Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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!

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.