Skip to content

Commit

Permalink
Fix memory leak caused by mob spawner items
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Jun 5, 2022
1 parent d20a80a commit 09432dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/codechicken/nei/ClientHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ public void loadWorld(World world, boolean fromServer) {

if (!Minecraft.getMinecraft().isSingleplayer())//wait for server to initiate in singleplayer
NEIClientConfig.loadWorld("remote/" + ClientUtils.getServerIP().replace(':', '~'));

ItemMobSpawner.clearEntityReferences(world);
}

lastworld = world;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/codechicken/nei/ItemMobSpawner.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ public static EntityLiving getEntity(int ID) {
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);
Expand Down

0 comments on commit 09432dd

Please sign in to comment.