From fe5fcdab1bb7a75f85619bfedb01e276f7519702 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 5 Jan 2025 13:33:23 -0800 Subject: [PATCH] Tulips change fox type --- .../server/0028-Tulips-change-fox-type.patch | 80 ------------------- .../features/0001-Ridables.patch | 14 ++-- .../world/entity/animal/Fox.java.patch | 52 ++++++++++++ .../purpurmc/purpur/PurpurWorldConfig.java | 2 + 4 files changed, 61 insertions(+), 87 deletions(-) delete mode 100644 patches/server/0028-Tulips-change-fox-type.patch create mode 100644 purpur-server/minecraft-patches/sources/net/minecraft/world/entity/animal/Fox.java.patch diff --git a/patches/server/0028-Tulips-change-fox-type.patch b/patches/server/0028-Tulips-change-fox-type.patch deleted file mode 100644 index e21ddc104..000000000 --- a/patches/server/0028-Tulips-change-fox-type.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: William Blake Galbreath -Date: Sat, 13 Jul 2019 15:56:22 -0500 -Subject: [PATCH] Tulips change fox type - - -diff --git a/net/minecraft/world/entity/animal/Fox.java b/net/minecraft/world/entity/animal/Fox.java -index 584d08bca961f8b8487b844cd2412b773401296d..a0adc29bb09a3eaecdaf564fd992b8aefec69629 100644 ---- a/net/minecraft/world/entity/animal/Fox.java -+++ b/net/minecraft/world/entity/animal/Fox.java -@@ -385,6 +385,11 @@ public class Fox extends Animal implements VariantHolder { - } - - private void setTargetGoals() { -+ // Purpur start - do not add duplicate goals -+ this.targetSelector.removeGoal(this.landTargetGoal); -+ this.targetSelector.removeGoal(this.turtleEggTargetGoal); -+ this.targetSelector.removeGoal(this.fishTargetGoal); -+ // Purpur end - if (this.getVariant() == Fox.Variant.RED) { - this.targetSelector.addGoal(4, this.landTargetGoal); - this.targetSelector.addGoal(4, this.turtleEggTargetGoal); -@@ -414,6 +419,7 @@ public class Fox extends Animal implements VariantHolder { - - public void setVariant(Fox.Variant variant) { - this.entityData.set(Fox.DATA_TYPE_ID, variant.getId()); -+ this.setTargetGoals(); // Purpur - fix API bug not updating pathfinders on type change - } - - List getTrustedUUIDs() { -@@ -749,6 +755,29 @@ public class Fox extends Animal implements VariantHolder { - } - // Paper end - -+ // Purpur start -+ @Override -+ public net.minecraft.world.InteractionResult mobInteract(Player player, net.minecraft.world.InteractionHand hand) { -+ if (level().purpurConfig.foxTypeChangesWithTulips) { -+ ItemStack itemstack = player.getItemInHand(hand); -+ if (getVariant() == Variant.RED && itemstack.getItem() == Items.WHITE_TULIP) { -+ setVariant(Variant.SNOW); -+ if (!player.getAbilities().instabuild) { -+ itemstack.shrink(1); -+ } -+ return net.minecraft.world.InteractionResult.SUCCESS; -+ } else if (getVariant() == Variant.SNOW && itemstack.getItem() == Items.ORANGE_TULIP) { -+ setVariant(Variant.RED); -+ if (!player.getAbilities().instabuild) { -+ itemstack.shrink(1); -+ } -+ return net.minecraft.world.InteractionResult.SUCCESS; -+ } -+ } -+ return super.mobInteract(player, hand); -+ } -+ // Purpur end -+ - @Override - // Paper start - Cancellable death event - protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(ServerLevel world, DamageSource damageSource) { -diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 0ba770af96809403dd93317dcf5120c7d87bf587..37f89fabc286ea07bf6438df7ed7c8d6bcb76d48 100644 ---- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -586,6 +586,7 @@ public class PurpurWorldConfig { - public boolean foxControllable = true; - public double foxMaxHealth = 10.0D; - public double foxScale = 1.0D; -+ public boolean foxTypeChangesWithTulips = false; - private void foxSettings() { - foxRidable = getBoolean("mobs.fox.ridable", foxRidable); - foxRidableInWater = getBoolean("mobs.fox.ridable-in-water", foxRidableInWater); -@@ -597,6 +598,7 @@ public class PurpurWorldConfig { - } - foxMaxHealth = getDouble("mobs.fox.attributes.max_health", foxMaxHealth); - foxScale = Mth.clamp(getDouble("mobs.fox.attributes.scale", foxScale), 0.0625D, 16.0D); -+ foxTypeChangesWithTulips = getBoolean("mobs.fox.tulips-change-type", foxTypeChangesWithTulips); - } - - public boolean frogRidable = false; diff --git a/purpur-server/minecraft-patches/features/0001-Ridables.patch b/purpur-server/minecraft-patches/features/0001-Ridables.patch index ce6d3117e..1a39ad090 100644 --- a/purpur-server/minecraft-patches/features/0001-Ridables.patch +++ b/purpur-server/minecraft-patches/features/0001-Ridables.patch @@ -30,7 +30,7 @@ index 717b2496ffb1246e6335db8eb5c8e724fbacd1cf..6812185f1d1a1fb14285267b7398f4ca /* Drop global time updates if (this.tickCount % 20 == 0) { diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 1ed30a8fa93d248e682dae48f7cc5bae9c005b03..909eed8ed93ae9f205c3e0c63bf6b7988a1cc8be 100644 +index 8d8248a014d95f1fc0d75b2c14c010eef39bab62..f2cd492c8c66ffe2eca5bbd925469a76693142f8 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -215,6 +215,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -966,7 +966,7 @@ index 4141052dfd635804195a5cfa24dbd0394355a7da..0e4112793dddc0d75f4bed35bb880c03 this.setAirSupply(this.getMaxAirSupply()); } else { diff --git a/net/minecraft/world/entity/animal/Fox.java b/net/minecraft/world/entity/animal/Fox.java -index 44bb04cc9796a16f5477d8f2ad22af62c9af1fc3..ff22b9bd7eb2b60fac58cae0a2be1d93a6eef7b7 100644 +index ddc252c76cedec0a0e9e268d8a874015a5ad52fe..8b0a813f9dd001c6dd108ba7aac04d134a20fbc1 100644 --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java @@ -129,6 +129,44 @@ public class Fox extends Animal implements VariantHolder { @@ -1030,7 +1030,7 @@ index 44bb04cc9796a16f5477d8f2ad22af62c9af1fc3..ff22b9bd7eb2b60fac58cae0a2be1d93 this.targetSelector .addGoal( 3, -@@ -1066,15 +1106,15 @@ public class Fox extends Animal implements VariantHolder { +@@ -1095,15 +1135,15 @@ public class Fox extends Animal implements VariantHolder { } } @@ -1049,7 +1049,7 @@ index 44bb04cc9796a16f5477d8f2ad22af62c9af1fc3..ff22b9bd7eb2b60fac58cae0a2be1d93 } } -@@ -1110,15 +1150,15 @@ public class Fox extends Animal implements VariantHolder { +@@ -1139,15 +1179,15 @@ public class Fox extends Animal implements VariantHolder { } } @@ -1518,7 +1518,7 @@ index d94a7cfcd0f7a15ce97d3b12daa8b2c71acf997a..f7e9abf778186ad1c78dbe411980a83c protected void defineSynchedData(SynchedEntityData.Builder builder) { super.defineSynchedData(builder); diff --git a/net/minecraft/world/entity/animal/Rabbit.java b/net/minecraft/world/entity/animal/Rabbit.java -index 4708c7479fdd818f6fdf672b45af1ed435d7d2ef..6e39e00fc6227edda23d4ec23a5625562a452fd2 100644 +index b2cbe9f7a771dbfc381effa0821d44421c98b33e..8cac46951938c80fae3499e8b53709c25d86e9bd 100644 --- a/net/minecraft/world/entity/animal/Rabbit.java +++ b/net/minecraft/world/entity/animal/Rabbit.java @@ -83,6 +83,7 @@ public class Rabbit extends Animal implements VariantHolder { @@ -3131,7 +3131,7 @@ index 2e32567fca7a2a4cd87bc078a6eeb30e3ffabfce..4873a3d8dd9c160ecdbda594ee546c35 public boolean doHurtTarget(ServerLevel level, Entity source) { if (super.doHurtTarget(level, source)) { diff --git a/net/minecraft/world/entity/monster/Creeper.java b/net/minecraft/world/entity/monster/Creeper.java -index 958a69656a5fac2c04047d452deb15203f436d72..1e2acc2fb369afe8cb391e4b8ac0c2927af2127b 100644 +index 2b3e1fcf4ec73f5be1804c77ffd74f27c2dc2eaf..cae4c797cf72920b9fd8e79d95d51367b5f7b87b 100644 --- a/net/minecraft/world/entity/monster/Creeper.java +++ b/net/minecraft/world/entity/monster/Creeper.java @@ -50,21 +50,98 @@ public class Creeper extends Monster { @@ -4468,7 +4468,7 @@ index 7f1cdea810db24182f8f87076c42a19b1b43e98a..26528bc9a9cffb68f82917a3e70900cf Vec3 deltaMovement = Vex.this.getDeltaMovement(); Vex.this.setYRot(-((float)Mth.atan2(deltaMovement.x, deltaMovement.z)) * (180.0F / (float)Math.PI)); diff --git a/net/minecraft/world/entity/monster/Vindicator.java b/net/minecraft/world/entity/monster/Vindicator.java -index 402c22d9feaf0301ed95692b783fb0f226510833..8a6a0b7522437a3cb627a164b9164b53dee6c460 100644 +index 5e7506f64159ac4838eee8594c995387e2fceed0..c1a1bb0be8bc77a1c0f771924f3bb8b4936d367b 100644 --- a/net/minecraft/world/entity/monster/Vindicator.java +++ b/net/minecraft/world/entity/monster/Vindicator.java @@ -55,15 +55,34 @@ public class Vindicator extends AbstractIllager { diff --git a/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/animal/Fox.java.patch b/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/animal/Fox.java.patch new file mode 100644 index 000000000..c0f401ee5 --- /dev/null +++ b/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/animal/Fox.java.patch @@ -0,0 +1,52 @@ +--- a/net/minecraft/world/entity/animal/Fox.java ++++ b/net/minecraft/world/entity/animal/Fox.java +@@ -335,6 +_,11 @@ + } + + private void setTargetGoals() { ++ // Purpur start - Tulips change fox type - do not add duplicate goals ++ this.targetSelector.removeGoal(this.landTargetGoal); ++ this.targetSelector.removeGoal(this.turtleEggTargetGoal); ++ this.targetSelector.removeGoal(this.fishTargetGoal); ++ // Purpur end - Tulips change fox type + if (this.getVariant() == Fox.Variant.RED) { + this.targetSelector.addGoal(4, this.landTargetGoal); + this.targetSelector.addGoal(4, this.turtleEggTargetGoal); +@@ -364,6 +_,7 @@ + @Override + public void setVariant(Fox.Variant variant) { + this.entityData.set(DATA_TYPE_ID, variant.getId()); ++ this.setTargetGoals(); // Purpur - Tulips change fox type - fix API bug not updating pathfinders on type change + } + + List getTrustedUUIDs() { +@@ -684,6 +_,29 @@ + return slot == EquipmentSlot.MAINHAND; + } + // Paper end ++ ++ // Purpur start - Tulips change fox type ++ @Override ++ public net.minecraft.world.InteractionResult mobInteract(Player player, net.minecraft.world.InteractionHand hand) { ++ if (level().purpurConfig.foxTypeChangesWithTulips) { ++ ItemStack itemstack = player.getItemInHand(hand); ++ if (getVariant() == Variant.RED && itemstack.getItem() == Items.WHITE_TULIP) { ++ setVariant(Variant.SNOW); ++ if (!player.getAbilities().instabuild) { ++ itemstack.shrink(1); ++ } ++ return net.minecraft.world.InteractionResult.SUCCESS; ++ } else if (getVariant() == Variant.SNOW && itemstack.getItem() == Items.ORANGE_TULIP) { ++ setVariant(Variant.RED); ++ if (!player.getAbilities().instabuild) { ++ itemstack.shrink(1); ++ } ++ return net.minecraft.world.InteractionResult.SUCCESS; ++ } ++ } ++ return super.mobInteract(player, hand); ++ } ++ // Purpur end - Tulips change fox type + + @Override + // Paper start - Cancellable death event diff --git a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index 16df261c3..41f60788b 100644 --- a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -572,6 +572,7 @@ public class PurpurWorldConfig { public boolean foxControllable = true; public double foxMaxHealth = 10.0D; public double foxScale = 1.0D; + public boolean foxTypeChangesWithTulips = false; private void foxSettings() { foxRidable = getBoolean("mobs.fox.ridable", foxRidable); foxRidableInWater = getBoolean("mobs.fox.ridable-in-water", foxRidableInWater); @@ -583,6 +584,7 @@ public class PurpurWorldConfig { } foxMaxHealth = getDouble("mobs.fox.attributes.max_health", foxMaxHealth); foxScale = Mth.clamp(getDouble("mobs.fox.attributes.scale", foxScale), 0.0625D, 16.0D); + foxTypeChangesWithTulips = getBoolean("mobs.fox.tulips-change-type", foxTypeChangesWithTulips); } public boolean frogRidable = false;