mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 09:57:43 +01:00
149 lines
6.5 KiB
Diff
149 lines
6.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: BillyGalbreath <blake.galbreath@gmail.com>
|
|
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/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<Byte> 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;
|