mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-18 11:29:35 +00:00
Use a weak hash map instead of manually clearing the map
This commit is contained in:
2 files changed
+4
-7
No files matched your search
@@ -328,8 +328,6 @@ 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;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
@@ -33,7 +34,9 @@ public class ItemMobSpawner extends ItemBlock
|
||||
hasSubtypes = true;
|
||||
MinecraftForgeClient.registerItemRenderer(this, new SpawnerRenderer());
|
||||
|
||||
entityHashMap = new HashMap<>();
|
||||
entityHashMap = new MapMaker()
|
||||
.weakValues()
|
||||
.makeMap();
|
||||
IDtoNameMap = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -96,10 +99,6 @@ 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);
|
||||
|
||||
Reference in new issue
Block a user