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

@@ -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<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
+ private int spitCooldown; // Purpur - Ridables
public Dolphin(EntityType<? extends Dolphin> 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();

View File

@@ -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

View File

@@ -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

View File

@@ -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<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 @@
@Override

View File

@@ -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;