Paper/Spigot-Server-Patches/0008-Store-counts-for-each-Entity-Block-Entity-Type.patch
Aikar 835bc39b03
Paper 1.13.1 Update
Updated Upstream (Bukkit/CraftBukkit/Spigot)

Bukkit Changes:
2dcc44dc SPIGOT-4307: Fix hacky API for banners on shields
e0fc6572 SPIGOT-4309: Add "forced" display of particles
efeeab2f Add index to README.md for easier navigation
f502bc6f Update to Minecraft 1.13.1

CraftBukkit Changes:
d0bb0a1d Fix some tests randomly failing
997d378d Fix client stall in specific teleportation scenarios
b3dc2366 SPIGOT-4307: Fix hacky API for banners on shields
2a271162 SPIGOT-4301: Fix more invalid enchants
5d0d83bb SPIGOT-4309: Add "forced" display of particles
a6772578 Add additional tests for CraftBlockData
ce1af0c3 Update to Minecraft 1.13.1

Spigot Changes:
2440e189 Rebuild patches
4ecffced Update to Minecraft 1.13.1
2018-08-26 20:51:39 -04:00

59 lines
2.3 KiB
Diff

From 3e64fc7d6db1a903430d4313f4da4d84173428c4 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 85f33c140e..bcafd86fb8 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -63,15 +63,19 @@ public class Chunk implements IChunkAccess {
private int neighbors = 0x1 << 12;
public long chunkKey;
// 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;
}
@@ -81,6 +85,7 @@ public class Chunk implements IChunkAccess {
TileEntity removed = super.remove(key);
if (removed != null) {
removed.setCurrentChunk(null);
+ tileEntityCounts.decrement(removed.getMinecraftKeyString());
}
return removed;
}
@@ -670,6 +675,7 @@ public class Chunk implements IChunkAccess {
this.entitySlices[k].add(entity);
// Paper start
entity.setCurrentChunk(this);
+ entityCounts.increment(entity.getMinecraftKeyString());
// Paper end
}
@@ -694,6 +700,7 @@ public class Chunk implements IChunkAccess {
return;
}
entity.setCurrentChunk(null);
+ entityCounts.decrement(entity.getMinecraftKeyString());
// Paper end
}
--
2.18.0