mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Iron golem calm anger options
This commit is contained in:
committed by
granny
parent
b40d56f9be
commit
68b70c0446
@@ -1,145 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
||||||
Date: Thu, 13 May 2021 21:22:51 -0500
|
|
||||||
Subject: [PATCH] Iron golem calm anger options
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/entity/animal/IronGolem.java b/net/minecraft/world/entity/animal/IronGolem.java
|
|
||||||
index 74971f19a646b78bff66d2543d80d9358fdd29c5..da51e119c290a850072679a7b4f4bde3025c95cf 100644
|
|
||||||
--- a/net/minecraft/world/entity/animal/IronGolem.java
|
|
||||||
+++ b/net/minecraft/world/entity/animal/IronGolem.java
|
|
||||||
@@ -95,6 +95,7 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
|
|
||||||
@Override
|
|
||||||
protected void registerGoals() {
|
|
||||||
if (level().purpurConfig.ironGolemCanSwim) this.goalSelector.addGoal(0, new net.minecraft.world.entity.ai.goal.FloatGoal(this)); // Purpur - Ridables
|
|
||||||
+ if (this.level().purpurConfig.ironGolemPoppyCalm) this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.ReceiveFlower(this)); // Purpur - Iron golem calm anger options
|
|
||||||
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables
|
|
||||||
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0D, true));
|
|
||||||
this.goalSelector.addGoal(2, new MoveTowardsTargetGoal(this, 0.9D, 32.0F));
|
|
||||||
@@ -312,6 +313,7 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
|
|
||||||
|
|
||||||
this.playSound(SoundEvents.IRON_GOLEM_REPAIR, 1.0F, f1);
|
|
||||||
itemstack.consume(1, player);
|
|
||||||
+ if (this.level().purpurConfig.ironGolemHealCalm && isAngry() && getHealth() == getMaxHealth()) stopBeingAngry(); // Purpur - Iron golem calm anger options
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
index 851d0c96350abc8d8c490d92183540b013a98d12..5caaaa88d71f84562f8ab403062bf9ac4eb4dfb9 100644
|
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
@@ -1442,6 +1442,8 @@ public class PurpurWorldConfig {
|
|
||||||
public double ironGolemMaxHealth = 100.0D;
|
|
||||||
public double ironGolemScale = 1.0D;
|
|
||||||
public boolean ironGolemTakeDamageFromWater = false;
|
|
||||||
+ public boolean ironGolemPoppyCalm = false;
|
|
||||||
+ public boolean ironGolemHealCalm = false;
|
|
||||||
private void ironGolemSettings() {
|
|
||||||
ironGolemRidable = getBoolean("mobs.iron_golem.ridable", ironGolemRidable);
|
|
||||||
ironGolemRidableInWater = getBoolean("mobs.iron_golem.ridable-in-water", ironGolemRidableInWater);
|
|
||||||
@@ -1455,6 +1457,8 @@ public class PurpurWorldConfig {
|
|
||||||
ironGolemMaxHealth = getDouble("mobs.iron_golem.attributes.max_health", ironGolemMaxHealth);
|
|
||||||
ironGolemScale = Mth.clamp(getDouble("mobs.iron_golem.attributes.scale", ironGolemScale), 0.0625D, 16.0D);
|
|
||||||
ironGolemTakeDamageFromWater = getBoolean("mobs.iron_golem.takes-damage-from-water", ironGolemTakeDamageFromWater);
|
|
||||||
+ ironGolemPoppyCalm = getBoolean("mobs.iron_golem.poppy-calms-anger", ironGolemPoppyCalm);
|
|
||||||
+ ironGolemHealCalm = getBoolean("mobs.iron_golem.healing-calms-anger", ironGolemHealCalm);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean llamaRidable = false;
|
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/entity/ai/ReceiveFlower.java b/src/main/java/org/purpurmc/purpur/entity/ai/ReceiveFlower.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..9660716f4162a4441c6e1b0baddef8f5086566c5
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/entity/ai/ReceiveFlower.java
|
|
||||||
@@ -0,0 +1,91 @@
|
|
||||||
+package org.purpurmc.purpur.entity.ai;
|
|
||||||
+
|
|
||||||
+import net.minecraft.server.level.ServerLevel;
|
|
||||||
+import net.minecraft.server.level.ServerPlayer;
|
|
||||||
+import net.minecraft.world.InteractionHand;
|
|
||||||
+import net.minecraft.world.entity.Entity;
|
|
||||||
+import net.minecraft.world.entity.ai.goal.Goal;
|
|
||||||
+import net.minecraft.world.entity.animal.IronGolem;
|
|
||||||
+import net.minecraft.world.item.ItemStack;
|
|
||||||
+import net.minecraft.world.level.block.Blocks;
|
|
||||||
+
|
|
||||||
+import java.util.EnumSet;
|
|
||||||
+import java.util.UUID;
|
|
||||||
+
|
|
||||||
+public class ReceiveFlower extends Goal {
|
|
||||||
+ private final IronGolem irongolem;
|
|
||||||
+ private ServerPlayer target;
|
|
||||||
+ private int cooldown;
|
|
||||||
+
|
|
||||||
+ public ReceiveFlower(IronGolem entity) {
|
|
||||||
+ this.irongolem = entity;
|
|
||||||
+ setFlags(EnumSet.of(Flag.MOVE, Flag.LOOK));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public boolean canUse() {
|
|
||||||
+ if (this.irongolem.getOfferFlowerTick() > 0) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ if (!this.irongolem.isAngry()) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ UUID uuid = this.irongolem.getPersistentAngerTarget();
|
|
||||||
+ if (uuid == null) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ Entity target = ((ServerLevel) this.irongolem.level()).getEntity(uuid);
|
|
||||||
+ if (!(target instanceof ServerPlayer player)) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ InteractionHand hand = getPoppyHand(player);
|
|
||||||
+ if (hand == null) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ removeFlower(player, hand);
|
|
||||||
+ this.target = player;
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public boolean canContinueToUse() {
|
|
||||||
+ return this.cooldown > 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public void start() {
|
|
||||||
+ this.cooldown = 100;
|
|
||||||
+ this.irongolem.stopBeingAngry();
|
|
||||||
+ this.irongolem.offerFlower(true);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public void stop() {
|
|
||||||
+ this.irongolem.offerFlower(false);
|
|
||||||
+ this.target = null;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public void tick() {
|
|
||||||
+ this.irongolem.getLookControl().setLookAt(this.target, 30.0F, 30.0F);
|
|
||||||
+ --this.cooldown;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private InteractionHand getPoppyHand(ServerPlayer player) {
|
|
||||||
+ if (isPoppy(player.getMainHandItem())) {
|
|
||||||
+ return InteractionHand.MAIN_HAND;
|
|
||||||
+ }
|
|
||||||
+ if (isPoppy(player.getOffhandItem())) {
|
|
||||||
+ return InteractionHand.OFF_HAND;
|
|
||||||
+ }
|
|
||||||
+ return null;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private void removeFlower(ServerPlayer player, InteractionHand hand) {
|
|
||||||
+ player.setItemInHand(hand, ItemStack.EMPTY);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private boolean isPoppy(ItemStack item) {
|
|
||||||
+ return item.getItem() == Blocks.POPPY.asItem();
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
--- a/net/minecraft/world/entity/animal/IronGolem.java
|
||||||
|
+++ b/net/minecraft/world/entity/animal/IronGolem.java
|
||||||
|
@@ -63,6 +_,7 @@
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerGoals() {
|
||||||
|
+ if (this.level().purpurConfig.ironGolemPoppyCalm) this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.ReceiveFlower(this)); // Purpur - Iron golem calm anger options
|
||||||
|
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0, true));
|
||||||
|
this.goalSelector.addGoal(2, new MoveTowardsTargetGoal(this, 0.9, 32.0F));
|
||||||
|
this.goalSelector.addGoal(2, new MoveBackToVillageGoal(this, 0.6, false));
|
||||||
|
@@ -266,6 +_,7 @@
|
||||||
|
float f = 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F;
|
||||||
|
this.playSound(SoundEvents.IRON_GOLEM_REPAIR, 1.0F, f);
|
||||||
|
itemInHand.consume(1, player);
|
||||||
|
+ if (this.level().purpurConfig.ironGolemHealCalm && isAngry() && getHealth() == getMaxHealth()) stopBeingAngry(); // Purpur - Iron golem calm anger options
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1434,6 +1434,8 @@ public class PurpurWorldConfig {
|
|||||||
public double ironGolemMaxHealth = 100.0D;
|
public double ironGolemMaxHealth = 100.0D;
|
||||||
public double ironGolemScale = 1.0D;
|
public double ironGolemScale = 1.0D;
|
||||||
public boolean ironGolemTakeDamageFromWater = false;
|
public boolean ironGolemTakeDamageFromWater = false;
|
||||||
|
public boolean ironGolemPoppyCalm = false;
|
||||||
|
public boolean ironGolemHealCalm = false;
|
||||||
private void ironGolemSettings() {
|
private void ironGolemSettings() {
|
||||||
ironGolemRidable = getBoolean("mobs.iron_golem.ridable", ironGolemRidable);
|
ironGolemRidable = getBoolean("mobs.iron_golem.ridable", ironGolemRidable);
|
||||||
ironGolemRidableInWater = getBoolean("mobs.iron_golem.ridable-in-water", ironGolemRidableInWater);
|
ironGolemRidableInWater = getBoolean("mobs.iron_golem.ridable-in-water", ironGolemRidableInWater);
|
||||||
@@ -1447,6 +1449,8 @@ public class PurpurWorldConfig {
|
|||||||
ironGolemMaxHealth = getDouble("mobs.iron_golem.attributes.max_health", ironGolemMaxHealth);
|
ironGolemMaxHealth = getDouble("mobs.iron_golem.attributes.max_health", ironGolemMaxHealth);
|
||||||
ironGolemScale = Mth.clamp(getDouble("mobs.iron_golem.attributes.scale", ironGolemScale), 0.0625D, 16.0D);
|
ironGolemScale = Mth.clamp(getDouble("mobs.iron_golem.attributes.scale", ironGolemScale), 0.0625D, 16.0D);
|
||||||
ironGolemTakeDamageFromWater = getBoolean("mobs.iron_golem.takes-damage-from-water", ironGolemTakeDamageFromWater);
|
ironGolemTakeDamageFromWater = getBoolean("mobs.iron_golem.takes-damage-from-water", ironGolemTakeDamageFromWater);
|
||||||
|
ironGolemPoppyCalm = getBoolean("mobs.iron_golem.poppy-calms-anger", ironGolemPoppyCalm);
|
||||||
|
ironGolemHealCalm = getBoolean("mobs.iron_golem.healing-calms-anger", ironGolemHealCalm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean llamaRidable = false;
|
public boolean llamaRidable = false;
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package org.purpurmc.purpur.entity.ai;
|
||||||
|
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.ai.goal.Goal;
|
||||||
|
import net.minecraft.world.entity.animal.IronGolem;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ReceiveFlower extends Goal {
|
||||||
|
private final IronGolem irongolem;
|
||||||
|
private ServerPlayer target;
|
||||||
|
private int cooldown;
|
||||||
|
|
||||||
|
public ReceiveFlower(IronGolem entity) {
|
||||||
|
this.irongolem = entity;
|
||||||
|
setFlags(EnumSet.of(Flag.MOVE, Flag.LOOK));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUse() {
|
||||||
|
if (this.irongolem.getOfferFlowerTick() > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!this.irongolem.isAngry()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
UUID uuid = this.irongolem.getPersistentAngerTarget();
|
||||||
|
if (uuid == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Entity target = ((ServerLevel) this.irongolem.level()).getEntity(uuid);
|
||||||
|
if (!(target instanceof ServerPlayer player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
InteractionHand hand = getPoppyHand(player);
|
||||||
|
if (hand == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
removeFlower(player, hand);
|
||||||
|
this.target = player;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canContinueToUse() {
|
||||||
|
return this.cooldown > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
this.cooldown = 100;
|
||||||
|
this.irongolem.stopBeingAngry();
|
||||||
|
this.irongolem.offerFlower(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
this.irongolem.offerFlower(false);
|
||||||
|
this.target = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
this.irongolem.getLookControl().setLookAt(this.target, 30.0F, 30.0F);
|
||||||
|
--this.cooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
private InteractionHand getPoppyHand(ServerPlayer player) {
|
||||||
|
if (isPoppy(player.getMainHandItem())) {
|
||||||
|
return InteractionHand.MAIN_HAND;
|
||||||
|
}
|
||||||
|
if (isPoppy(player.getOffhandItem())) {
|
||||||
|
return InteractionHand.OFF_HAND;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeFlower(ServerPlayer player, InteractionHand hand) {
|
||||||
|
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPoppy(ItemStack item) {
|
||||||
|
return item.getItem() == Blocks.POPPY.asItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user