d627cfa110
Upstream has released updates that appears 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: 17da3420 Fix reading custom persistent entity data 83783357 SPIGOT-4980: Shields will not be put on cooldown when hit with an axe 8d0f3722 SPIGOT-4752: Fixed inconsistency between isChunkLoaded and chunk load/unload events 3f9f31c3 SPIGOT-4982: Armor disappearing while breaking the armor stand
59 lines
2.3 KiB
Diff
59 lines
2.3 KiB
Diff
From b0d8c37bfea84dd51fffd1e950e359bdc819e832 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 4 Jul 2018 02:13:59 -0400
|
|
Subject: [PATCH] Store counts for each Entity/Block Entity Type
|
|
|
|
Opens door for future patches to optimize performance
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
|
index ce40882b17..7bcbe601bc 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -56,15 +56,19 @@ public class Chunk implements IChunkAccess {
|
|
}
|
|
|
|
// Paper start
|
|
+ public final co.aikar.util.Counter<String> entityCounts = new co.aikar.util.Counter<>();
|
|
+ public final co.aikar.util.Counter<String> tileEntityCounts = new co.aikar.util.Counter<>();
|
|
private class TileEntityHashMap extends java.util.HashMap<BlockPosition, TileEntity> {
|
|
@Override
|
|
public TileEntity put(BlockPosition key, TileEntity value) {
|
|
TileEntity replaced = super.put(key, value);
|
|
if (replaced != null) {
|
|
replaced.setCurrentChunk(null);
|
|
+ tileEntityCounts.decrement(replaced.getMinecraftKeyString());
|
|
}
|
|
if (value != null) {
|
|
value.setCurrentChunk(Chunk.this);
|
|
+ tileEntityCounts.increment(value.getMinecraftKeyString());
|
|
}
|
|
return replaced;
|
|
}
|
|
@@ -74,6 +78,7 @@ public class Chunk implements IChunkAccess {
|
|
TileEntity removed = super.remove(key);
|
|
if (removed != null) {
|
|
removed.setCurrentChunk(null);
|
|
+ tileEntityCounts.decrement(removed.getMinecraftKeyString());
|
|
}
|
|
return removed;
|
|
}
|
|
@@ -378,6 +383,7 @@ public class Chunk implements IChunkAccess {
|
|
k = this.entitySlices.length - 1;
|
|
}
|
|
|
|
+ if (!entity.inChunk || entity.getCurrentChunk() != this) entityCounts.increment(entity.getMinecraftKeyString()); // Paper
|
|
entity.inChunk = true;
|
|
entity.setCurrentChunk(this); // Paper
|
|
entity.chunkX = this.loc.x;
|
|
@@ -409,6 +415,7 @@ public class Chunk implements IChunkAccess {
|
|
if (!this.entitySlices[i].remove(entity)) {
|
|
return;
|
|
}
|
|
+ entityCounts.decrement(entity.getMinecraftKeyString());
|
|
// Paper end
|
|
}
|
|
|
|
--
|
|
2.21.0
|
|
|