From e256ff6ac7caf69ddeceb3f0c2f6187129d3be4b Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 12 Jan 2025 12:45:47 -0800 Subject: [PATCH] Dolphins naturally aggressive to players chance --- ...turally-aggressive-to-players-chance.patch | 68 ------------------- .../features/0001-Ridables.patch | 24 +++---- ...-Configurable-entity-base-attributes.patch | 4 +- ...oggle-for-water-sensitive-mob-damage.patch | 4 +- .../world/entity/animal/Dolphin.java.patch | 37 ++++++++++ .../purpurmc/purpur/PurpurWorldConfig.java | 2 + 6 files changed, 55 insertions(+), 84 deletions(-) delete mode 100644 patches/server/0204-Dolphins-naturally-aggressive-to-players-chance.patch diff --git a/patches/server/0204-Dolphins-naturally-aggressive-to-players-chance.patch b/patches/server/0204-Dolphins-naturally-aggressive-to-players-chance.patch deleted file mode 100644 index e50a3c45f..000000000 --- a/patches/server/0204-Dolphins-naturally-aggressive-to-players-chance.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: William Blake Galbreath -Date: Mon, 30 Aug 2021 22:14:39 -0500 -Subject: [PATCH] Dolphins naturally aggressive to players chance - - -diff --git a/net/minecraft/world/entity/animal/Dolphin.java b/net/minecraft/world/entity/animal/Dolphin.java -index 46862ebf302454a077a837da001abdceeffa1026..64d1e932ac3bc673cffa324d8e75e8da596d6941 100644 ---- a/net/minecraft/world/entity/animal/Dolphin.java -+++ b/net/minecraft/world/entity/animal/Dolphin.java -@@ -86,6 +86,7 @@ public class Dolphin extends AgeableWaterCreature { - }; - public static final float BABY_SCALE = 0.65F; - private int spitCooldown; // Purpur - Ridables -+ private boolean isNaturallyAggressiveToPlayers; // Purpur - Dolphins naturally aggressive to players chance - - public Dolphin(EntityType type, Level world) { - super(type, world); -@@ -182,6 +183,7 @@ public class Dolphin extends AgeableWaterCreature { - SpawnGroupData groupdataentity1 = (SpawnGroupData) Objects.requireNonNullElseGet(entityData, () -> { - return new AgeableMob.AgeableMobGroupData(0.1F); - }); -+ this.isNaturallyAggressiveToPlayers = world.getLevel().purpurConfig.dolphinNaturallyAggressiveToPlayersChance > 0.0D && random.nextDouble() <= world.getLevel().purpurConfig.dolphinNaturallyAggressiveToPlayersChance; // Purpur - Dolphins naturally aggressive to players chance - - return super.finalizeSpawn(world, difficulty, spawnReason, groupdataentity1); - } -@@ -259,18 +261,20 @@ public class Dolphin extends AgeableWaterCreature { - this.goalSelector.addGoal(0, new BreathAirGoal(this)); - this.goalSelector.addGoal(0, new TryFindWaterGoal(this)); - this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables -+ this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2000000476837158D, true)); // Purpur - Dolphins naturally aggressive to players chance - this.goalSelector.addGoal(1, new Dolphin.DolphinSwimToTreasureGoal(this)); - this.goalSelector.addGoal(2, new Dolphin.DolphinSwimWithPlayerGoal(this, 4.0D)); - this.goalSelector.addGoal(4, new RandomSwimmingGoal(this, 1.0D, 10)); - this.goalSelector.addGoal(4, new RandomLookAroundGoal(this)); - this.goalSelector.addGoal(5, new LookAtPlayerGoal(this, Player.class, 6.0F)); - this.goalSelector.addGoal(5, new DolphinJumpGoal(this, 10)); -- this.goalSelector.addGoal(6, new MeleeAttackGoal(this, 1.2000000476837158D, true)); -+ //this.goalSelector.addGoal(6, new MeleeAttackGoal(this, 1.2000000476837158D, true)); // Purpur - moved up - Dolphins naturally aggressive to players chance - this.goalSelector.addGoal(8, new Dolphin.PlayWithItemsGoal()); - this.goalSelector.addGoal(8, new FollowBoatGoal(this)); - this.goalSelector.addGoal(9, new AvoidEntityGoal<>(this, Guardian.class, 8.0F, 1.0D, 1.0D)); - this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables - this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[]{Guardian.class})).setAlertOthers()); -+ this.targetSelector.addGoal(2, new net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (ignored, ignored2) -> isNaturallyAggressiveToPlayers)); // Purpur - Dolphins naturally aggressive to players chance - } - - public static AttributeSupplier.Builder createAttributes() { -diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 382ce37738d278400b609af7fb9189c93b907eeb..b1a18e3e1b2459adda1a2621a0aa7219d5580a0f 100644 ---- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -1367,6 +1367,7 @@ public class PurpurWorldConfig { - public double dolphinScale = 1.0D; - public boolean dolphinDisableTreasureSearching = false; - public boolean dolphinTakeDamageFromWater = false; -+ public double dolphinNaturallyAggressiveToPlayersChance = 0.0D; - private void dolphinSettings() { - dolphinRidable = getBoolean("mobs.dolphin.ridable", dolphinRidable); - dolphinControllable = getBoolean("mobs.dolphin.controllable", dolphinControllable); -@@ -1382,6 +1383,7 @@ public class PurpurWorldConfig { - dolphinScale = Mth.clamp(getDouble("mobs.dolphin.attributes.scale", dolphinScale), 0.0625D, 16.0D); - dolphinDisableTreasureSearching = getBoolean("mobs.dolphin.disable-treasure-searching", dolphinDisableTreasureSearching); - dolphinTakeDamageFromWater = getBoolean("mobs.dolphin.takes-damage-from-water", dolphinTakeDamageFromWater); -+ dolphinNaturallyAggressiveToPlayersChance = getDouble("mobs.dolphin.naturally-aggressive-to-players-chance", dolphinNaturallyAggressiveToPlayersChance); - } - - public boolean donkeyRidableInWater = false; diff --git a/purpur-server/minecraft-patches/features/0001-Ridables.patch b/purpur-server/minecraft-patches/features/0001-Ridables.patch index 67eb71a5e..a556fcd67 100644 --- a/purpur-server/minecraft-patches/features/0001-Ridables.patch +++ b/purpur-server/minecraft-patches/features/0001-Ridables.patch @@ -30,7 +30,7 @@ index c7a7a65273801ee1c11aa9f72ee2327beac21ec0..69bd4d3401cf8432494be78ce5d8c009 /* 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 4ad0cd0664384a671a538524c0d6ff5845c21ff0..8aa27a33f5f182937097427ed481152b7309fa56 100644 +index 704e618c1a71c5182bc927758eb3f91e5f008f7d..a55772a67bca2be0a36ce63e7b0143b825c40f01 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -217,6 +217,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -62,10 +62,10 @@ index 31739c5c9dfdd940263cc9b931068b3f624329ec..a8287654d3023f0a5fb183d4ad2dd418 private void updatePlayerAttributes() { diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index a2832445eab54cc6d93f929ac061949002f1bd4b..6d19faa36b4f824533e1b76e7cda1f324d1c179f 100644 +index 1c28e91e46d16a77da00f6fc06b9be1bd61ee5df..6f4d69a0c8a3ce91954ee61381dd2ad87510c11d 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2818,6 +2818,8 @@ public class ServerGamePacketListenerImpl +@@ -2819,6 +2819,8 @@ public class ServerGamePacketListenerImpl ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event); @@ -841,13 +841,13 @@ index 8c1f74c6be53cbf48bd6b5641511359578801c08..656babc0c8810a85eb9f78ced1f3ad95 // CraftBukkit end player.playSound(SoundEvents.COW_MILK, 1.0F, 1.0F); diff --git a/net/minecraft/world/entity/animal/Dolphin.java b/net/minecraft/world/entity/animal/Dolphin.java -index 7b4b50a714829ed1a48c8ff1fed779432e079489..f6aa8c23afdccb093bcfb0643683614dad49caac 100644 +index 8be0dd148d88dfdfb9efab91124c829e60b5dea5..35bce598bb5857356823594d2a001006ce19f835 100644 --- a/net/minecraft/world/entity/animal/Dolphin.java +++ b/net/minecraft/world/entity/animal/Dolphin.java -@@ -71,14 +71,82 @@ public class Dolphin extends AgeableWaterCreature { - private static final int TOTAL_MOISTNESS_LEVEL = 2400; +@@ -72,14 +72,82 @@ public class Dolphin extends AgeableWaterCreature { public static final Predicate ALLOWED_ITEMS = itemEntity -> !itemEntity.hasPickUpDelay() && itemEntity.isAlive() && itemEntity.isInWater(); public static final float BABY_SCALE = 0.65F; + private boolean isNaturallyAggressiveToPlayers; // Purpur - Dolphins naturally aggressive to players chance + private int spitCooldown; // Purpur - Ridables public Dolphin(EntityType entityType, Level level) { @@ -928,23 +928,23 @@ index 7b4b50a714829ed1a48c8ff1fed779432e079489..f6aa8c23afdccb093bcfb0643683614d @Nullable @Override public SpawnGroupData finalizeSpawn( -@@ -169,6 +237,7 @@ public class Dolphin extends AgeableWaterCreature { - protected void registerGoals() { +@@ -172,6 +240,7 @@ public class Dolphin extends AgeableWaterCreature { this.goalSelector.addGoal(0, new BreathAirGoal(this)); this.goalSelector.addGoal(0, new TryFindWaterGoal(this)); + this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2000000476837158D, true)); // Purpur - Dolphins naturally aggressive to players chance + this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables this.goalSelector.addGoal(1, new Dolphin.DolphinSwimToTreasureGoal(this)); this.goalSelector.addGoal(2, new Dolphin.DolphinSwimWithPlayerGoal(this, 4.0)); this.goalSelector.addGoal(4, new RandomSwimmingGoal(this, 1.0, 10)); -@@ -179,6 +248,7 @@ public class Dolphin extends AgeableWaterCreature { +@@ -182,6 +251,7 @@ public class Dolphin extends AgeableWaterCreature { this.goalSelector.addGoal(8, new Dolphin.PlayWithItemsGoal()); this.goalSelector.addGoal(8, new FollowBoatGoal(this)); this.goalSelector.addGoal(9, new AvoidEntityGoal<>(this, Guardian.class, 8.0F, 1.0, 1.0)); + this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Guardian.class).setAlertOthers()); + this.targetSelector.addGoal(2, new net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (ignored, ignored2) -> isNaturallyAggressiveToPlayers)); // Purpur - Dolphins naturally aggressive to players chance } - -@@ -223,7 +293,7 @@ public class Dolphin extends AgeableWaterCreature { +@@ -227,7 +297,7 @@ public class Dolphin extends AgeableWaterCreature { @Override protected boolean canRide(Entity entity) { @@ -953,7 +953,7 @@ index 7b4b50a714829ed1a48c8ff1fed779432e079489..f6aa8c23afdccb093bcfb0643683614d } @Override -@@ -252,6 +322,11 @@ public class Dolphin extends AgeableWaterCreature { +@@ -256,6 +326,11 @@ public class Dolphin extends AgeableWaterCreature { @Override public void tick() { super.tick(); diff --git a/purpur-server/minecraft-patches/features/0002-Configurable-entity-base-attributes.patch b/purpur-server/minecraft-patches/features/0002-Configurable-entity-base-attributes.patch index b28a87416..a8fc86e19 100644 --- a/purpur-server/minecraft-patches/features/0002-Configurable-entity-base-attributes.patch +++ b/purpur-server/minecraft-patches/features/0002-Configurable-entity-base-attributes.patch @@ -164,10 +164,10 @@ index 656babc0c8810a85eb9f78ced1f3ad9551fdc286..d2a4bfa5334f7361067e4adac36ba5a4 protected void registerGoals() { this.goalSelector.addGoal(0, new FloatGoal(this)); diff --git a/net/minecraft/world/entity/animal/Dolphin.java b/net/minecraft/world/entity/animal/Dolphin.java -index f6aa8c23afdccb093bcfb0643683614dad49caac..2dc6af7adcf3b62f02725bbeca47fe163f360d04 100644 +index 35bce598bb5857356823594d2a001006ce19f835..5b764c686e8759a7b04a7b50708c69629be02c04 100644 --- a/net/minecraft/world/entity/animal/Dolphin.java +++ b/net/minecraft/world/entity/animal/Dolphin.java -@@ -147,6 +147,14 @@ public class Dolphin extends AgeableWaterCreature { +@@ -148,6 +148,14 @@ public class Dolphin extends AgeableWaterCreature { } // Purpur end - Ridables diff --git a/purpur-server/minecraft-patches/features/0018-Toggle-for-water-sensitive-mob-damage.patch b/purpur-server/minecraft-patches/features/0018-Toggle-for-water-sensitive-mob-damage.patch index d70bd6d25..4a0658fb2 100644 --- a/purpur-server/minecraft-patches/features/0018-Toggle-for-water-sensitive-mob-damage.patch +++ b/purpur-server/minecraft-patches/features/0018-Toggle-for-water-sensitive-mob-damage.patch @@ -138,10 +138,10 @@ index e4965300eb41512d03a0b111422c98627cf29a54..a8c76fcbbaa4afd2d0bd568874995b91 protected void registerGoals() { this.goalSelector.addGoal(0, new FloatGoal(this)); diff --git a/net/minecraft/world/entity/animal/Dolphin.java b/net/minecraft/world/entity/animal/Dolphin.java -index 2dc6af7adcf3b62f02725bbeca47fe163f360d04..febe96708feb874d8a9d19b9509731e83476649b 100644 +index 5b764c686e8759a7b04a7b50708c69629be02c04..e104058b3c01bea4cc8a77de2ad4378465903b34 100644 --- a/net/minecraft/world/entity/animal/Dolphin.java +++ b/net/minecraft/world/entity/animal/Dolphin.java -@@ -155,6 +155,13 @@ public class Dolphin extends AgeableWaterCreature { +@@ -156,6 +156,13 @@ public class Dolphin extends AgeableWaterCreature { } // Purpur end - Configurable entity base attributes diff --git a/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch b/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch index bfee808b2..7a3ebe2c4 100644 --- a/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch +++ b/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch @@ -1,5 +1,42 @@ --- a/net/minecraft/world/entity/animal/Dolphin.java +++ b/net/minecraft/world/entity/animal/Dolphin.java +@@ -71,6 +_,7 @@ + private static final int TOTAL_MOISTNESS_LEVEL = 2400; + public static final Predicate ALLOWED_ITEMS = itemEntity -> !itemEntity.hasPickUpDelay() && itemEntity.isAlive() && itemEntity.isInWater(); + public static final float BABY_SCALE = 0.65F; ++ private boolean isNaturallyAggressiveToPlayers; // Purpur - Dolphins naturally aggressive to players chance + + public Dolphin(EntityType entityType, Level level) { + super(entityType, level); +@@ -87,6 +_,7 @@ + this.setAirSupply(this.getMaxAirSupply()); + this.setXRot(0.0F); + SpawnGroupData spawnGroupData1 = Objects.requireNonNullElseGet(spawnGroupData, () -> new AgeableMob.AgeableMobGroupData(0.1F)); ++ this.isNaturallyAggressiveToPlayers = level.getLevel().purpurConfig.dolphinNaturallyAggressiveToPlayersChance > 0.0D && random.nextDouble() <= level.getLevel().purpurConfig.dolphinNaturallyAggressiveToPlayersChance; // Purpur - Dolphins naturally aggressive to players chance + return super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData1); + } + +@@ -169,17 +_,19 @@ + protected void registerGoals() { + this.goalSelector.addGoal(0, new BreathAirGoal(this)); + this.goalSelector.addGoal(0, new TryFindWaterGoal(this)); ++ this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2000000476837158D, true)); // Purpur - Dolphins naturally aggressive to players chance + this.goalSelector.addGoal(1, new Dolphin.DolphinSwimToTreasureGoal(this)); + this.goalSelector.addGoal(2, new Dolphin.DolphinSwimWithPlayerGoal(this, 4.0)); + this.goalSelector.addGoal(4, new RandomSwimmingGoal(this, 1.0, 10)); + this.goalSelector.addGoal(4, new RandomLookAroundGoal(this)); + this.goalSelector.addGoal(5, new LookAtPlayerGoal(this, Player.class, 6.0F)); + this.goalSelector.addGoal(5, new DolphinJumpGoal(this, 10)); +- this.goalSelector.addGoal(6, new MeleeAttackGoal(this, 1.2F, true)); ++ //this.goalSelector.addGoal(6, new MeleeAttackGoal(this, 1.2F, true)); // Purpur - moved up - Dolphins naturally aggressive to players chance + this.goalSelector.addGoal(8, new Dolphin.PlayWithItemsGoal()); + this.goalSelector.addGoal(8, new FollowBoatGoal(this)); + this.goalSelector.addGoal(9, new AvoidEntityGoal<>(this, Guardian.class, 8.0F, 1.0, 1.0)); + this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Guardian.class).setAlertOthers()); ++ this.targetSelector.addGoal(2, new net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (ignored, ignored2) -> isNaturallyAggressiveToPlayers)); // Purpur - Dolphins naturally aggressive to players chance + } + + public static AttributeSupplier.Builder createAttributes() { @@ -412,6 +_,7 @@ @Override 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 b7d1cad01..311d65cdd 100644 --- a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -1366,6 +1366,7 @@ public class PurpurWorldConfig { public double dolphinScale = 1.0D; public boolean dolphinDisableTreasureSearching = false; public boolean dolphinTakeDamageFromWater = false; + public double dolphinNaturallyAggressiveToPlayersChance = 0.0D; private void dolphinSettings() { dolphinRidable = getBoolean("mobs.dolphin.ridable", dolphinRidable); dolphinControllable = getBoolean("mobs.dolphin.controllable", dolphinControllable); @@ -1381,6 +1382,7 @@ public class PurpurWorldConfig { dolphinScale = Mth.clamp(getDouble("mobs.dolphin.attributes.scale", dolphinScale), 0.0625D, 16.0D); dolphinDisableTreasureSearching = getBoolean("mobs.dolphin.disable-treasure-searching", dolphinDisableTreasureSearching); dolphinTakeDamageFromWater = getBoolean("mobs.dolphin.takes-damage-from-water", dolphinTakeDamageFromWater); + dolphinNaturallyAggressiveToPlayersChance = getDouble("mobs.dolphin.naturally-aggressive-to-players-chance", dolphinNaturallyAggressiveToPlayersChance); } public boolean donkeyRidableInWater = false;