Changed generic signature of GameRegistry.register methods to work around the type inference bug; updated all example mods to the new block/item registration method.

This commit is contained in:
RainWarrior committed 2016-04-03 10:14:16 +03:00
1 parent fc57d5e6c6
commit 77772ac3f5
12 files changed
+99 -44

No files matched your search

@@ -6,7 +6,9 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
@@ -20,7 +22,8 @@ public class MultiLayerModelDebug
public static final String MODID = "forgedebugmultilayermodel";
public static final String VERSION = "0.0";
public static String blockName = "test_layer_block";
private static String blockName = "test_layer_block";
private static final ResourceLocation blockId = new ResourceLocation(MODID, blockName);
@SidedProxy
public static CommonProxy proxy;
@@ -29,11 +32,12 @@ public class MultiLayerModelDebug
{
public void preInit(FMLPreInitializationEvent event)
{
GameRegistry.registerBlock(new Block(Material.wood)
GameRegistry.register(new Block(Material.wood)
{
{
setCreativeTab(CreativeTabs.tabBlock);
setUnlocalizedName(MODID + "." + blockName);
setRegistryName(blockId);
}
@Override
@@ -47,7 +51,8 @@ public class MultiLayerModelDebug
{
return layer == BlockRenderLayer.SOLID || layer == BlockRenderLayer.TRANSLUCENT;
}
}, blockName);
});
GameRegistry.register(new ItemBlock(Block.blockRegistry.getObject(blockId)).setRegistryName(blockId));
}
}
@@ -59,7 +64,7 @@ public class MultiLayerModelDebug
public void preInit(FMLPreInitializationEvent event)
{
super.preInit(event);
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(GameRegistry.findBlock(MODID, blockName)), 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + blockName, "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.itemRegistry.getObject(blockId), 0, new ModelResourceLocation(blockId, "inventory"));
}
}