3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/Spigot-Server-Patches/0626-Optimized-tick-ready-check.patch
Josh Roy be13705177
Updated Upstream (CraftBukkit) (#5484)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

CraftBukkit Changes:
6b8cd9a7 SPIGOT-6207: forcibly drop the items of a converted zombie villager
2021-04-12 02:03:08 +01:00

52 Zeilen
3.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: lukas <lukasalt98@gmail.com>
Date: Sun, 27 Dec 2020 17:19:51 +0100
Subject: [PATCH] Optimized tick ready check
diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
index f40be366ebc5f98b417b677565fa89d3f817f3fb..78dcba08d6d796d5d97c8304bf1f1e7d1e650d5d 100644
--- a/src/main/java/net/minecraft/world/level/World.java
+++ b/src/main/java/net/minecraft/world/level/World.java
@@ -854,13 +854,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
if (!tileentity.isRemoved() && tileentity.hasWorld()) {
BlockPosition blockposition = tileentity.getPosition();
- if (this.getChunkProvider().a(blockposition) && this.getWorldBorder().a(blockposition)) {
+ Chunk chunk; PlayerChunk playerChunk; if ((chunk = tileentity.getCurrentChunk()) != null && (playerChunk = chunk.playerChunk) != null && playerChunk.isTickingReady() && this.getWorldBorder().isInBounds(blockposition)) { // Paper - optimized tick ready check by inlining ChunkProviderServer.a(BlockPosition). Chunk lookup is no longer required and we can use the PlayerChunk directly available through the tile entity
try {
gameprofilerfiller.a(() -> {
return String.valueOf(TileEntityTypes.a(tileentity.getTileType()));
});
tileentity.tickTimer.startTiming(); // Spigot
- if (tileentity.getTileType().isValidBlock(this.getType(blockposition).getBlock())) {
+ if (tileentity.getTileType().isValidBlock(chunk.getType(blockposition).getBlock())) { // Paper - reuse the chunk from above, do not look it up again
((ITickable) tileentity).tick();
} else {
tileentity.w();
@@ -893,9 +893,11 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
this.tileEntityListTick.remove(tileTickPosition--);
// Spigot end
//this.tileEntityList.remove(tileentity); // Paper - remove unused list
- if (this.isLoaded(tileentity.getPosition())) {
- this.getChunkAtWorldCoords(tileentity.getPosition()).removeTileEntity(tileentity.getPosition());
+ // Paper - prevent double chunk lookups
+ Chunk chunk; if ((chunk = this.getChunkIfLoaded(tileentity.getPosition())) != null) { // inlined contents of this.isLoaded(BlockPosition). Reuse the returned chunk instead of looking it up again
+ chunk.removeTileEntity(tileentity.getPosition());
}
+ // Paper end
}
}
@@ -914,8 +916,8 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
}
// CraftBukkit end */
- if (this.isLoaded(tileentity1.getPosition())) {
- Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
+ Chunk chunk; if ((chunk = this.getChunkIfLoaded(tileentity1.getPosition())) != null) { // Paper - inlined contents of this.isLoaded(BlockPosition). Reuse the returned chunk instead of looking it up again
+ // Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); // Paper - already computed above
IBlockData iblockdata = chunk.getType(tileentity1.getPosition());
chunk.setTileEntity(tileentity1.getPosition(), tileentity1);