Paper/Spigot-Server-Patches/0008-Store-counts-for-each-Entity-Block-Entity-Type.patch
Shane Freeder 3496f2d7e4
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Developers!: You will need to clean up your work/Minecraft/1.13.2 folder for this

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

Bukkit Changes:
b850a822 SPIGOT-4526: Add conversion time API for Zombie & subclasses

CraftBukkit Changes:
38cf676e SPIGOT-4534: CreatureSpawnEvent not being called for CHUNK_GEN
b446cb5d SPIGOT-4527: Fix sponges with waterlogged blocks
6ec8ea5c SPIGOT-4526: Add conversion time API for Zombie & subclasses
c64fe508 Mappings Update
a3c2ec03 Fix missing ServerListPingEvent call for legacy pings

Spigot Changes:
1dc156ce Rebuild patches
140f654d Mappings Update
2018-12-17 05:19:39 +00:00

59 lines
2.3 KiB
Diff

From a00c2b358e7f0ce360d28c8e803026470f3ee940 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 d1d8c3be6..4d04fdda7 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -68,15 +68,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;
}
@@ -86,6 +90,7 @@ public class Chunk implements IChunkAccess {
TileEntity removed = super.remove(key);
if (removed != null) {
removed.setCurrentChunk(null);
+ tileEntityCounts.decrement(removed.getMinecraftKeyString());
}
return removed;
}
@@ -683,6 +688,7 @@ public class Chunk implements IChunkAccess {
this.entitySlices[k].add(entity);
// Paper start
entity.setCurrentChunk(this);
+ entityCounts.increment(entity.getMinecraftKeyString());
// Paper end
}
@@ -707,6 +713,7 @@ public class Chunk implements IChunkAccess {
return;
}
entity.setCurrentChunk(null);
+ entityCounts.decrement(entity.getMinecraftKeyString());
// Paper end
}
--
2.20.0