From 552d783c644528db64c6e19a78bef3a729580d8a Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Thu, 13 May 2021 22:00:52 -0500 Subject: [PATCH] Iron golem poppy calms anger --- .../0041-Iron-golem-poppy-calms-anger.patch | 17 ++ .../0211-Extend-Halloween-Optimization.patch | 10 +- .../0213-Iron-golem-poppy-calms-anger.patch | 160 ++++++++++++++++++ 3 files changed, 182 insertions(+), 5 deletions(-) create mode 100644 patches/api/0041-Iron-golem-poppy-calms-anger.patch create mode 100644 patches/server/0213-Iron-golem-poppy-calms-anger.patch diff --git a/patches/api/0041-Iron-golem-poppy-calms-anger.patch b/patches/api/0041-Iron-golem-poppy-calms-anger.patch new file mode 100644 index 000000000..0287a30a9 --- /dev/null +++ b/patches/api/0041-Iron-golem-poppy-calms-anger.patch @@ -0,0 +1,17 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Thu, 13 May 2021 21:38:01 -0500 +Subject: [PATCH] Iron golem poppy calms anger + + +diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java +index 39f77041133228c4bd4cec2427ad0bae8e739d4a..29144c0e325a3efbef05670a6fb2e849bbed6bba 100644 +--- a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java ++++ b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java +@@ -214,5 +214,6 @@ public interface VanillaGoal extends Goal { + GoalKey DROWNED_ATTACK_VILLAGER = GoalKey.of(Drowned.class, NamespacedKey.minecraft("drowned_attack_villager")); + GoalKey ZOMBIE_ATTACK_VILLAGER = GoalKey.of(Zombie.class, NamespacedKey.minecraft("zombie_attack_villager")); + GoalKey AVOID_RABID_WOLVES = GoalKey.of(Wolf.class, NamespacedKey.minecraft("avoid_rabid_wolves")); ++ GoalKey RECEIVE_FLOWER = GoalKey.of(IronGolem.class, NamespacedKey.minecraft("receive_flower")); + // Purpur end + } diff --git a/patches/server/0211-Extend-Halloween-Optimization.patch b/patches/server/0211-Extend-Halloween-Optimization.patch index 5e2ea6f5e..a52b9c486 100644 --- a/patches/server/0211-Extend-Halloween-Optimization.patch +++ b/patches/server/0211-Extend-Halloween-Optimization.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Extend Halloween Optimization diff --git a/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java b/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java -index bd02320d450a7fd7254f01b1c44ef421c1810ea7..dcc1f203b9bc0510d4c7fedbb4db7a10855d630f 100644 +index bd02320d450a7fd7254f01b1c44ef421c1810ea7..33f380c543677b5a382d1e9163cd0bbd3585be4b 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java @@ -311,17 +311,31 @@ public class EntityBat extends EntityAmbient { @@ -34,10 +34,10 @@ index bd02320d450a7fd7254f01b1c44ef421c1810ea7..dcc1f203b9bc0510d4c7fedbb4db7a10 - int j = localdate.get(ChronoField.MONTH_OF_YEAR); - isSpookySeason = j == 10 && i >= 20 || j == 11 && i <= 3; + LocalDate localdate = LocalDate.now(); -+ int month = localdate.get(ChronoField.DAY_OF_MONTH); -+ int day = localdate.get(ChronoField.MONTH_OF_YEAR); -+ isHalloween = day == 10 && month == 31; // Purpur -+ isSpookySeason = day == 10 && month >= 20 || day == 11 && month <= 3; ++ int day = localdate.get(ChronoField.DAY_OF_MONTH); ++ int month = localdate.get(ChronoField.MONTH_OF_YEAR); ++ isHalloween = month == 10 && day == 31; // Purpur ++ isSpookySeason = month == 10 && day >= 20 || month == 11 && day <= 3; lastSpookyCheck = MinecraftServer.currentTick; } - diff --git a/patches/server/0213-Iron-golem-poppy-calms-anger.patch b/patches/server/0213-Iron-golem-poppy-calms-anger.patch new file mode 100644 index 000000000..fc405dbb9 --- /dev/null +++ b/patches/server/0213-Iron-golem-poppy-calms-anger.patch @@ -0,0 +1,160 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Thu, 13 May 2021 21:22:51 -0500 +Subject: [PATCH] Iron golem poppy calms anger + + +diff --git a/src/main/java/net/minecraft/world/entity/ai/control/ControllerLook.java b/src/main/java/net/minecraft/world/entity/ai/control/ControllerLook.java +index 3ce9edde641c8b8eea75479615bcd2866ffd2198..295d8614d611a185489a46527e7980dc9c38f12d 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/control/ControllerLook.java ++++ b/src/main/java/net/minecraft/world/entity/ai/control/ControllerLook.java +@@ -24,6 +24,7 @@ public class ControllerLook { + this.a(vec3d.x, vec3d.y, vec3d.z); + } + ++ public void lookAt(Entity entity, float f, float f1) { a(entity, f, f1); } // Purpur - OBFHELPER + public void a(Entity entity, float f, float f1) { + this.a(entity.locX(), b(entity), entity.locZ(), f, f1); + } +diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/target/PathfinderGoalReceiveFlower.java b/src/main/java/net/minecraft/world/entity/ai/goal/target/PathfinderGoalReceiveFlower.java +new file mode 100644 +index 0000000000000000000000000000000000000000..6a288fead988d424aa369b8ef6378ab3c9ec16af +--- /dev/null ++++ b/src/main/java/net/minecraft/world/entity/ai/goal/target/PathfinderGoalReceiveFlower.java +@@ -0,0 +1,79 @@ ++package net.minecraft.world.entity.ai.goal.target; ++ ++import net.minecraft.server.level.EntityPlayer; ++import net.minecraft.server.level.WorldServer; ++import net.minecraft.world.entity.Entity; ++import net.minecraft.world.entity.ai.goal.PathfinderGoal; ++import net.minecraft.world.entity.animal.EntityIronGolem; ++import net.minecraft.world.item.ItemStack; ++import net.minecraft.world.level.block.Blocks; ++ ++import java.util.EnumSet; ++import java.util.UUID; ++ ++public class PathfinderGoalReceiveFlower extends PathfinderGoal { ++ private final EntityIronGolem entity; ++ private EntityPlayer target; ++ private int cooldown; ++ ++ public PathfinderGoalReceiveFlower(EntityIronGolem entity) { ++ this.entity = entity; ++ this.setTypes(EnumSet.of(Type.MOVE, Type.LOOK)); ++ } ++ ++ @Override ++ public boolean shouldActivate() { ++ if (this.entity.getHoldingFlowerTick() > 0) { ++ return false; ++ } ++ if (!this.entity.isAngry()) { ++ return false; ++ } ++ UUID uuid = this.entity.getAngerTarget(); ++ if (uuid == null) { ++ return false; ++ } ++ Entity target = ((WorldServer) this.entity.world).getEntity(uuid); ++ if (!(target instanceof EntityPlayer)) { ++ return false; ++ } ++ EntityPlayer player = (EntityPlayer) target; ++ if (!isHoldingFlower(player)) { ++ return false; ++ } ++ this.target = player; ++ return true; ++ } ++ ++ @Override ++ public boolean shouldStayActive() { ++ return this.cooldown > 0; ++ } ++ ++ @Override ++ public void start() { ++ this.cooldown = 100; ++ this.entity.pacify(); ++ this.entity.holdFlower(true); ++ } ++ ++ @Override ++ public void onTaskReset() { ++ this.entity.holdFlower(false); ++ this.target = null; ++ } ++ ++ @Override ++ public void tick() { ++ this.entity.getControllerLook().lookAt(this.target, 30.0F, 30.0F); ++ --this.cooldown; ++ } ++ ++ private boolean isHoldingFlower(EntityPlayer player) { ++ return isPoppy(player.getItemInMainHand()) || isPoppy(player.getItemInOffHand()); ++ } ++ ++ private boolean isPoppy(ItemStack item) { ++ return item.getItem() == Blocks.POPPY.getItem(); ++ } ++} +diff --git a/src/main/java/net/minecraft/world/entity/animal/EntityIronGolem.java b/src/main/java/net/minecraft/world/entity/animal/EntityIronGolem.java +index 9ee82c908008190e31034e614c241fc7a66248e1..402a8733905ebbbb9c1d962bafa7fd806a9253cc 100644 +--- a/src/main/java/net/minecraft/world/entity/animal/EntityIronGolem.java ++++ b/src/main/java/net/minecraft/world/entity/animal/EntityIronGolem.java +@@ -42,6 +42,7 @@ import net.minecraft.world.entity.ai.goal.PathfinderGoalStrollVillageGolem; + import net.minecraft.world.entity.ai.goal.target.PathfinderGoalDefendVillage; + import net.minecraft.world.entity.ai.goal.target.PathfinderGoalHurtByTarget; + import net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget; ++import net.minecraft.world.entity.ai.goal.target.PathfinderGoalReceiveFlower; + import net.minecraft.world.entity.ai.goal.target.PathfinderGoalUniversalAngerReset; + import net.minecraft.world.entity.monster.EntityCreeper; + import net.minecraft.world.entity.monster.IMonster; +@@ -60,7 +61,7 @@ public class EntityIronGolem extends EntityGolem implements IEntityAngerable { + + protected static final DataWatcherObject b = DataWatcher.a(EntityIronGolem.class, DataWatcherRegistry.a); + private int c; +- private int d; ++ private int d; public int getHoldingFlowerTick() { return d; } // Purpur - OBFHELPER + private static final IntRange bo = TimeRange.a(20, 39); + private int bp; + private UUID bq; +@@ -91,6 +92,7 @@ public class EntityIronGolem extends EntityGolem implements IEntityAngerable { + protected void initPathfinder() { + if (world.purpurConfig.ironGolemCanSwim) this.goalSelector.a(0, new PathfinderGoalFloat(this)); // Purpur + this.goalSelector.a(0, new PathfinderGoalHasRider(this)); // Purpur ++ if (world.purpurConfig.ironGolemPoppyCalm) this.goalSelector.addGoal(0, new PathfinderGoalReceiveFlower(this)); // Purpur + this.goalSelector.a(1, new PathfinderGoalMeleeAttack(this, 1.0D, true)); + this.goalSelector.a(2, new PathfinderGoalMoveTowardsTarget(this, 0.9D, 32.0F)); + this.goalSelector.a(2, new PathfinderGoalStrollVillage(this, 0.6D, false)); +@@ -241,6 +243,7 @@ public class EntityIronGolem extends EntityGolem implements IEntityAngerable { + return EntityIronGolem.CrackLevel.a(this.getHealth() / this.getMaxHealth()); + } + ++ public void holdFlower(boolean flag) { t(flag); } // Purpur - OBFHELPER + public void t(boolean flag) { + if (flag) { + this.d = 400; +diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +index 5659e75177f3c5acb935b0f6dc0b720853602108..ffb8d505a723d61bd6311f4116524d9a99a27f62 100644 +--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java ++++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +@@ -1183,6 +1183,7 @@ public class PurpurWorldConfig { + public boolean ironGolemRidableInWater = false; + public boolean ironGolemCanSwim = false; + public double ironGolemMaxHealth = 100.0D; ++ public boolean ironGolemPoppyCalm = false; + private void ironGolemSettings() { + ironGolemRidable = getBoolean("mobs.iron_golem.ridable", ironGolemRidable); + ironGolemRidableInWater = getBoolean("mobs.iron_golem.ridable-in-water", ironGolemRidableInWater); +@@ -1193,6 +1194,7 @@ public class PurpurWorldConfig { + set("mobs.iron_golem.attributes.max_health", oldValue); + } + ironGolemMaxHealth = getDouble("mobs.iron_golem.attributes.max_health", ironGolemMaxHealth); ++ ironGolemPoppyCalm = getBoolean("mobs.iron_golem.poppy-calms-anger", ironGolemPoppyCalm); + } + + public boolean llamaRidable = false;