Jump to content

Block Faces me when I Place It, But Icon in Inventory Does Not


kenoba10

Recommended Posts

I have a block that has a few different textures and I hae gotten it so, the front texture faces you when it is placed.  But how would I make the icon when it is in my inventory display similar to how the furnace does?  Here is my code:

 

@SideOnly(Side.CLIENT)
    private IIcon blockTop;

    @SideOnly(Side.CLIENT)
    private IIcon blockSide;

    public BlockFactoryTerminal() {

        super();

        this.setBlockName("factoryFactoryTerminal");

    }

    public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {

        int l = MathHelper.floor_double((double) (player.rotationYaw * 4f / 360f) + .5d) & 3;

        if(l == 0)
            world.setBlockMetadataWithNotify(x, y, z, 2, 2);

        if(l == 1)
            world.setBlockMetadataWithNotify(x, y, z, 5, 2);

        if(l == 2)
            world.setBlockMetadataWithNotify(x, y, z, 3, 2);

        if(l == 3)
            world.setBlockMetadataWithNotify(x, y, z, 4, 2);

    }

    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister iconRegister) {

        blockIcon = iconRegister.registerIcon(String.format("%s", getUnWrappedUnlocalizedName(this.getUnlocalizedName())));
        blockTop = iconRegister.registerIcon(String.format("%s", getUnWrappedUnlocalizedName(ElectricFactoryBlocks.factoryFactoryStructureBlock.getUnlocalizedName() + "Top")));
        blockSide = iconRegister.registerIcon(String.format("%s", getUnWrappedUnlocalizedName(ElectricFactoryBlocks.factoryFactoryStructureBlock.getUnlocalizedName())));

    }

    @SideOnly(Side.CLIENT)
    public IIcon getIcon(int side, int meta) {

        if(side == 0 || side == 1)
            return blockTop;
        else if(side != meta)
            return blockSide;
        else
            return blockIcon;

    }

Link to comment
Share on other sites

I have a block that has a few different textures and I hae gotten it so, the front texture faces you when it is placed.  But how would I make the icon when it is in my inventory display similar to how the furnace does?

What do you mean "similar to how the furnace does" ?

Do you mean you want the inventory block to face a particular direction?

 

If so, I would suggest one of two things-

either change your metadata meanings so that medata=0 gives you the inventory rendering appearance that you want, or use an ISimpleBlockRenderingHandler or an IItemRenderer for your item to give you more control.

For some background info, see here under the Item Rendering topics

http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html

 

-TGG

 

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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