3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00

Fix getBlockStateIfLoaded world bounds check

Closes #8922
Dieser Commit ist enthalten in:
Nassim Jahnke 2023-02-28 12:27:38 +01:00
Ursprung 08e6622b81
Commit 4ae202eb82
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
20 geänderte Dateien mit 63 neuen und 62 gelöschten Zeilen

Datei anzeigen

@ -6826,7 +6826,7 @@ index 3c707d6674b2594b09503b959a31c1f4ad3981e6..db61b6b0158a9bcc0e1d735e34fe3671
public BlockState getBlockState(BlockPos pos) { public BlockState getBlockState(BlockPos pos) {
return Blocks.AIR.defaultBlockState(); return Blocks.AIR.defaultBlockState();
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index ca5cbd7c43d7e263f76d8719a259514c0748a430..3bf5b8429a25b0f1347cc287f919dec7a66d9b6c 100644 index ca5cbd7c43d7e263f76d8719a259514c0748a430..a0bd6c4df76fac867e1862273ce31dbe067de624 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -88,6 +88,7 @@ import org.bukkit.craftbukkit.CraftServer; @@ -88,6 +88,7 @@ import org.bukkit.craftbukkit.CraftServer;
@ -6837,7 +6837,7 @@ index ca5cbd7c43d7e263f76d8719a259514c0748a430..3bf5b8429a25b0f1347cc287f919dec7
import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.util.CraftSpawnCategory; import org.bukkit.craftbukkit.util.CraftSpawnCategory;
import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey;
@@ -287,18 +288,51 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -287,18 +288,52 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return y < -20000000 || y >= 20000000; return y < -20000000 || y >= 20000000;
} }
@ -6863,21 +6863,22 @@ index ca5cbd7c43d7e263f76d8719a259514c0748a430..3bf5b8429a25b0f1347cc287f919dec7
+ +
+ @Override + @Override
+ @Nullable + @Nullable
+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) { + public final BlockState getBlockStateIfLoaded(BlockPos pos) {
+ // CraftBukkit start - tree generation + // CraftBukkit start - tree generation
+ if (captureTreeGeneration) { + if (this.captureTreeGeneration) {
+ CraftBlockState previous = capturedBlockStates.get(blockposition); + CraftBlockState previous = this.capturedBlockStates.get(pos);
+ if (previous != null) { + if (previous != null) {
+ return previous.getHandle(); + return previous.getHandle();
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ if (!isInWorldBounds(blockposition)) { + if (this.isOutsideBuildHeight(pos)) {
+ return Blocks.AIR.defaultBlockState(); + return Blocks.VOID_AIR.defaultBlockState();
+ } + } else {
+ ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); + ChunkAccess chunk = this.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4);
+ +
+ return chunk == null ? null : chunk.getBlockState(blockposition); + return chunk == null ? null : chunk.getBlockState(pos);
+ }
+ } + }
+ +
+ @Override + @Override
@ -6893,7 +6894,7 @@ index ca5cbd7c43d7e263f76d8719a259514c0748a430..3bf5b8429a25b0f1347cc287f919dec7
ChunkAccess ichunkaccess = this.getChunkSource().getChunk(chunkX, chunkZ, leastStatus, create); ChunkAccess ichunkaccess = this.getChunkSource().getChunk(chunkX, chunkZ, leastStatus, create);
if (ichunkaccess == null && create) { if (ichunkaccess == null && create) {
@@ -309,7 +343,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -309,7 +344,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
} }
@Override @Override
@ -6902,7 +6903,7 @@ index ca5cbd7c43d7e263f76d8719a259514c0748a430..3bf5b8429a25b0f1347cc287f919dec7
return this.setBlock(pos, state, flags, 512); return this.setBlock(pos, state, flags, 512);
} }
@@ -553,7 +587,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -553,7 +588,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
if (this.isOutsideBuildHeight(pos)) { if (this.isOutsideBuildHeight(pos)) {
return Blocks.VOID_AIR.defaultBlockState(); return Blocks.VOID_AIR.defaultBlockState();
} else { } else {

Datei anzeigen

@ -1309,7 +1309,7 @@ index 032a21ffd22630c0d4d0456ac651b05105449350..fdb7314784a2232a96a9ccdb049bd240
} }
// CraftBukkit end // CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 8c1937ff71b8b4dad85e20b55dcf2a0cc06ce2df..257b13703166bf953c73c83db8982b412ca96565 100644 index dfd2f3ba256edc64e0016e7816ccefff9e7b1b7a..5f8498ac372a34549519264f612e7554addb41d9 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java --- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
@ -1489,7 +1489,7 @@ index f29b109fdef494927f5f894ac962c50c33b1f0b6..c6ce813f7ea6c4dcbd45e9d8c55f56c2
if (!this.level.isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { if (!this.level.isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
this.hurt(DamageSource.DROWN, 1.0F); this.hurt(DamageSource.DROWN, 1.0F);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 3bf5b8429a25b0f1347cc287f919dec7a66d9b6c..0640df782cff1aec27e1915f726c89275edeec69 100644 index a0bd6c4df76fac867e1862273ce31dbe067de624..ddb876d9494fa72ba2cb49dbfb8d5e61410d1d2a 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -86,7 +86,6 @@ import org.bukkit.Bukkit; @@ -86,7 +86,6 @@ import org.bukkit.Bukkit;
@ -1518,7 +1518,7 @@ index 3bf5b8429a25b0f1347cc287f919dec7a66d9b6c..0640df782cff1aec27e1915f726c8927
this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
} }
@@ -714,15 +713,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -715,15 +714,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
timings.tileEntityTick.stopTiming(); // Spigot timings.tileEntityTick.stopTiming(); // Spigot
this.tickingBlockEntities = false; this.tickingBlockEntities = false;

Datei anzeigen

@ -15940,7 +15940,7 @@ index fdb7314784a2232a96a9ccdb049bd240e1cc9b06..8ef64f5192500f87f514c42432c0d5c8
StringReader stringreader = new StringReader(packet.getCommand()); StringReader stringreader = new StringReader(packet.getCommand());
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 257b13703166bf953c73c83db8982b412ca96565..da36a7342c5ef34af9ea4330e6cee2880d8d4dc8 100644 index 5f8498ac372a34549519264f612e7554addb41d9..8a75650f1e1b8a223723ece379beab0eb8f17ce9 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java --- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -251,7 +251,7 @@ public abstract class PlayerList { @@ -251,7 +251,7 @@ public abstract class PlayerList {
@ -16477,10 +16477,10 @@ index 127c4ebedb94631ceac92dbdcd465e904217d715..be6e3e21ad62da01e5e2dd78e300cbc8
<T extends Entity> List<T> getEntities(EntityTypeTest<Entity, T> filter, AABB box, Predicate<? super T> predicate); <T extends Entity> List<T> getEntities(EntityTypeTest<Entity, T> filter, AABB box, Predicate<? super T> predicate);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 0640df782cff1aec27e1915f726c89275edeec69..bcbbb266302cbd1ac3b0b42fac58d09737357dd3 100644 index ddb876d9494fa72ba2cb49dbfb8d5e61410d1d2a..5ed57b1156b1f358fb7d1d876becfc06f47ffe3b 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -453,6 +453,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -454,6 +454,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement
this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i); this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i);
@ -16492,7 +16492,7 @@ index 0640df782cff1aec27e1915f726c89275edeec69..bcbbb266302cbd1ac3b0b42fac58d097
} }
if ((i & 1) != 0) { if ((i & 1) != 0) {
@@ -805,7 +810,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -806,7 +811,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.capturedTileEntities.get(blockposition); return this.capturedTileEntities.get(blockposition);
} }
// CraftBukkit end // CraftBukkit end
@ -16501,7 +16501,7 @@ index 0640df782cff1aec27e1915f726c89275edeec69..bcbbb266302cbd1ac3b0b42fac58d097
} }
public void setBlockEntity(BlockEntity blockEntity) { public void setBlockEntity(BlockEntity blockEntity) {
@@ -896,26 +901,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -897,26 +902,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public List<Entity> getEntities(@Nullable Entity except, AABB box, Predicate<? super Entity> predicate) { public List<Entity> getEntities(@Nullable Entity except, AABB box, Predicate<? super Entity> predicate) {
this.getProfiler().incrementCounter("getEntities"); this.getProfiler().incrementCounter("getEntities");
List<Entity> list = Lists.newArrayList(); List<Entity> list = Lists.newArrayList();
@ -16529,7 +16529,7 @@ index 0640df782cff1aec27e1915f726c89275edeec69..bcbbb266302cbd1ac3b0b42fac58d097
return list; return list;
} }
@@ -933,34 +919,23 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -934,34 +920,23 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public <T extends Entity> void getEntities(EntityTypeTest<Entity, T> filter, AABB box, Predicate<? super T> predicate, List<? super T> result, int limit) { public <T extends Entity> void getEntities(EntityTypeTest<Entity, T> filter, AABB box, Predicate<? super T> predicate, List<? super T> result, int limit) {
this.getProfiler().incrementCounter("getEntities"); this.getProfiler().incrementCounter("getEntities");
@ -16580,7 +16580,7 @@ index 0640df782cff1aec27e1915f726c89275edeec69..bcbbb266302cbd1ac3b0b42fac58d097
} }
@Nullable @Nullable
@@ -1293,4 +1268,45 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -1294,4 +1269,45 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
private ExplosionInteraction() {} private ExplosionInteraction() {}
} }

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Prevent tile entity and entity crashes
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 409f8440773ef09aecf8f2fd70004d0592f4bbe2..461c04a97eaa77264896ce3a5268d22f9385131c 100644 index 4b2aadae3a7595a5aee2bc71216adc34fa0f2cf9..e082e4a8c8fbce341bcf00115d1579b4bed4b2a4 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -728,11 +728,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -729,11 +729,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
try { try {
tickConsumer.accept(entity); tickConsumer.accept(entity);
} catch (Throwable throwable) { } catch (Throwable throwable) {

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Disable spigot tick limiters
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 4aed75843c794a3a8dbf5e66135b6792cc7d3d8b..a36da18ac1ea613f1a77ce2fbb70d5cb05563714 100644 index 746cab58dc67b47bb57889343c625e038dda4851..6457384bded7b65f22547704eba74875a6b84ebb 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -694,9 +694,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -695,9 +695,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Spigot start // Spigot start
// Iterator iterator = this.blockEntityTickers.iterator(); // Iterator iterator = this.blockEntityTickers.iterator();
int tilesThisCycle = 0; int tilesThisCycle = 0;

Datei anzeigen

@ -88,7 +88,7 @@ index c6fb4c33d7ea52b88d8fc0d90748cbab7387c565..fed09b886f4fa0006d160e5f2abb00df
} }
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index a36da18ac1ea613f1a77ce2fbb70d5cb05563714..86fc83f6ea7bbf445edf097b6ab501a09ec18e2b 100644 index 6457384bded7b65f22547704eba74875a6b84ebb..383bf9fe7263bc6153a2e1cbc21657215a3bdb79 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1,5 +1,10 @@ @@ -1,5 +1,10 @@
@ -102,7 +102,7 @@ index a36da18ac1ea613f1a77ce2fbb70d5cb05563714..86fc83f6ea7bbf445edf097b6ab501a0
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import java.io.IOException; import java.io.IOException;
@@ -730,6 +735,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -731,6 +736,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Paper start - Prevent tile entity and entity crashes // Paper start - Prevent tile entity and entity crashes
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level.getWorld().getName(), entity.getX(), entity.getY(), entity.getZ()); final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level.getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
MinecraftServer.LOGGER.error(msg, throwable); MinecraftServer.LOGGER.error(msg, throwable);

