From 2288e13816a74d96f3acbbb3c369b9ec87c8df76 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sat, 13 Jul 2024 11:44:52 -0700 Subject: [PATCH] Update last chunk position in findSupportingBlock Fixes fetching chunks needlessly multiple times. Thanks Lulu13022002 for pointing this out --- .../0991-Moonrise-optimisation-patches.patch | 22 ++++++++++--------- ...ldBounds-and-getBlockState-for-inlin.patch | 4 ++-- ...cing-for-EntityLiving-hasLineOfSight.patch | 6 ++--- patches/server/1002-Anti-Xray.patch | 8 +++---- ...nate-Current-redstone-implementation.patch | 4 ++-- .../1026-Improved-Watchdog-Support.patch | 4 ++-- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/patches/server/0991-Moonrise-optimisation-patches.patch b/patches/server/0991-Moonrise-optimisation-patches.patch index a64e3f7d0a..7c41fea24d 100644 --- a/patches/server/0991-Moonrise-optimisation-patches.patch +++ b/patches/server/0991-Moonrise-optimisation-patches.patch @@ -31308,7 +31308,7 @@ index bff83fe413c7baef4ba56a3270ea4463a58c792f..a248d859cbce48f4a34c4771a7acffc1 } diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b80b988f7 100644 +index e27d3547d1e19c137e05e6b8d075127a8bafb237..a12ef61b42779e37d439585e479c7d73a5abf226 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -81,6 +81,7 @@ import net.minecraft.world.level.storage.LevelData; @@ -31328,7 +31328,7 @@ index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); -@@ -199,6 +200,439 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -199,6 +200,441 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public abstract ResourceKey getTypeKey(); @@ -31694,6 +31694,8 @@ index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b + final int newChunkZ = currZ >> 4; + + if (((newChunkX ^ lastChunkX) | (newChunkZ ^ lastChunkZ)) != 0) { ++ lastChunkX = newChunkX; ++ lastChunkZ = newChunkZ; + lastChunk = (LevelChunk)chunkSource.getChunk(newChunkX, newChunkZ, ChunkStatus.FULL, false); + } + @@ -31768,7 +31770,7 @@ index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator) { // Paper - create paper world config this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config -@@ -281,6 +715,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -281,6 +717,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); @@ -31780,7 +31782,7 @@ index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b } // Paper start - Cancel hit for vanished players -@@ -549,7 +988,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -549,7 +990,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); } @@ -31789,7 +31791,7 @@ index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i); } -@@ -813,6 +1252,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -813,6 +1254,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Iterator iterator = this.blockEntityTickers.iterator(); boolean flag = this.tickRateManager().runsNormally(); @@ -31798,7 +31800,7 @@ index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b int tilesThisCycle = 0; var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet(); // Paper - Fix MC-117075; use removeAll toRemove.add(null); // Paper - Fix MC-117075 -@@ -828,6 +1269,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -828,6 +1271,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Spigot end } else if (flag && this.shouldTickBlocksAt(tickingblockentity.getPos())) { tickingblockentity.tick(); @@ -31810,7 +31812,7 @@ index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b } } this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 -@@ -850,12 +1296,20 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -850,12 +1298,20 @@ public abstract class Level implements LevelAccessor, AutoCloseable { entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Paper end - Prevent block entity and entity crashes } @@ -31832,7 +31834,7 @@ index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b } // Paper end - Option to prevent armor stands from doing entity lookups -@@ -949,7 +1403,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -949,7 +1405,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } // Paper end - Perf: Optimize capturedTileEntities lookup // CraftBukkit end @@ -31841,7 +31843,7 @@ index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b } public void setBlockEntity(BlockEntity blockEntity) { -@@ -1039,28 +1493,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1039,28 +1495,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public List getEntities(@Nullable Entity except, AABB box, Predicate predicate) { this.getProfiler().incrementCounter("getEntities"); @@ -31875,7 +31877,7 @@ index e27d3547d1e19c137e05e6b8d075127a8bafb237..6559ca1b3025eae1837986d404369a9b } @Override -@@ -1075,36 +1514,77 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1075,36 +1516,77 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.getEntities(filter, box, predicate, result, Integer.MAX_VALUE); } diff --git a/patches/server/0994-Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch b/patches/server/0994-Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch index 48f04e61e0..96d7849725 100644 --- a/patches/server/0994-Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch +++ b/patches/server/0994-Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch @@ -29,10 +29,10 @@ index 02367ef1371dde94ff6c4cd40bd32e800d6ccaaf..7b0fc7135bc107103dcaed6dc0707b18 this.x = x; this.y = y; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 6559ca1b3025eae1837986d404369a9b80b988f7..8fa92ac2a96fdfb8ecca2be0edd4186d07f26cc5 100644 +index a12ef61b42779e37d439585e479c7d73a5abf226..78dc1e76a579d135dd0eee989acc9f7de2fd5996 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -780,7 +780,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -782,7 +782,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // Paper end public boolean isInWorldBounds(BlockPos pos) { diff --git a/patches/server/0996-Strip-raytracing-for-EntityLiving-hasLineOfSight.patch b/patches/server/0996-Strip-raytracing-for-EntityLiving-hasLineOfSight.patch index f54307018e..6c404fd257 100644 --- a/patches/server/0996-Strip-raytracing-for-EntityLiving-hasLineOfSight.patch +++ b/patches/server/0996-Strip-raytracing-for-EntityLiving-hasLineOfSight.patch @@ -26,7 +26,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index bf787241e33bdc5e8ff3e77ab953c792dc7f83cd..1ac7a3fc583c54aa1113bb575c21c1e5ee482816 100644 +index 9adaf1269e3eea6c0b62b5127317be7bfd651330..5deec2f7ab0f550b574b777f5a8eeb029f890dfd 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3774,7 +3774,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -62,10 +62,10 @@ index bb8e962e63c7a2d931f9bd7f7c002aa35cfa5fd3..0fa131a6c98adb498fc8d534e0e39647 default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) { // Paper start - Add predicate for blocks when raytracing diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 8fa92ac2a96fdfb8ecca2be0edd4186d07f26cc5..0eeae82b1357c339dc0ea69a74ebbd6896c0c3b2 100644 +index 78dc1e76a579d135dd0eee989acc9f7de2fd5996..559855092c375db066cad35018958718014633ff 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -772,10 +772,87 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -774,10 +774,87 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return null; } diff --git a/patches/server/1002-Anti-Xray.patch b/patches/server/1002-Anti-Xray.patch index c64656ab06..3595851e29 100644 --- a/patches/server/1002-Anti-Xray.patch +++ b/patches/server/1002-Anti-Xray.patch @@ -1168,7 +1168,7 @@ index 9b1a6d8351fb473eec75a2fd08fb892b770e3586..0d0b07c9199be9ca0d5ac3feb1d44f14 } // Paper end - Send empty chunk diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 6048b243205a7f856fe5169303a4482723e208f9..f4e84f2be9a8f4852b5c26fc5ac063fa6375a341 100644 +index 01a50831285fa99782c18c66e6d49c78026e04e0..f4cffb4e0856126ea3dded5ab6a663d6bfcb4e26 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -172,6 +172,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -1179,7 +1179,7 @@ index 6048b243205a7f856fe5169303a4482723e208f9..f4e84f2be9a8f4852b5c26fc5ac063fa public final co.aikar.timings.WorldTimingsHandler timings; // Paper public static BlockPos lastPhysicsProblem; // Spigot private org.spigotmc.TickLimiter entityLimiter; -@@ -639,7 +640,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -641,7 +642,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } // Paper end - optimise collisions @@ -1188,7 +1188,7 @@ index 6048b243205a7f856fe5169303a4482723e208f9..f4e84f2be9a8f4852b5c26fc5ac063fa this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.generator = gen; -@@ -726,6 +727,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -728,6 +729,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl this.minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(this); this.maxSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxSection(this); // Paper end - optimise collisions @@ -1196,7 +1196,7 @@ index 6048b243205a7f856fe5169303a4482723e208f9..f4e84f2be9a8f4852b5c26fc5ac063fa } // Paper start - Cancel hit for vanished players -@@ -1003,6 +1005,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1005,6 +1007,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // CraftBukkit end BlockState iblockdata1 = chunk.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag diff --git a/patches/server/1004-Add-Alternate-Current-redstone-implementation.patch b/patches/server/1004-Add-Alternate-Current-redstone-implementation.patch index cbf27f48a7..27f02baedd 100644 --- a/patches/server/1004-Add-Alternate-Current-redstone-implementation.patch +++ b/patches/server/1004-Add-Alternate-Current-redstone-implementation.patch @@ -2035,10 +2035,10 @@ index 8a3f58e6dfdb0af767be334087748f93c06ec797..7ba34da235ea536b929e1c8bc2cc39e4 EntityCallbacks() {} diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index f4e84f2be9a8f4852b5c26fc5ac063fa6375a341..3ad4c2d22c191bfc0e25a31661daebc1161e5656 100644 +index f4cffb4e0856126ea3dded5ab6a663d6bfcb4e26..f59c544b72a8d5c00f83ed51c54d2bba0e8a05de 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1969,4 +1969,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1971,4 +1971,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } } // Paper end - notify observers even if grow failed diff --git a/patches/server/1026-Improved-Watchdog-Support.patch b/patches/server/1026-Improved-Watchdog-Support.patch index f7fdd3fd7b..7c89ec1556 100644 --- a/patches/server/1026-Improved-Watchdog-Support.patch +++ b/patches/server/1026-Improved-Watchdog-Support.patch @@ -287,10 +287,10 @@ index 2510589400b3012b827efcab477c6483d9d55901..43487a9ee202c5b0e5a416519939111f } } diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 3ad4c2d22c191bfc0e25a31661daebc1161e5656..c1f392cd7928a142192c87cf46ef2a4fc2495562 100644 +index f59c544b72a8d5c00f83ed51c54d2bba0e8a05de..b16c3beda0fc7d7d06cfc82f450165096a88bade 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1375,6 +1375,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1377,6 +1377,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl try { tickConsumer.accept(entity); } catch (Throwable throwable) {