Jump to content

[1.7.2] Blocks rendering as Items. Yes, I'm registering in preInit. (Solved)


Recommended Posts

Posted

Hey guys, I'm seem to be having a problem when I run my obfuscated mod in Minecraft. The blocks displays as items. When I am in Eclipse, the renders work correctly. Before you start replying, I am registering my blocks and items in preInit.

 

@EventHandler
    public void preInit(FMLPreInitializationEvent event) {
buildingBlock = new BlockBuilding(Material.wood).setBlockName("ccmBlockBuilding").setHardness(0.5F).setCreativeTab(this.tabConstruction);
planningBlock = new BlockPlanner(Material.wood).setBlockName("ccmBlockPlanner").setHardness(0.5F).setCreativeTab(this.tabConstruction);
itemBlueprint = new ItemBlueprint().setUnlocalizedName("ccmItemBlueprint").setTextureName("ccm:itemblueprint").setCreativeTab(this.tabConstruction);
itemWoodHammer = new ItemHammer(1, Item.ToolMaterial.WOOD).setUnlocalizedName("ccmItemWoodHammer").setTextureName("ccm:itemwoodhammer").setCreativeTab(this.tabConstruction).setFull3D();
itemStoneHammer = new ItemHammer(3, Item.ToolMaterial.STONE).setUnlocalizedName("ccmItemStoneHammer").setTextureName("ccm:itemstonehammer").setCreativeTab(this.tabConstruction).setFull3D();
itemIronHammer = new ItemHammer(6, Item.ToolMaterial.IRON).setUnlocalizedName("ccmItemIronHammer").setTextureName("ccm:itemironhammer").setCreativeTab(this.tabConstruction).setFull3D();
itemGoldHammer = new ItemHammer(4, Item.ToolMaterial.GOLD).setUnlocalizedName("ccmItemGoldHammer").setTextureName("ccm:itemgoldhammer").setCreativeTab(this.tabConstruction).setFull3D();
itemDiamondHammer = new ItemHammer(8, Item.ToolMaterial.EMERALD).setUnlocalizedName("ccmItemDiamondHammer").setTextureName("ccm:itemdiamondhammer").setCreativeTab(this.tabConstruction).setFull3D();
itemCreationTool = new ItemCreationTool().setUnlocalizedName("ccmItemCreationTool").setTextureName("ccm:itempencil").setCreativeTab(this.tabConstruction);
itemConstructionHelmet = new ItemConstructionHelmet(constructionArmour, 0, 0).setUnlocalizedName("ccmItemConstructionHelmet").setTextureName("ccm:itemconstructionhelmet").setCreativeTab(this.tabConstruction);

GameRegistry.registerBlock(buildingBlock, "BlockBuilding");
GameRegistry.registerBlock(planningBlock, "BlockPlanner");
GameRegistry.registerItem(itemConstructionHelmet, "ItemConstructionHelmet");
GameRegistry.registerItem(itemBlueprint, "ItemBlueprint");
GameRegistry.registerItem(itemCreationTool, "ItemCreationTool");
GameRegistry.registerItem(itemWoodHammer, "ItemHammer");
GameRegistry.registerItem(itemStoneHammer, "ItemStoneHammer");
GameRegistry.registerItem(itemIronHammer, "ItemIronHammer");
GameRegistry.registerItem(itemGoldHammer, "ItemGoldHammer");
GameRegistry.registerItem(itemDiamondHammer, "ItemDiamondHammer");

GameRegistry.registerTileEntity(com.mrcrayfish.construction.tileentity.TileEntityBuildingBlock.class, "ccmBuildingBlock");
GameRegistry.registerTileEntity(com.mrcrayfish.construction.tileentity.TileEntityPlanningBlock.class, "ccmPlanningBlock");

proxy.registerRenderers();
NetworkRegistry.INSTANCE.registerGuiHandler(this, guiHandler);
    }

 

Eclipse Environment:

width=800 height=449https://dl.dropboxusercontent.com/s/oy6gugfua44c1eb/2014-03-23_10.15.06.png[/img]

 

Obfuscated Environment:

width=800 height=450https://dl.dropboxusercontent.com/s/5ynjw1p26g3fprq/2014-03-23_10.32.40.png[/img]

 

If you have any answers, I will appreciate it very much!

Posted

Here is the block class as seen in the picture. I've removed irrelevant code.

 

package com.mrcrayfish.construction.block;

public class BlockBuilding extends BlockContainer {
    private IIcon direction;
    private IIcon rest;

    public BlockBuilding(Material par2Material) {
super(par2Material);
    }

    @Override
    public IIcon getIcon(int par1, int par2) {
return (par1 != par2 ? this.rest : this.direction);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister par1IconRegister) {
this.rest = par1IconRegister.registerIcon("ccm:buildingblock_rest");
this.direction = par1IconRegister.registerIcon("ccm:buildingblock_direction");
    }
}

 

Edit: I seem to have fixed the problem by change the register method to this.

GameRegistry.registerBlock(buildingBlock, buildingBlock.getUnlocalizedName().substring(5));

 

I think the registering name has to be the same as the string set in .setBlockName()

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.