Change how blocks/items are registered (desc)

tterrag is a meany face and yelled at me for using class.getSimpleName(). So here's an API-friendly re-work of the registration system. This allows all our Items/Blocks to be obtained via the API. Just add a new enum.
This commit is contained in:
Nick 2016-01-18 22:34:12 -08:00
parent 2a028414b1
commit fdfcb5c5b7
69 changed files with 260 additions and 15 deletions

View file

@ -163,7 +163,15 @@ public class ModBlocks
private static Block registerBlock(Block block, Class<? extends ItemBlock> itemBlock)
{
return registerBlock(block, itemBlock, block.getClass().getSimpleName());
if (block.getRegistryName() == null) {
BloodMagic.instance.getLogger().error("Attempted to register Block {} without setting a registry name. Block will not be registered. Please report this.", block.getClass().getCanonicalName());
return block;
}
if (!ConfigHandler.blockBlacklist.contains(block.getRegistryName().split(":")[1]))
GameRegistry.registerBlock(block, itemBlock);
return block;
}
private static Block registerBlock(Block block, String name)
@ -176,6 +184,14 @@ public class ModBlocks
private static Block registerBlock(Block block)
{
return registerBlock(block, block.getClass().getSimpleName());
if (block.getRegistryName() == null) {
BloodMagic.instance.getLogger().error("Attempted to register Block {} without setting a registry name. Block will not be registered. Please report this.", block.getClass().getCanonicalName());
return null;
}
if (!ConfigHandler.blockBlacklist.contains(block.getRegistryName().split(":")[1]))
GameRegistry.registerBlock(block);
return block;
}
}