Jump to content

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


MrCaracal

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Please share a link to your crash report on https://paste.ee, as explained in the FAQ. Dumping it directly into the thread often triggers the anti-spam and makes it hard to read due to word wrapping
    • Hi all, I'm running a 1.20.1 Minecraft Forge server with a hosting website and something seems to have gone wrong. It started as an occasional crash that has now become extremely frequent and I don't know what exactly is causing it. I already tried disabling watchdog but the server crashes anyway. Oddly it only occasionally generates a crash report after a crash occurs. Based on viewing the server console's research usage it seems that the CPU spikes astronomically high (100% usage), especially when chunks are being loaded or when a new person joins the server. I downloaded Spark to create a profile (https://spark.lucko.me/bBlWe7ou29) but I lack experience with this mod and don't understand what I'm looking at/how this should help me diagnose the issue. I am using a lot of mods so I'm guessing there is some sort of issue there or a corrupted chunk (although MCRF found no chunk errors). We actually don't experience any lag until the crash occurs, so it's some sort of sudden spike in resource usage. Based on the crash report I've already tried removing Canary and Modernfix but there was no change. Thanks for any help you can provide. Specs:  4 cores x 4200MHz AMD Ryzen 9 5950X 4GB RAM Crash report:  
    • will test that once i get home, thanks
    • I am getting this exception (I am new and just trying to create an item) Caused by: java.io.FileNotFoundException: abrasmagics:models/item/ingot_test.json at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:69) ~[SimpleReloadableResourceManager.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.access$1400(ModelLoader.java:115) ~[ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:861) ~[ModelLoader$VanillaLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]   However the directory is set up correctly and the file does exist   idk how to upload images so here is a treeview of the directories:   src ├───main │ ├───java │ │ └───net │ │ └───abrasmods │ │ └───abrasmagics │ │ ├───init │ │ ├───items │ │ └───utils │ │ ├───handlers │ │ ├───misc │ │ └───proxy │ └───resources │ └───assets │ └───abrasmagics │ ├───models │ │ ├───block │ │ └───item │ └───textures └───test ├───java └───resources   the file ingot_test.json is under models/item. The directory seems fine and the file does exist so anyone plz help.   i am using intellij and is coding for 1.12.2
  • Topics

×
×
  • Create New...

Important Information

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