Dolphins naturally aggressive to players chance

This commit is contained in:
William Blake Galbreath
2025-01-12 12:45:47 -08:00
committed by granny
parent eab7420f71
commit e256ff6ac7
6 changed files with 55 additions and 84 deletions

View File

@@ -1,68 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
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<? extends Dolphin> 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;

View File

@@ -30,7 +30,7 @@ index c7a7a65273801ee1c11aa9f72ee2327beac21ec0..69bd4d3401cf8432494be78ce5d8c009
/* Drop global time updates /* Drop global time updates
if (this.tickCount % 20 == 0) { if (this.tickCount % 20 == 0) {
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java 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 --- a/net/minecraft/server/level/ServerLevel.java
+++ b/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 @@ -217,6 +217,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -62,10 +62,10 @@ index 31739c5c9dfdd940263cc9b931068b3f624329ec..a8287654d3023f0a5fb183d4ad2dd418
private void updatePlayerAttributes() { private void updatePlayerAttributes() {
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java 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 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/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); ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event);
@@ -841,13 +841,13 @@ index 8c1f74c6be53cbf48bd6b5641511359578801c08..656babc0c8810a85eb9f78ced1f3ad95
// CraftBukkit end // CraftBukkit end
player.playSound(SoundEvents.COW_MILK, 1.0F, 1.0F); 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 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 --- a/net/minecraft/world/entity/animal/Dolphin.java
+++ b/net/minecraft/world/entity/animal/Dolphin.java +++ b/net/minecraft/world/entity/animal/Dolphin.java
@@ -71,14 +71,82 @@ public class Dolphin extends AgeableWaterCreature { @@ -72,14 +72,82 @@ public class Dolphin extends AgeableWaterCreature {
private static final int TOTAL_MOISTNESS_LEVEL = 2400;
public static final Predicate<ItemEntity> ALLOWED_ITEMS = itemEntity -> !itemEntity.hasPickUpDelay() && itemEntity.isAlive() && itemEntity.isInWater(); public static final Predicate<ItemEntity> ALLOWED_ITEMS = itemEntity -> !itemEntity.hasPickUpDelay() && itemEntity.isAlive() && itemEntity.isInWater();
public static final float BABY_SCALE = 0.65F; public static final float BABY_SCALE = 0.65F;
private boolean isNaturallyAggressiveToPlayers; // Purpur - Dolphins naturally aggressive to players chance
+ private int spitCooldown; // Purpur - Ridables + private int spitCooldown; // Purpur - Ridables
public Dolphin(EntityType<? extends Dolphin> entityType, Level level) { public Dolphin(EntityType<? extends Dolphin> entityType, Level level) {
@@ -928,23 +928,23 @@ index 7b4b50a714829ed1a48c8ff1fed779432e079489..f6aa8c23afdccb093bcfb0643683614d
@Nullable @Nullable
@Override @Override
public SpawnGroupData finalizeSpawn( public SpawnGroupData finalizeSpawn(
@@ -169,6 +237,7 @@ public class Dolphin extends AgeableWaterCreature { @@ -172,6 +240,7 @@ public class Dolphin extends AgeableWaterCreature {
protected void registerGoals() {
this.goalSelector.addGoal(0, new BreathAirGoal(this)); this.goalSelector.addGoal(0, new BreathAirGoal(this));
this.goalSelector.addGoal(0, new TryFindWaterGoal(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(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables
this.goalSelector.addGoal(1, new Dolphin.DolphinSwimToTreasureGoal(this)); this.goalSelector.addGoal(1, new Dolphin.DolphinSwimToTreasureGoal(this));
this.goalSelector.addGoal(2, new Dolphin.DolphinSwimWithPlayerGoal(this, 4.0)); 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 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 Dolphin.PlayWithItemsGoal());
this.goalSelector.addGoal(8, new FollowBoatGoal(this)); this.goalSelector.addGoal(8, new FollowBoatGoal(this));
this.goalSelector.addGoal(9, new AvoidEntityGoal<>(this, Guardian.class, 8.0F, 1.0, 1.0)); 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(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables
this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Guardian.class).setAlertOthers()); 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
} }
@@ -227,7 +297,7 @@ public class Dolphin extends AgeableWaterCreature {
@@ -223,7 +293,7 @@ public class Dolphin extends AgeableWaterCreature {
@Override @Override
protected boolean canRide(Entity entity) { protected boolean canRide(Entity entity) {
@@ -953,7 +953,7 @@ index 7b4b50a714829ed1a48c8ff1fed779432e079489..f6aa8c23afdccb093bcfb0643683614d
} }
@Override @Override
@@ -252,6 +322,11 @@ public class Dolphin extends AgeableWaterCreature { @@ -256,6 +326,11 @@ public class Dolphin extends AgeableWaterCreature {
@Override @Override
public void tick() { public void tick() {
super.tick(); super.tick();

View File

@@ -164,10 +164,10 @@ index 656babc0c8810a85eb9f78ced1f3ad9551fdc286..d2a4bfa5334f7361067e4adac36ba5a4
protected void registerGoals() { protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this)); 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 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 --- a/net/minecraft/world/entity/animal/Dolphin.java
+++ b/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 // Purpur end - Ridables

View File

@@ -138,10 +138,10 @@ index e4965300eb41512d03a0b111422c98627cf29a54..a8c76fcbbaa4afd2d0bd568874995b91
protected void registerGoals() { protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this)); 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 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 --- a/net/minecraft/world/entity/animal/Dolphin.java
+++ b/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 // Purpur end - Configurable entity base attributes

View File

@@ -1,5 +1,42 @@
--- a/net/minecraft/world/entity/animal/Dolphin.java --- a/net/minecraft/world/entity/animal/Dolphin.java
+++ b/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<ItemEntity> 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<? extends Dolphin> 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 @@ @@ -412,6 +_,7 @@
@Override @Override

View File

@@ -1366,6 +1366,7 @@ public class PurpurWorldConfig {
public double dolphinScale = 1.0D; public double dolphinScale = 1.0D;
public boolean dolphinDisableTreasureSearching = false; public boolean dolphinDisableTreasureSearching = false;
public boolean dolphinTakeDamageFromWater = false; public boolean dolphinTakeDamageFromWater = false;
public double dolphinNaturallyAggressiveToPlayersChance = 0.0D;
private void dolphinSettings() { private void dolphinSettings() {
dolphinRidable = getBoolean("mobs.dolphin.ridable", dolphinRidable); dolphinRidable = getBoolean("mobs.dolphin.ridable", dolphinRidable);
dolphinControllable = getBoolean("mobs.dolphin.controllable", dolphinControllable); 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); dolphinScale = Mth.clamp(getDouble("mobs.dolphin.attributes.scale", dolphinScale), 0.0625D, 16.0D);
dolphinDisableTreasureSearching = getBoolean("mobs.dolphin.disable-treasure-searching", dolphinDisableTreasureSearching); dolphinDisableTreasureSearching = getBoolean("mobs.dolphin.disable-treasure-searching", dolphinDisableTreasureSearching);
dolphinTakeDamageFromWater = getBoolean("mobs.dolphin.takes-damage-from-water", dolphinTakeDamageFromWater); dolphinTakeDamageFromWater = getBoolean("mobs.dolphin.takes-damage-from-water", dolphinTakeDamageFromWater);
dolphinNaturallyAggressiveToPlayersChance = getDouble("mobs.dolphin.naturally-aggressive-to-players-chance", dolphinNaturallyAggressiveToPlayersChance);
} }
public boolean donkeyRidableInWater = false; public boolean donkeyRidableInWater = false;