2021-06-13 13:40:34 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sat, 6 Apr 2019 10:16:48 -0400
|
|
|
|
Subject: [PATCH] Optimize Captured TileEntity Lookup
|
|
|
|
|
|
|
|
upstream was doing a containsKey/get pattern, and always doing it at that.
|
|
|
|
that scenario is only even valid if were in the middle of a block place.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
2023-12-05 18:20:55 +01:00
|
|
|
index 3f6d9b7c91a14dedeee11968e80de26adeccb510..0c64e65af843034b26147f62c49c6ab12ac5ddd2 100644
|
2021-06-13 13:40:34 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
2023-09-22 22:13:57 +02:00
|
|
|
@@ -982,9 +982,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
2021-06-13 13:40:34 +02:00
|
|
|
|
|
|
|
@Nullable
|
2021-11-24 04:42:31 +01:00
|
|
|
public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) {
|
2021-06-13 13:40:34 +02:00
|
|
|
- if (this.capturedTileEntities.containsKey(blockposition)) {
|
|
|
|
- return this.capturedTileEntities.get(blockposition);
|
|
|
|
+ // Paper start - Optimize capturedTileEntities lookup
|
|
|
|
+ net.minecraft.world.level.block.entity.BlockEntity blockEntity;
|
|
|
|
+ if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(blockposition)) != null) {
|
|
|
|
+ return blockEntity;
|
|
|
|
}
|
|
|
|
+ // Paper end
|
|
|
|
// CraftBukkit end
|
2023-09-22 22:13:57 +02:00
|
|
|
return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && !io.papermc.paper.util.TickThread.isTickThread() ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); // Paper - rewrite chunk system
|
2021-06-13 13:40:34 +02:00
|
|
|
}
|