Datei anzeigen

@ -19,10 +19,10 @@ index 9c9c8178cd11e37aaef400e40092fb1095fa6c5f..d4b101d0f1835b57f34f68653d728df2
} }
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 86fc83f6ea7bbf445edf097b6ab501a09ec18e2b..aeb37e84f5760a7435530123b53276920fb19749 100644 index 383bf9fe7263bc6153a2e1cbc21657215a3bdb79..47d24d64d16f00e481d4773487163bc1e46ae4a8 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -336,6 +336,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -337,6 +337,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return chunk == null ? null : chunk.getFluidState(blockposition); return chunk == null ? null : chunk.getFluidState(blockposition);
} }

Datei anzeigen

@ -30,10 +30,10 @@ index 87a81cdd00b19ba020f6506eedd8ac4bf20d32ef..a487331d9df8fa0d58cfb0859c25a8ff
@Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI @Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
return this.chunkSource.getChunk(x, z, false); return this.chunkSource.getChunk(x, z, false);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 3e4ebdb53b543c85c1179b591ce5569336fbb995..89274e7df5ab8e8681d96b20c752fa34eebc44f3 100644 index 4d2a64a38a94cc82767030dbdf219b5ee1002a7d..00911231201f84b781048d052495b60a47fb5277 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -496,7 +496,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -497,7 +497,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// CraftBukkit start // CraftBukkit start
iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam
CraftWorld world = ((ServerLevel) this).getWorld(); CraftWorld world = ((ServerLevel) this).getWorld();

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Optimize World.isLoaded(BlockPosition)Z
Reduce method invocations for World.isLoaded(BlockPosition)Z Reduce method invocations for World.isLoaded(BlockPosition)Z
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 3c8d4d439d40a8dc340286e0a9852b8911ce607f..a3ff278b5a2caa8132025f6cbee46500e97f58c4 100644 index c834428e04eab9639cfa9d07513d695dcb3bfce9..64abe2a075c1b2ee18cb691599ef5223953108f3 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -337,6 +337,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -338,6 +338,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return chunk == null ? null : chunk.getFluidState(blockposition); return chunk == null ? null : chunk.getFluidState(blockposition);
} }

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Fix MC-117075: TE Unload Lag Spike
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 6a5ede377a2e5e7c39ebf6db6708b4f234f96dc7..f39d927df5997cb0dd3d8c677a10099afa84da09 100644 index 94e527fa7db9822a15711c80107a2d99eacbaac5..edb12eb2a567febe01dd3160b193b0d8a7d17270 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -721,6 +721,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -722,6 +722,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Spigot start // Spigot start
// Iterator iterator = this.blockEntityTickers.iterator(); // Iterator iterator = this.blockEntityTickers.iterator();
int tilesThisCycle = 0; int tilesThisCycle = 0;
@ -17,7 +17,7 @@ index 6a5ede377a2e5e7c39ebf6db6708b4f234f96dc7..f39d927df5997cb0dd3d8c677a10099a
for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0; this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(tileTickPosition); TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(tileTickPosition);
@@ -728,7 +730,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -729,7 +731,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
if (tickingblockentity == null) { if (tickingblockentity == null) {
this.getCraftServer().getLogger().severe("Spigot has detected a null entity and has removed it, preventing a crash"); this.getCraftServer().getLogger().severe("Spigot has detected a null entity and has removed it, preventing a crash");
tilesThisCycle--; tilesThisCycle--;
@ -25,7 +25,7 @@ index 6a5ede377a2e5e7c39ebf6db6708b4f234f96dc7..f39d927df5997cb0dd3d8c677a10099a
continue; continue;
} }
// Spigot end // Spigot end
@@ -736,12 +737,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -737,12 +738,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
if (tickingblockentity.isRemoved()) { if (tickingblockentity.isRemoved()) {
// Spigot start // Spigot start
tilesThisCycle--; tilesThisCycle--;

Datei anzeigen

@ -18,7 +18,7 @@ the blockstate that will be valid for restoration, as opposed to dropping
information on restoration when the event is cancelled. information on restoration when the event is cancelled.
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index f39d927df5997cb0dd3d8c677a10099afa84da09..995278298b7feb61255cd8c1fea396ed0850099e 100644 index edb12eb2a567febe01dd3160b193b0d8a7d17270..7b4fe58cb6b9e0b4b9a09c79a5385c785983c955 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -151,7 +151,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -151,7 +151,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@ -30,7 +30,7 @@ index f39d927df5997cb0dd3d8c677a10099afa84da09..995278298b7feb61255cd8c1fea396ed
public Map<BlockPos, BlockEntity> capturedTileEntities = new HashMap<>(); public Map<BlockPos, BlockEntity> capturedTileEntities = new HashMap<>();
public List<ItemEntity> captureDrops; public List<ItemEntity> captureDrops;
public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<SpawnCategory> ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<SpawnCategory> ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>();
@@ -379,7 +379,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -380,7 +380,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) { public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
// CraftBukkit start - tree generation // CraftBukkit start - tree generation
if (this.captureTreeGeneration) { if (this.captureTreeGeneration) {
@ -39,7 +39,7 @@ index f39d927df5997cb0dd3d8c677a10099afa84da09..995278298b7feb61255cd8c1fea396ed
if (blockstate == null) { if (blockstate == null) {
blockstate = CapturedBlockState.getTreeBlockState(this, pos, flags); blockstate = CapturedBlockState.getTreeBlockState(this, pos, flags);
this.capturedBlockStates.put(pos.immutable(), blockstate); this.capturedBlockStates.put(pos.immutable(), blockstate);
@@ -399,7 +399,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -400,7 +400,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// CraftBukkit start - capture blockstates // CraftBukkit start - capture blockstates
boolean captured = false; boolean captured = false;
if (this.captureBlockStates && !this.capturedBlockStates.containsKey(pos)) { if (this.captureBlockStates && !this.capturedBlockStates.containsKey(pos)) {
@ -49,7 +49,7 @@ index f39d927df5997cb0dd3d8c677a10099afa84da09..995278298b7feb61255cd8c1fea396ed
this.capturedBlockStates.put(pos.immutable(), blockstate); this.capturedBlockStates.put(pos.immutable(), blockstate);
captured = true; captured = true;
} }
@@ -611,7 +612,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -612,7 +613,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public BlockState getBlockState(BlockPos pos) { public BlockState getBlockState(BlockPos pos) {
// CraftBukkit start - tree generation // CraftBukkit start - tree generation
if (this.captureTreeGeneration) { if (this.captureTreeGeneration) {

Datei anzeigen

@ -17,10 +17,10 @@ index 4398a33df4e0f0e9d28c51af3d48e41d957d7c9e..3488c882c654a2cb7a470ed84066bcc0
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 995278298b7feb61255cd8c1fea396ed0850099e..d2e07f39097aee880e14c7b6c6df90e825a724d3 100644 index 7b4fe58cb6b9e0b4b9a09c79a5385c785983c955..bb5d49a1b002fbe9109b2fe6c31c9d4f7c3f9ac8 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -765,6 +765,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -766,6 +766,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Paper end // Paper end
} }
} }

Datei anzeigen

@ -11,7 +11,7 @@ floating in the air.
This can replace many uses of BlockPhysicsEvent This can replace many uses of BlockPhysicsEvent
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 638a77d3ea65b509b9fcdd3c1e3ea0abe5b7566f..35838b3c858f8dd3c3cb59fe1c4cc8d1d878ff83 100644 index 01e8a8c36645efc9b728c6c58e12f594d619f5a5..dcbd8afb4d6fcf509bbb66788f55e83f2faa6f90 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -29,6 +29,7 @@ import net.minecraft.nbt.CompoundTag; @@ -29,6 +29,7 @@ import net.minecraft.nbt.CompoundTag;
@ -22,7 +22,7 @@ index 638a77d3ea65b509b9fcdd3c1e3ea0abe5b7566f..35838b3c858f8dd3c3cb59fe1c4cc8d1
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@@ -582,8 +583,21 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -583,8 +584,21 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return false; return false;
} else { } else {
FluidState fluid = this.getFluidState(pos); FluidState fluid = this.getFluidState(pos);

Datei anzeigen

@ -10,10 +10,10 @@ Optimize to check if the captured list even has values in it, and also to
just do a get call since the value can never be null. just do a get call since the value can never be null.
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 35838b3c858f8dd3c3cb59fe1c4cc8d1d878ff83..9b3a86710d5ac63afee9293f0c2cb1e443c98020 100644 index dcbd8afb4d6fcf509bbb66788f55e83f2faa6f90..07fa9e1b1b165bd98135b66ffd8eef5c9b5389fc 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -898,9 +898,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -899,9 +899,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@Nullable @Nullable
public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) { public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) {

Datei anzeigen

@ -1161,7 +1161,7 @@ index 514c045883060e4a22f748176091d3b236c2a7fd..aee5144bdc5bd9f7b07ce3b72331bcfd
public void destroyAndAck(BlockPos pos, int sequence, String reason) { public void destroyAndAck(BlockPos pos, int sequence, String reason) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 6f5fa7a2db798419a60206bc714e72b49b6a79e8..63036914ff4f7b52bb1880cc4514ed4da11ff163 100644 index 16a5103e106f87fb5d33c4e4435b494cae583395..c53fa2902c6572c65f42a07be987a7da096a8aee 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/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 { @@ -172,6 +172,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@ -1189,7 +1189,7 @@ index 6f5fa7a2db798419a60206bc714e72b49b6a79e8..63036914ff4f7b52bb1880cc4514ed4d
} }
// Paper start // Paper start
@@ -454,6 +456,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -455,6 +457,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// CraftBukkit end // CraftBukkit end
BlockState iblockdata1 = chunk.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag BlockState iblockdata1 = chunk.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag

Datei anzeigen

@ -269,7 +269,7 @@ index f22c50f0a2ef05e9f52550db7c40b5b99632650c..549ea8e0fe702615eefcbfd1cd6a30e0
} }
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 1051e81a0fb9f0a590e92b0d1fa27cb7afcae06f..3cc7ef57fa5bf43ae5de25b69e2b73e56c4bb703 100644 index 508900514a98ad35d33854a1c67a1b38c5ac76b1..0e15a5292cf32ad613952ba15c2f202c40d1d2b2 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java --- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -526,7 +526,7 @@ public abstract class PlayerList { @@ -526,7 +526,7 @@ public abstract class PlayerList {
@ -294,10 +294,10 @@ index f5829ae484d93b547a5437b85a9621346384a11b..83701fbfaa56a232593ee8f11a3afb89
} }
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 63036914ff4f7b52bb1880cc4514ed4da11ff163..6498a4073867fc2cb24e2d75776d2a84661846fb 100644 index c53fa2902c6572c65f42a07be987a7da096a8aee..d9842447d7ae840bf9541bbe7c99b032c83d0039 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -820,6 +820,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -821,6 +821,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
try { try {
tickConsumer.accept(entity); tickConsumer.accept(entity);
} catch (Throwable throwable) { } catch (Throwable throwable) {

Datei anzeigen

@ -34,10 +34,10 @@ index cc8dcb77f2b6d447c0e8d769a3d233dc2eb64efa..0a2f5e929d34c933755e9bc4b205e1b2
this.level.getProfiler().push("explosion_blocks"); this.level.getProfiler().push("explosion_blocks");
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 6498a4073867fc2cb24e2d75776d2a84661846fb..44f0325e8762e1bc528ab22d56a71322dbc84bd6 100644 index d9842447d7ae840bf9541bbe7c99b032c83d0039..6ee6ecf5ae3d450a2da4db453f5b02dd71073ad0 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -428,6 +428,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -429,6 +429,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) { public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
// CraftBukkit start - tree generation // CraftBukkit start - tree generation
if (this.captureTreeGeneration) { if (this.captureTreeGeneration) {

Datei anzeigen

@ -154,10 +154,10 @@ index d984a4304e8ebbcc3147e34bd3e35a7f0f95a83b..ef6aabd65651fe2eabe319908e6adfe9
} }
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index abaf792d77bb30d7bab6377dc1cdb6237766555d..5c904ca1e7963cabaaa84d81e0eab4872c4595ac 100644 index 81b94b2cda04cbb2bc89036448e48fef791b338b..b94736286adf22ea4ff5702fa7a45b5e212b232f 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -825,6 +825,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -826,6 +826,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Spigot end // Spigot end
} else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) { } else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) {
tickingblockentity.tick(); tickingblockentity.tick();
@ -169,7 +169,7 @@ index abaf792d77bb30d7bab6377dc1cdb6237766555d..5c904ca1e7963cabaaa84d81e0eab487
} }
} }
this.blockEntityTickers.removeAll(toRemove); this.blockEntityTickers.removeAll(toRemove);
@@ -839,6 +844,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -840,6 +845,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) { public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
try { try {
tickConsumer.accept(entity); tickConsumer.accept(entity);

Datei anzeigen

@ -319,10 +319,10 @@ index 30663713e198bfe40b95c48524b71ea65f39965e..25503678e7d049a8b3172cfad8a56069
public BlockPos getHomePos() { public BlockPos getHomePos() {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index f2868adace339d923012efc9aba0d882909eecb5..7c86a130afb536ece5726caf7f2b32f68fa5fa0a 100644 index 8be0e1097f0490bc87f3eb87249daa6c0f761bb7..158046d001cbd71b4cec2717f5e9266cc87cd2d0 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1368,10 +1368,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -1369,10 +1369,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public abstract RecipeManager getRecipeManager(); public abstract RecipeManager getRecipeManager();
public BlockPos getBlockRandomPos(int x, int y, int z, int l) { public BlockPos getBlockRandomPos(int x, int y, int z, int l) {

Datei anzeigen

@ -2034,10 +2034,10 @@ index d0a19d8e04e92a39d5db19e9eb23aa44a7691567..4029f898b16205bf6779ee3b38dd2223
EntityCallbacks() {} EntityCallbacks() {}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 413b4a5d2064381b2f52f6b4eef553c72029808f..bb411f4efc550ed7872f0252373be81bd8e99b76 100644 index 9d122994fb0587eab313ba522a2e9933aa2ddc8b..807b58b1a7a9a01faef7f42aba022ed467fa607e 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1520,4 +1520,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -1521,4 +1521,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return ret; return ret;
} }
// Paper end // Paper end