mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-06 15:51:31 +00:00
ClassInstanceMultiMap belongs to Minecraft vanilla entity storage. And is unused, since replaced by spottedleaf's entity storage (rewrite chunk system). However these patches might be useful for vanilla entity storage if is used.
326 lines
24 KiB
Diff
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 6ae53701e2b8ed3a8ab89e940c817245a14ea35b..19e65eaf77dd8fa5eaa23e4db9af1adee7280fff 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -277,7 +277,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
|
|
@@ -287,7 +287,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
|
|
|
|
@@ -1242,9 +1242,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;
|
|
}
|
|
@@ -1272,7 +1275,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 cb646939cc6465135030b715d203ba2211981b8e..53200e2f90d76a54254f819a2f419e298975a367 100644
|
|
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1333,7 +1333,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 fb387919e51504beafd2e7947faa41795df18100..0cdd3eb97e74aa3955f014a1f8f6a7d1580d323f 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -543,23 +543,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 dd5343287503e2818e083696a17362091d94e652..b536461c672c608aeeb690f41ea457fc57768e4f 100644
|
|
--- a/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -1049,13 +1049,13 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
// 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 6d8e7d23640707ba0d771174f65e58df75243f77..c5f4b878aa5d736d987982c94fbf557c0f267bbf 100644
|
|
--- a/net/minecraft/world/entity/Mob.java
|
|
+++ b/net/minecraft/world/entity/Mob.java
|
|
@@ -1531,10 +1531,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 7127d8e5fff81be017f0aa04606cb8404ad7b2fd..a25976d6f0dec86b88017cd5f86f3b51c8d7444b 100644
|
|
--- a/net/minecraft/world/entity/animal/allay/Allay.java
|
|
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
|
|
@@ -268,8 +268,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 02db38fa315ecb9d5bdba74848012710106b662e..2cdf2fb60d4d3642f0870944be9bd5abafa9e817 100644
|
|
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
|
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
|
@@ -374,8 +374,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 c4db078db0b7bb2bd8f6757a8bd13d60a7a4fa14..a7e9179c287671a689cb5ce668b5a33896da87a4 100644
|
|
--- a/net/minecraft/world/entity/animal/frog/Frog.java
|
|
+++ b/net/minecraft/world/entity/animal/frog/Frog.java
|
|
@@ -260,8 +260,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 a3858465569c40fcfc7c8c4c4735335ac83cb078..5abdf4253f1d0a6f35d8e05f7a0a2b4100083f76 100644
|
|
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
|
|
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
|
@@ -136,8 +136,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 11b020704a673c69bd2d4ab6313ea32e8e97cc23..c608c71eb601c169f543823c5c342b8928b9cf50 100644
|
|
--- a/net/minecraft/world/entity/animal/goat/Goat.java
|
|
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
|
|
@@ -227,8 +227,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 3c126b1610718a407c16775a935b295ecbaab533..8c9f240badf5a678ee4e1815e010a204f8704f4e 100644
|
|
--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
+++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
@@ -207,8 +207,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 fb58af763cf75c80703360a5c668168775b1458c..e442784741f1d0b4892284b6811343f954b50182 100644
|
|
--- a/net/minecraft/world/entity/monster/piglin/Piglin.java
|
|
+++ b/net/minecraft/world/entity/monster/piglin/Piglin.java
|
|
@@ -358,8 +358,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 ef960ee83adbb5e3ebfa44cd2457b23718045f61..e53c18efb573dea39a3d45f3cdb827d73b901ab6 100644
|
|
--- a/net/minecraft/world/entity/projectile/Projectile.java
|
|
+++ b/net/minecraft/world/entity/projectile/Projectile.java
|
|
@@ -82,7 +82,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 a03e166b490952534e8050654c1afa975795f731..88a2ad8e3b30cb9f447eb4001d33c7799339b6a0 100644
|
|
--- a/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -2453,6 +2453,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);
|