Ensure slave maps are cleaned up when handling registry overrides (#5250)

This commit is contained in:
Ben Staddon 2019-01-04 01:36:32 +00:00 committed by tterrag
parent cb3ff19801
commit 8b5a5ecd74
1 changed files with 24 additions and 0 deletions

View File

@ -273,6 +273,15 @@ public class GameData
this.objectList.clear();
this.nextId = 0;
}
void remove(I key)
{
Integer prev = this.identityMap.remove(key);
if (prev != null)
{
this.objectList.set(prev, null);
}
}
}
private static class BlockCallbacks implements IForgeRegistry.AddCallback<Block>, IForgeRegistry.ClearCallback<Block>, IForgeRegistry.BakeCallback<Block>, IForgeRegistry.CreateCallback<Block>, IForgeRegistry.DummyFactory<Block>
@ -316,6 +325,14 @@ public class GameData
}
/*
if (oldBlock != null)
{
for (IBlockState state : oldBlock.getBlockState().getValidStates())
{
blockstateMap.remove(state);
}
}
if ("minecraft:tripwire".equals(block.getRegistryName().toString())) //Tripwire is crap so we have to special case whee!
{
for (int meta = 0; meta < 15; meta++)
@ -424,6 +441,12 @@ public class GameData
@Override
public void onAdd(IForgeRegistryInternal<Item> owner, RegistryManager stage, int id, Item item, @Nullable Item oldItem)
{
if (oldItem instanceof ItemBlock)
{
@SuppressWarnings("unchecked")
BiMap<Block, Item> blockToItem = owner.getSlaveMap(BLOCK_TO_ITEM, BiMap.class);
blockToItem.remove(((ItemBlock)oldItem).getBlock());
}
if (item instanceof ItemBlock)
{
@SuppressWarnings("unchecked")
@ -511,6 +534,7 @@ public class GameData
}
if (entry.getEgg() != null)
EntityList.ENTITY_EGGS.put(entry.getRegistryName(), entry.getEgg());
}
}
}
*/