Jump to content

[SOLVED]Textures Not Working in Inventory, but do in World


mardiff

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;

 

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

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

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.