diff --git a/patches/server/0033-Pufferfish-Reduce-projectile-chunk-loading.patch b/patches/server/0033-Pufferfish-Reduce-projectile-chunk-loading.patch index c8a637b..56c62b3 100644 --- a/patches/server/0033-Pufferfish-Reduce-projectile-chunk-loading.patch +++ b/patches/server/0033-Pufferfish-Reduce-projectile-chunk-loading.patch @@ -33,10 +33,10 @@ index 0000000000000000000000000000000000000000..12683ec5a5102e45b6171fea0b833ba5 + } +} diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index 10d7c64fb3a9bafdcdae99f8dc87017722341337..11dfac223d36b0a8cbd865b3a29de15b4268eeb0 100644 +index 10d7c64fb3a9bafdcdae99f8dc87017722341337..d44510a3b70b97b13b87a8e0868fdc699b70b75b 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -45,6 +45,36 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -45,6 +45,38 @@ public abstract class Projectile extends Entity implements TraceableEntity { super(type, world); } @@ -47,23 +47,25 @@ index 10d7c64fb3a9bafdcdae99f8dc87017722341337..11dfac223d36b0a8cbd865b3a29de15b + private int loadedLifetime = 0; + @Override + public void setPos(double x, double y, double z) { -+ long currentTick = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion().getData().getCurrentTick(); -+ if (loadedTick != currentTick) { -+ loadedTick = currentTick; -+ loadedThisTick = 0; -+ } -+ int previousX = Mth.floor(this.getX()) >> 4, previousZ = Mth.floor(this.getZ()) >> 4; -+ int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4; -+ if (previousX != newX || previousZ != newZ) { -+ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfLoadedMainThread(newX, newZ) != null; -+ if (!isLoaded) { -+ if (Projectile.loadedThisTick > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) { -+ if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) { -+ this.discard(); ++ if (io.papermc.paper.util.TickThread.isTickThreadFor(this)){ ++ long currentTick = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion().getData().getCurrentTick(); ++ if (loadedTick != currentTick) { ++ loadedTick = currentTick; ++ loadedThisTick = 0; ++ } ++ int previousX = Mth.floor(this.getX()) >> 4, previousZ = Mth.floor(this.getZ()) >> 4; ++ int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4; ++ if ((previousX != newX || previousZ != newZ) && io.papermc.paper.util.TickThread.isTickThreadFor(((ServerLevel) this.level()), newX, newZ)) { ++ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfLoadedMainThread(newX, newZ) != null; ++ if (!isLoaded) { ++ if (Projectile.loadedThisTick > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) { ++ if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) { ++ this.discard(); ++ } ++ return; + } -+ return; ++ Projectile.loadedThisTick++; + } -+ Projectile.loadedThisTick++; + } + } + super.setPos(x, y, z); diff --git a/patches/server/0058-KioCG-Chunk-API.patch b/patches/server/0058-KioCG-Chunk-API.patch index 5195194..69dd150 100644 --- a/patches/server/0058-KioCG-Chunk-API.patch +++ b/patches/server/0058-KioCG-Chunk-API.patch @@ -334,10 +334,10 @@ index 579eb5a81281ca36c145153d8c24a517242ffe18..a758081a3058bee62721a0b73adbce51 + // KioCG end } diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index 11dfac223d36b0a8cbd865b3a29de15b4268eeb0..2dcfcb226bef8ca0f60ade043dcde1acc8a0811c 100644 +index d44510a3b70b97b13b87a8e0868fdc699b70b75b..2430e5c15be02c75d0e7de3af4118846da122554 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -351,4 +351,11 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -353,4 +353,11 @@ public abstract class Projectile extends Entity implements TraceableEntity { public boolean mayBreak(Level world) { return this.getType().is(EntityTypeTags.IMPACT_PROJECTILES) && world.getGameRules().getBoolean(GameRules.RULE_PROJECTILESCANBREAKBLOCKS); }