Skip to content

Commit

Permalink
Synced fixes from branch 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHua269 committed Jul 29, 2024
1 parent bbd1c34 commit 592877e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0058-KioCG-Chunk-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 592877e

Please sign in to comment.