Ensure we check both item and block registries when finding valid IDs. Should fix #365
This commit is contained in:
parent
498ab360e8
commit
be8d33070e
2 changed files with 19 additions and 5 deletions
|
@ -107,7 +107,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
|||
private Map<String,Integer> transactionalNamedIds;
|
||||
private BitSet transactionalAvailabilityMap;
|
||||
private BitSet availabilityMap;
|
||||
private int maxId;
|
||||
int maxId;
|
||||
private int minId;
|
||||
private char discriminator;
|
||||
|
||||
|
@ -316,4 +316,9 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
|||
FMLLog.finer("Registry : %s %d %s", name, entry.getValue(), thing);
|
||||
}
|
||||
}
|
||||
|
||||
BitSet slots()
|
||||
{
|
||||
return (BitSet) availabilityMap.clone();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ package cpw.mods.fml.common.registry;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -157,11 +158,19 @@ public class GameData {
|
|||
{
|
||||
customOwners.put(new UniqueIdentifier(modId, name), mc);
|
||||
}
|
||||
int blockId = blockRegistry.add(0, name, block);
|
||||
int itemId = itemRegistry.add(blockId, name, item);
|
||||
if (itemId != blockId)
|
||||
BitSet blockAvailability = blockRegistry.slots();
|
||||
BitSet itemAvailability = itemRegistry.slots();
|
||||
blockAvailability.or(itemAvailability);
|
||||
int blockId = blockAvailability.nextClearBit(0);
|
||||
if (blockId >= blockRegistry.maxId)
|
||||
{
|
||||
throw new RuntimeException();
|
||||
throw new RuntimeException(String.format("No more space for block allocations: used %d block ids", blockId -1));
|
||||
}
|
||||
int actualBlockId = blockRegistry.add(blockId, name, block);
|
||||
int itemId = itemRegistry.add(blockId, name, item);
|
||||
if (blockId != actualBlockId || itemId != blockId)
|
||||
{
|
||||
throw new RuntimeException(String.format("There was a failure to allocate a matching block and item pair for %s: requested %d, got %d and %d", name, blockId, actualBlockId, itemId));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue