Jump to content

[SOLVED][1.7.10] Multipass rendered ItemBlock for Block with damage values


Recommended Posts

Posted

SOLUTION: I have discovered the source of my issue.

 

After much investigation I have discovered that Vanilla's ItemBlock renderer does not care at all about any of the getIcon method family, and instead is based entirely on the associated Block's rendering. A custom renderer is required for what I am trying to accomplish.

 

Hello all!

 

I'm having a bit of trouble with a custom ItemBlock implementation. I have a multi pass rendered Block that has multiple subtypes using metadata. The first pass renders vanilla's stone brick texture, and the second pass renders a texture on top of it based on my Block's metadata. The block implementation is working as expected, but I cannot seem to get the ItemBlock's rendering to behave.

 

I have registered the custom ItemBlock in the GameRegistry alongside its Block counterpart as per the norm; The ItemBlock code is as follows:

 

public class ItemBlockTest extends ItemBlock {
public ItemBlockTest(Block passedBlock) {
	super(passedBlock);
	this.setHasSubtypes(true);
}

@Override
public int getMetadata(int metadata) {
	return metadata;
}

@Override
@SideOnly(Side.CLIENT)
public boolean requiresMultipleRenderPasses()
{
	return true;
}

@Override
@SideOnly(Side.CLIENT)
public int getRenderPasses(int metadata) {
	return 2;
}

// DEBUG!
@Override
public IIcon getIconFromDamage(int passedMetadata) {
	return Blocks.dirt.getBlockTextureFromSide(passedMetadata);
}
}

 

I have the ItemBlock's getIconFromDamage method returning Dirt's texture as a debugging measure, but this is not the case in game. The ItemBlock is instead only rendering the texture from the parent Block's second render pass, no matter what I put in the getIconFromDamage method. I know the method is being called, I had previously put a System.out.println in there; the return value just doesn't seem to be used.

 

My hunch is that the getIconFromDamage method is used for ItemBlocks that have a sprite texture and don't render as a cube, but then why wouldn't the inventory render simply show the dirt texture as a flat plane? My other hunch is that I might need a special rendering handler to accomplish what I want here: An ItemBlock that has the texture of stone bricks, with another texture overlaid based on the ItemBlock's metadata.

 

This is probably just a major derp on my part, could anybody shed some light here?

Posted

you need to use

getIcon(ItemStack stack, int pass)

and on pass 0, return the stone brick icon, on pass 1 your own texture based on the damage the ItemStack has.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

There isn't a method in the ItemBlock superclass (nor in net.minecraft.Block) that matches that method signature, which was where I was looking.

 

A similar method exists in net.minecraft.Item though, as getIconFromDamageForRenderPass, but this method also does not affect the ItemBlock's rendering to any degree, no matter what I put as a return value there.

 

There are no getIcon methods that accept an ItemStack as a parameter. Ignore this, I missed it, my apologies. But the method in net.minecraft.item still does not change the ItemBlock's rendering. So far I have tried:

 

@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int passedMetadata) {
return Blocks.dirt.getBlockTextureFromSide(0);
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
return Blocks.dirt.getBlockTextureFromSide(0);
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamageForRenderPass(int passedMetadata, int passedRenderPass)
{
return Blocks.dirt.getBlockTextureFromSide(0);
}

 

And none of the three seem to alter my ItemBlock's inventory render at all.

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.