PaperMC/Spigot-Server-Patches/0509-MC-183249-Don-t-generate-Carving-Masks-BitSet-unless.patch
Aikar ce270e1412
Updated Upstream (Bukkit/CraftBukkit/Spigot)
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:
b2f1908c SPIGOT-5783: Add helpful info to UnknownDependencyException
e4f46260 SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot.
529a9a69 SPIGOT-5751: Clarify behaviour of block drop-related API methods

CraftBukkit Changes:
8ea9b138 Remove outdated build delay.
ffc2b251 Revert "#675: Fix redirected CommandNodes sometimes not being properly redirected"
cb701f6b #675: Fix redirected CommandNodes sometimes not being properly redirected
c9d7c16b SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot.
fad2494a #673: Fix Craftworld#isChunkLoaded
8637ec00 SPIGOT-5751: Made breakNaturally and getDrops returns the correct item if no argument is given

Spigot Changes:
a99063f7 Rebuild patches

Fixes #3602
2020-06-23 04:40:03 -04:00

43 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 9 May 2020 12:11:47 -0400
Subject: [PATCH] MC-183249: Don't generate Carving Masks BitSet unless needed
This was using SIGNIFICANT amounts of memory allocating many
long[]'s for BitSets for every ProtoChunk in the cache that had
been unloaded and reloaded.
This will result in a nice memory reduction.
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index fa893b14bcef9bab6891dea2c4375b09d74ac038..e625842e524f18e469f7695b27d52d4d04892266 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -472,7 +472,12 @@ public class ChunkRegionLoader {
for (int l = 0; l < k; ++l) {
WorldGenStage.Features worldgenstage_features = aworldgenstage_features[l];
- nbttagcompound3.setByteArray(worldgenstage_features.toString(), ichunkaccess.a(worldgenstage_features).toByteArray());
+ // Paper start - don't create carving mask bitsets if not even at that chunk status yet
+ BitSet mask = protochunk.getCarvingMaskIfSet(worldgenstage_features);
+ if (mask != null) {
+ nbttagcompound3.setByteArray(worldgenstage_features.toString(), mask.toByteArray());
+ }
+ // Paper end
}
nbttagcompound1.set("CarvingMasks", nbttagcompound3);
diff --git a/src/main/java/net/minecraft/server/ProtoChunk.java b/src/main/java/net/minecraft/server/ProtoChunk.java
index a78b240621e0407fff67b018224c39fc4f97f4e5..2eb14bbf888f5e5601441743cb7642da6ee1249c 100644
--- a/src/main/java/net/minecraft/server/ProtoChunk.java
+++ b/src/main/java/net/minecraft/server/ProtoChunk.java
@@ -43,7 +43,8 @@ public class ProtoChunk implements IChunkAccess {
private final ProtoChunkTickList<Block> q;
private final ProtoChunkTickList<FluidType> r;
private long s;
- private final Map<WorldGenStage.Features, BitSet> t;
+ private final Map<WorldGenStage.Features, BitSet> t;public BitSet getCarvingMaskIfSet(WorldGenStage.Features worldgenstage_features) { return this.t.get(worldgenstage_features); } // Paper
+ // Paper end
private volatile boolean u;
private final World world; // Paper - Anti-Xray - Add world