Fix memory leak caused by mob spawner items

This commit is contained in:
embeddedt committed 2022-06-05 12:13:12 -04:00
1 parent d20a80a77c
commit 09432dd986
2 files changed
+6

No files matched your search

@@ -328,6 +328,8 @@ public class ClientHandler
if (!Minecraft.getMinecraft().isSingleplayer())//wait for server to initiate in singleplayer
NEIClientConfig.loadWorld("remote/" + ClientUtils.getServerIP().replace(':', '~'));
ItemMobSpawner.clearEntityReferences(world);
}
lastworld = world;
@@ -96,6 +96,10 @@ public class ItemMobSpawner extends ItemBlock
return e;
}
public static void clearEntityReferences(World newWorld) {
entityHashMap.values().removeIf(e -> e.worldObj != newWorld);
}
private void setDefaultTag(ItemStack itemstack) {
if (!IDtoNameMap.containsKey(itemstack.getItemDamage()))
itemstack.setItemDamage(idPig);