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.

Featured Replies

Posted

Hello everyone,

 

I have a block that should be rendered pretty much the same as  furnace with different textures, except that the front side is never rendered in the inventory. Any help?

 

 

 

@SideOnly(Side.CLIENT)

 

/**

* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata

*/

public Icon getIcon(int par1, int par2)

{

return par1 == 2 ? (this.isActive ? this.furnaceIconActive : this.furnaceIconIdle) : this.furnaceIconSides;

}

 

@SideOnly(Side.CLIENT)

 

/**

* When this method is called, your block should register all the icons it needs with the given IconRegister. This

* is the only chance you get to register icons.

*/

public void registerIcons(IconRegister par1IconRegister)

{

this.furnaceIconSides = par1IconRegister.registerIcon("redstonefurnace:redstone_furnace_side");

this.furnaceIconActive = par1IconRegister.registerIcon("redstonefurnace:redstone_furnace_active");

this.furnaceIconIdle = par1IconRegister.registerIcon("redstonefurnace:redstone_furnace_idle");

}

 

 

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

side 0 and 1 are top and bottom so the sides are > 1

 

return par1 > 1...

 

I also use this along with the getIcon

 

    @SideOnly(Side.CLIENT)
    public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
    	int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
        if (par5 == 1 || par5 == 0)
        {
        	//Return Top/Bottom
            
        }
        else
        {
        	//Return Sides
        }
    }

  • Author

The names of the textures are misleading, the "furnaceIconSides" are really just all of the sides that aren't the front. The active and idle are the two options for side 2, which is the front. And I don't really see the point of using getBlockTexture and getIcon.

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

Minecraft has no sense of direction. The side number is cardinal directions Up, Down, North...etc. The furnace, Im pretty sure, uses meta to determine the front.

  • Author

Still works the same: the front texture works when its in the world, but the entire block in the inventory is the regular side Icon.

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

I dont even know how you managed to get it to work at all. You are trying to tell me no matter which direction you place it, the front icon shows as the actual front of the furnace AND any other furnace you place can display its own unique front face?

I got it working.

Lets see if I can remember all the changes...

 

BlockRedstoneFurnace:

public Icon getIcon(int par1, int par2)
{
	return par1 == 1 ? this.blockIcon : (par1 == 0 ? this.blockIcon : (par1 != par2 ? this.blockIcon : this.furnaceIconFront));
}

To:

public Icon getIcon(int par1, int par2)
{
	if (par1 == 4 && par2 == 0)
		return furnaceIconFront;
	if (par1 == 1)
		return blockIcon;
	if (par2 == -1 || par1 == par2)
		return furnaceIconFront;
	return blockIcon;
}

 

Added:

    @SideOnly(Side.CLIENT)
    public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
    	int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
    	return par5 == 1 ? this.blockIcon : (par5 == 0 ? this.blockIcon : (par5 != meta ? this.blockIcon : this.furnaceIconFront));
    }

 

I believe those are all the relevant changes I made. I changed the way you registered your block but I dont think it had anything to do with this.

Minecraft is weird.  In the inventory the furnace has a metadata of 0 (obviously: it's not placed) but that renders it 180 degrees away from where it needs to in order for the front to be the rendered face (you're actually seeing the back and right side).

 

Even vanilla has to do a kind of a hack to get the furnace to render the right way around.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Thanks guys, I really appreciate it.

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

Check your code on that.


public YourBlock(int par1, String texture) 
{
	super(par1, Material.rock);
	setCreativeTab(CreativeTabs.tabBlock);
}
public Icon getIcon(int par1, int par2)
    {
        return par1 == 1 ? this.field_94474_b : (par1 == 0 ? this.field_94474_b : (par2 == 2 && par1 == 2 ? this.field_94475_c : (par2 == 3 && par1 == 5 ? this.field_94475_c : (par2 == 0 && par1 == 3 ? this.field_94475_c : (par2 == 1 && par1 == 4 ? this.field_94475_c : this.blockIcon)))));
    }

Also in the end of the code put these;

public void registerIcons(IconRegister par1IconRegister) {
	this.blockIcon = par1IconRegister.registerIcon("youriconname");
	this.field_94393_a = par1IconRegister.registerIcon("youriconname");
	this.field_94392_b = par1IconRegister.registerIcon("youriconname");
	 this.field_94474_b = par1IconRegister.registerIcon("your[top]iconname");
	this.field_94475_c = par1IconRegister.registerIcon(this.blockType ? "your[front]iconname" : "your[front]iconname");
}

Mess up with the sides, i dont remember which.

Put this code if you want to always put your block from specified side;

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack)
    {
        int var7 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
        par1World.setBlockMetadataWithNotify(par2, par3, par4, var7, 2);
    }

AND DONT FORGET ABOUT VARIABLES IN THE BEGGINING OF CODE. IT SHOULD LOOK LIKE THIS;

public class YourBlock extends Block {
private boolean blockType;
private Icon field_94393_a;
private Icon field_94392_b;
private Icon field_94474_b;
private Icon field_94475_c;

 

  • Author

Umm thanks for all that stuff doorcloser, but I had all that already aside from the part that my icons are named and yours aren't...

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

  • 1 month later...

Hello!

 

So I am having this same problem as well....I tried the getIcon() method fix suggested by CJLetsGame. The custom furnace texture loaded correctly in the inventory. But, my problem is that when the block is placed it registers the side icons as the top and bottom icons.

 

I double checked exactly what I was replacing and found out that the getIcon() method as used above was different then mine (different minecraft version I am assuming).

 

Here is what my getIcon() method looks like.

 

@SideOnly(Side.CLIENT)

 

    /**

    * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata

    */

    public Icon getIcon(int par1, int par2)

    {

        return par1 == 1 ? this.furnaceIconTop : (par1 == 0 ? this.furnaceIconTop : (par1 != par2 ? this.blockIcon : this.furnaceIconFront));

    }

 

Seeing that it is different.....what should I do or change in order for the top and bottom icons to register correctly. I assume that I just need to register them in the getIcon() method. But, then again this is my first time looking at this code so i am not 100% sure.

 

Thanks before hand :D

Every day is a new day to learn.

I acknowledge the hard work of original content.

I will always improve in many ways.

 

Java > c

Wait!

 

I used this code and solved it

 

if (par2 == 0 && par1 == 3)

return furnaceIconFront;

        return par1 == 1 ? this.furnaceIconTop : (par1 == 0 ? this.furnaceIconTop : (par1 != par2 ? this.blockIcon : this.furnaceIconFront));

Every day is a new day to learn.

I acknowledge the hard work of original content.

I will always improve in many ways.

 

Java > c

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.