diff --git a/patches/server/0255-Dolphins-naturally-aggressive-to-players-chance.patch b/patches/server/0255-Dolphins-naturally-aggressive-to-players-chance.patch new file mode 100644 index 000000000..9f89182eb --- /dev/null +++ b/patches/server/0255-Dolphins-naturally-aggressive-to-players-chance.patch @@ -0,0 +1,68 @@ +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/src/main/java/net/minecraft/world/entity/animal/Dolphin.java b/src/main/java/net/minecraft/world/entity/animal/Dolphin.java +index 2aead13e8f879b614445715fb1912a20b9abf4b9..a33724bee284c3f05b1807d6564ddf1564278167 100644 +--- a/src/main/java/net/minecraft/world/entity/animal/Dolphin.java ++++ b/src/main/java/net/minecraft/world/entity/animal/Dolphin.java +@@ -85,6 +85,7 @@ public class Dolphin extends WaterAnimal { + return !entityitem.hasPickUpDelay() && entityitem.isAlive() && entityitem.isInWater(); + }; + private int spitCooldown; // Purpur ++ private boolean isNaturallyAggressiveToPlayers; // Purpur + + public Dolphin(EntityType type, Level world) { + super(type, world); +@@ -170,6 +171,7 @@ public class Dolphin extends WaterAnimal { + public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, @Nullable SpawnGroupData entityData, @Nullable CompoundTag entityNbt) { + this.setAirSupply(this.getMaxAirSupply()); + this.setXRot(0.0F); ++ this.isNaturallyAggressiveToPlayers = level.purpurConfig.dolphinNaturallyAggressiveToPlayersChance > 0.0D && random.nextDouble() <= level.purpurConfig.dolphinNaturallyAggressiveToPlayersChance; // Purpur + return super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt); + } + +@@ -240,18 +242,20 @@ public class Dolphin extends WaterAnimal { + this.goalSelector.addGoal(0, new BreathAirGoal(this)); + this.goalSelector.addGoal(0, new TryFindWaterGoal(this)); + this.goalSelector.addGoal(0, new net.pl3x.purpur.entity.ai.HasRider(this)); // Purpur ++ this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2000000476837158D, true)); // Purpur + 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 + 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 net.pl3x.purpur.entity.ai.HasRider(this)); // Purpur + this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[]{Guardian.class})).setAlertOthers(new Class[0])); // CraftBukkit - decompile error ++ this.targetSelector.addGoal(2, new net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, target -> isNaturallyAggressiveToPlayers)); // Purpur + } + + public static AttributeSupplier.Builder createAttributes() { +diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +index 258bd55eb334d1e841e7ecbf77da985f5b7278c4..da9d2abf91b16c3b98ad8b1ab65b39b5e693e8e0 100644 +--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java ++++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +@@ -1186,6 +1186,7 @@ public class PurpurWorldConfig { + public float dolphinSpitDamage = 2.0F; + public double dolphinMaxHealth = 10.0D; + public boolean dolphinDisableTreasureSearching = false; ++ public double dolphinNaturallyAggressiveToPlayersChance = 0.0D; + private void dolphinSettings() { + dolphinRidable = getBoolean("mobs.dolphin.ridable", dolphinRidable); + dolphinSpitCooldown = getInt("mobs.dolphin.spit.cooldown", dolphinSpitCooldown); +@@ -1198,6 +1199,7 @@ public class PurpurWorldConfig { + } + dolphinMaxHealth = getDouble("mobs.dolphin.attributes.max_health", dolphinMaxHealth); + dolphinDisableTreasureSearching = getBoolean("mobs.dolphin.disable-treasure-searching", dolphinDisableTreasureSearching); ++ dolphinNaturallyAggressiveToPlayersChance = getDouble("mobs.dolphin.naturally-aggressive-to-players-chance", dolphinNaturallyAggressiveToPlayersChance); + } + + public boolean donkeyRidableInWater = false;