9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0100-Fix-Pufferfish-and-Purpur-patches.patch
2025-06-11 05:20:38 +08:00

326 lines
24 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Mon, 29 Apr 2024 14:18:58 -0400
Subject: [PATCH] Fix Pufferfish and Purpur patches
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 271233087ad8a0ef8e90e1d518907e166f8235a2..ecf1e794c78962440da02aadfbe78d9782df2cf0 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -276,7 +276,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public static final int TICK_TIME = 1000000000 / MinecraftServer.TPS;
private static final int SAMPLE_INTERVAL = 20; // Paper - improve server tick loop
@Deprecated(forRemoval = true) // Paper
- public final double[] recentTps = new double[3];
+ public final double[] recentTps = new double[4]; // Leaf - Purpur - Add 5 second tps average in /tps
// Spigot end
public volatile boolean hasFullyShutdown; // Paper - Improved watchdog support
public volatile boolean abnormalExit; // Paper - Improved watchdog support
@@ -286,7 +286,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
- public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("MobSpawning"); // Pufferfish - optimize mob spawning
+ public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("Leaf Async Mob Spawn Thread"); // Pufferfish - optimize mob spawning // Leaf - Fix Pufferfish and Purpur patches - Unify thread name
public boolean lagging = false; // Purpur - Lagging threshold
protected boolean upnp = false; // Purpur - UPnP Port Forwarding
@@ -1239,9 +1239,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
tps15.add(currentTps, diff);
// Backwards compat with bad plugins
- this.recentTps[0] = tps1.getAverage();
- this.recentTps[1] = tps5.getAverage();
- this.recentTps[2] = tps15.getAverage();
+ // Leaf start - Purpur - Add 5 second tps average in /tps
+ this.recentTps[0] = tps5s.getAverage();
+ this.recentTps[1] = tps1.getAverage();
+ this.recentTps[2] = tps5.getAverage();
+ this.recentTps[3] = tps15.getAverage();
+ // Leaf end - Purpur - Add 5 second tps average in /tps
lagging = recentTps[0] < org.purpurmc.purpur.PurpurConfig.laggingThreshold; // Purpur - Lagging threshold
tickSection = currentTime;
}
@@ -1269,7 +1272,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.mayHaveDelayedTasks = true;
this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + l, this.nextTickTimeNanos);
// Purpur start - Configurable TPS Catchup
- if (!org.purpurmc.purpur.PurpurConfig.tpsCatchup /*|| !gg.pufferfish.pufferfish.PufferfishConfig.tpsCatchup*/) { // Purpur - Configurable TPS Catchup
+ if (!org.purpurmc.purpur.PurpurConfig.tpsCatchup) { // Purpur - Configurable TPS Catchup // Leaf - Fix Pufferfish and Purpur patches
this.nextTickTimeNanos = currentTime + l;
this.delayedTasksMaxNextTickTimeNanos = nextTickTimeNanos;
}
diff --git a/net/minecraft/server/gui/StatsComponent.java b/net/minecraft/server/gui/StatsComponent.java
index 35fd539eb2bfe60ad17ab1e558a01273666acc54..445bbdc8da7f1fdbddfc4d8787d78fea9328fb65 100644
--- a/net/minecraft/server/gui/StatsComponent.java
+++ b/net/minecraft/server/gui/StatsComponent.java
@@ -43,7 +43,7 @@ public class StatsComponent extends JComponent {
}
this.msgs[0] = "Memory use: " + l / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)";
this.msgs[1] = "Avg tick: " + DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / TimeUtil.NANOSECONDS_PER_MILLISECOND) + " ms";
- this.msgs[2] = "TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg);
+ this.msgs[2] = "TPS from last 5s, 1m, 5m, 15m: " + String.join(", ", tpsAvg); // Leaf - Purpur - Add 5 second tps average in /tps
// Paper end - Improve ServerGUI
this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory());
this.repaint();
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 35ca166964e8436154891708f69ac010491b64aa..586c00610fdba178f27391820d623c3a5254529f 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1289,7 +1289,7 @@ public class ServerGamePacketListenerImpl
}
if (byteTotal > byteAllowed) {
- ServerGamePacketListenerImpl.LOGGER.warn("{} tried to send too large of a book. Book size: {} - Allowed: {} - Pages: {}", this.player.getScoreboardName(), byteTotal, byteAllowed, pageList.size());
+ ServerGamePacketListenerImpl.LOGGER.warn("{} tried to send a book too large. Book size: {} - Allowed: {} - Pages: {}", this.player.getScoreboardName(), byteTotal, byteAllowed, pageList.size()); // Leaf - Fix Pufferfish and Purpur patches
org.purpurmc.purpur.event.player.PlayerBookTooLargeEvent event = new org.purpurmc.purpur.event.player.PlayerBookTooLargeEvent(player.getBukkitEntity(), itemstack.asBukkitCopy()); if (event.shouldKickPlayer()) // Purpur - PlayerBookTooLargeEvent
this.disconnectAsync(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause // Paper - add proper async disconnect
return;
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index d8c83a449a1f33031aa671f3bbe366a504172a1e..d4a7cabf25b3ba2b085c68a3a7ed73a072c5e7fa 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -526,23 +526,36 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
// Purpur end - Add canSaveToDisk to Entity
+ // Leaf start - Fix Pufferfish and Purpur patches
+ // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
+ private BlockPos cached_eye_blockpos;
+ private net.minecraft.world.phys.Vec3 cached_position;
+ // Gale end - JettPack - optimize sun burn tick - cache eye blockpos
// Purpur start - copied from Mob - API for any mob to burn daylight
public boolean isSunBurnTick() {
if (this.level().isBrightOutside() && !this.level().isClientSide) {
- float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue();
- BlockPos blockPos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
- boolean flag = this.isInWaterOrRain() || this.isInPowderSnow || this.wasInPowderSnow;
- if (lightLevelDependentMagicValue > 0.5F
- && this.random.nextFloat() * 30.0F < (lightLevelDependentMagicValue - 0.4F) * 2.0F
- && !flag
- && this.level().canSeeSky(blockPos)) {
- return true;
+ // Gale start - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
+ if (this.cached_position != this.position) {
+ this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
+ this.cached_position = this.position;
}
+
+ float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness
+
+ // Check brightness first
+ if (lightLevelDependentMagicValue <= 0.5F) return false;
+ if (this.random.nextFloat() * 30.0F >= (lightLevelDependentMagicValue - 0.4F) * 2.0F) return false;
+ // Gale end - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
+
+ boolean flag = this.isInWaterOrRain() || this.isInPowderSnow || this.wasInPowderSnow;
+
+ return !flag && this.level().canSeeSky(this.cached_eye_blockpos); // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
}
- return false;
+ return false; // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos - diff on change
}
// Purpur end - copied from Mob - API for any mob to burn daylight
+ // Leaf end - Fix Pufferfish and Purpur patches
public Entity(EntityType<?> entityType, Level level) {
this.type = entityType;
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index cd8c764f9aa2321c6e157abe958d89868a9f7bd1..ed15b5f29658d799a36dcbd196a8fcb107be4bda 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -1024,13 +1024,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
// Gale start - Petal - reduce skull ItemStack lookups for reduced visibility
EntityType<?> type = lookingEntity.getType();
// Purpur start - Mob head visibility percent
- if (type == EntityType.SKELETON && itemBySlot.is(Items.SKELETON_SKULL)) {
+ if (type == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL)) { // Leaf - Fix Pufferfish and Purpur patches
d *= lookingEntity.level().purpurConfig.skeletonHeadVisibilityPercent;
- } else if (type == EntityType.ZOMBIE && itemBySlot.is(Items.ZOMBIE_HEAD)) {
+ } else if (type == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD)) { // Leaf - Fix Pufferfish and Purpur patches
d *= lookingEntity.level().purpurConfig.zombieHeadVisibilityPercent;
- } else if ((type == EntityType.PIGLIN || type == EntityType.PIGLIN_BRUTE) && itemBySlot.is(Items.PIGLIN_HEAD)) {
+ } else if ((type == EntityType.PIGLIN || type == EntityType.PIGLIN_BRUTE) && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD)) { // Leaf - Fix Pufferfish and Purpur patches
d *= lookingEntity.level().purpurConfig.piglinHeadVisibilityPercent;
- } else if (type == EntityType.CREEPER && itemBySlot.is(Items.CREEPER_HEAD)) {
+ } else if (type == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) { // Leaf - Fix Pufferfish and Purpur patches
d *= lookingEntity.level().purpurConfig.creeperHeadVisibilityPercent;
}
// Purpur end - Mob head visibility percent
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
index 6a94f42c8e048985b94db64fa0405e12824a8a0f..fbcf26c0bfb9f496c99bd5a2ba988be06162cd52 100644
--- a/net/minecraft/world/entity/Mob.java
+++ b/net/minecraft/world/entity/Mob.java
@@ -1505,10 +1505,6 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
protected void playAttackSound() {
}
- // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
- private BlockPos cached_eye_blockpos;
- private net.minecraft.world.phys.Vec3 cached_position;
- // Gale end - JettPack - optimize sun burn tick - cache eye blockpos
public boolean isSunBurnTick() {
// Purpur - implemented in Entity - API for any mob to burn daylight
return super.isSunBurnTick();
diff --git a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
index 60ec389615cfcad388ed37b8d3ee04e87db36755..34fe1d3bd6603225f84ab18794bbb1189d4b4f49 100644
--- a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
+++ b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
@@ -22,20 +22,17 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
@Override
protected void doTick(ServerLevel level, Villager entity) {
- // Gale start - Lithium - skip secondary POI sensor if absent
+ // Leaf start - Fix Pufferfish and Purpur patches
+ // Purpur: Option for Villager Clerics to farm Nether Wart - make sure clerics don't wander to soul sand when the option is off
+ // Gale: Lithium - skip secondary POI sensor if absent
var secondaryPoi = entity.getVillagerData().profession().value().secondaryPoi();
- if (secondaryPoi.isEmpty()) {
- entity.getBrain().eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
- return;
- }
- // Gale end - Lithium - skip secondary POI sensor if absent
- // Purpur start - Option for Villager Clerics to farm Nether Wart - make sure clerics don't wander to soul sand when the option is off
Brain<?> brain = entity.getBrain();
- if (!level.purpurConfig.villagerClericsFarmWarts && entity.getVillagerData().profession().is(net.minecraft.world.entity.npc.VillagerProfession.CLERIC)) {
+ if (secondaryPoi.isEmpty() || !level.purpurConfig.villagerClericsFarmWarts && entity.getVillagerData().profession().is(net.minecraft.world.entity.npc.VillagerProfession.CLERIC)) {
brain.eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
return;
}
// Purpur end - Option for Villager Clerics to farm Nether Wart
+ // Leaf end - Fix Pufferfish and Purpur patches
ResourceKey<Level> resourceKey = level.dimension();
BlockPos blockPos = entity.blockPosition();
List<GlobalPos> list = Lists.newArrayList();
diff --git a/net/minecraft/world/entity/animal/allay/Allay.java b/net/minecraft/world/entity/animal/allay/Allay.java
index 441287e74243a413c97a98b7898bab7833ac6458..18107d9be4d9ba816852ee4595a5349867834bef 100644
--- a/net/minecraft/world/entity/animal/allay/Allay.java
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
@@ -283,8 +283,7 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
private int behaviorTick = 0; // Pufferfish
@Override
protected void customServerAiStep(ServerLevel level) {
- //if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
- if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider // Leaf - Fix Pufferfish and Purpur patches
this.getBrain().tick(level, this);
AllayAi.updateActivity(this);
super.customServerAiStep(level);
diff --git a/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
index de207d747026453fabe2e6e725d2aa8504fbc9a1..524a7c31708a03f7a9dae75731caa8a450a6488d 100644
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
@@ -372,8 +372,7 @@ public class Axolotl extends Animal implements Bucketable {
private int behaviorTick = 0; // Pufferfish
@Override
protected void customServerAiStep(ServerLevel level) {
- //if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
- if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider // Leaf - Fix Pufferfish and Purpur patches
this.getBrain().tick(level, this);
AxolotlAi.updateActivity(this);
if (!this.isNoAi()) {
diff --git a/net/minecraft/world/entity/animal/frog/Frog.java b/net/minecraft/world/entity/animal/frog/Frog.java
index 89fa6a785ff73b30effd58dde4fbcbf99fdad168..71bae5f5ed284fed30262872771f85de97383d6d 100644
--- a/net/minecraft/world/entity/animal/frog/Frog.java
+++ b/net/minecraft/world/entity/animal/frog/Frog.java
@@ -259,8 +259,7 @@ public class Frog extends Animal {
private int behaviorTick = 0; // Pufferfish
@Override
protected void customServerAiStep(ServerLevel level) {
- //if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
- if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider // Leaf - Fix Pufferfish and Purpur patches
this.getBrain().tick(level, this);
FrogAi.updateActivity(this);
super.customServerAiStep(level);
diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java
index a445bbe84d919ffadd8f3f0006b12140cd8060fd..7a3bfa91ffc5c7c6b04eef7b1b1d3c04c5a6d856 100644
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
@@ -134,8 +134,7 @@ public class Tadpole extends AbstractFish {
private int behaviorTick = 0; // Pufferfish
@Override
protected void customServerAiStep(ServerLevel level) {
- //if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
- if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider // Leaf - Fix Pufferfish and Purpur patches
this.getBrain().tick(level, this);
TadpoleAi.updateActivity(this);
super.customServerAiStep(level);
diff --git a/net/minecraft/world/entity/animal/goat/Goat.java b/net/minecraft/world/entity/animal/goat/Goat.java
index 40ba2e6dc6b1efbd17dba582561c133f6b41df25..39d4da47dcd7bbb33ad907b428dc0f65eaa23a82 100644
--- a/net/minecraft/world/entity/animal/goat/Goat.java
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
@@ -226,8 +226,7 @@ public class Goat extends Animal {
private int behaviorTick = 0; // Pufferfish
@Override
protected void customServerAiStep(ServerLevel level) {
- //if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
- if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider // Leaf - Fix Pufferfish and Purpur patches
this.getBrain().tick(level, this);
GoatAi.updateActivity(this);
super.customServerAiStep(level);
diff --git a/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
index 584955d151e95727406bc68d6a6f15a33c0f920c..865a83fc73d79893e9bdedad37a6e3986d15fc2b 100644
--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java
+++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
@@ -206,8 +206,7 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
private int behaviorTick; // Pufferfish
@Override
protected void customServerAiStep(ServerLevel level) {
- //if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
- if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider // Leaf - Fix Pufferfish and Purpur patches
this.getBrain().tick(level, this);
HoglinAi.updateActivity(this);
if (this.isConverting()) {
diff --git a/net/minecraft/world/entity/monster/piglin/Piglin.java b/net/minecraft/world/entity/monster/piglin/Piglin.java
index 0afdfdc07764a26316c171c2a6722caf786875f2..732d44372cf226ca9d008ebc26d1838237ec96d6 100644
--- a/net/minecraft/world/entity/monster/piglin/Piglin.java
+++ b/net/minecraft/world/entity/monster/piglin/Piglin.java
@@ -357,8 +357,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
private int behaviorTick; // Pufferfish
@Override
protected void customServerAiStep(ServerLevel level) {
- //if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
- if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider // Leaf - Fix Pufferfish and Purpur patches
this.getBrain().tick(level, this);
PiglinAi.updateActivity(this);
super.customServerAiStep(level);
diff --git a/net/minecraft/world/entity/projectile/Projectile.java b/net/minecraft/world/entity/projectile/Projectile.java
index 9f1c07be83999b7bafdee9238e8bad8c646d42f1..554e679a756dc1bf529053594231a958717f3573 100644
--- a/net/minecraft/world/entity/projectile/Projectile.java
+++ b/net/minecraft/world/entity/projectile/Projectile.java
@@ -85,7 +85,7 @@ public abstract class Projectile extends Entity implements TraceableEntity {
if (maxChunkLoadsPerProjectile >= 0 && this.chunksLoadedByProjectile >= maxChunkLoadsPerProjectile) {
if (maxProjectileChunkLoadsConfig.perProjectile.removeFromWorldAfterReachLimit) {
- this.discard();
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Leaf - Fix Pufferfish and Purpur patches - Purpur
} else if (maxProjectileChunkLoadsConfig.perProjectile.resetMovementAfterReachLimit) {
this.setDeltaMovement(0, this.getDeltaMovement().y, 0);
}
diff --git a/org/purpurmc/purpur/PurpurWorldConfig.java b/org/purpurmc/purpur/PurpurWorldConfig.java
index 31cc4e6e68a9743aaaeb296cb31e64526d3f1f73..cadfbb7310fce33eda24d69c39fda5689c7fb882 100644
--- a/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -2435,6 +2435,13 @@ public class PurpurWorldConfig {
piglinMobGriefingOverride = getBooleanOrDefault("mobs.piglin.mob-griefing-override", piglinMobGriefingOverride);
piglinTakeDamageFromWater = getBoolean("mobs.piglin.takes-damage-from-water", piglinTakeDamageFromWater);
piglinPortalSpawnModifier = getInt("mobs.piglin.portal-spawn-modifier", piglinPortalSpawnModifier);
+ // Leaf start - Fix Pufferfish and Purpur patches - better input sanitization
+ if (piglinPortalSpawnModifier < 1) {
+ piglinPortalSpawnModifier = 1;
+ log(Level.WARNING, "mobs.piglin.portal-spawn-modifier is set to below minimum allowed value of 1");
+ log(Level.WARNING, "Using value of 1 to prevent issues");
+ }
+ // Leaf end - Fix Pufferfish and Purpur patches - better input sanitization
piglinAlwaysDropExp = getBoolean("mobs.piglin.always-drop-exp", piglinAlwaysDropExp);
piglinHeadVisibilityPercent = getDouble("mobs.piglin.head-visibility-percent", piglinHeadVisibilityPercent);
piglinIgnoresArmorWithGoldTrim = getBoolean("mobs.piglin.ignores-armor-with-gold-trim", piglinIgnoresArmorWithGoldTrim);