Jump to content

Trouble with ISimpleBlockRenderingHandler


QuantumLeaf7895

Recommended Posts

Hi all,

I've been working on a block with a custom renderer -- the idea is a partially transparent block which has a different 'height' based on its metadata.  I've been tinkering with a renderer, but for some reason when placed into the world the block is always invisible.

 

The block looks like this:

 

 

public class BlockAedifilisVapor extends BlockBreakable {

 

public BlockAedifilisVapor(int ID)

{

super(ID, 160, Material.sand, false);

this.setCreativeTab(CreativeTabs.tabDeco);

this.setBlockName("Aedifilis Vapor");

}

 

@Override

public String getTextureFile()

{

return Utils.BLOCKS_PNG;

}

 

@Override

public int getBlockTextureFromSideAndMetadata(int side, int meta)

{

if (side > 1)

{

return meta + 160;

}

else

{

return 163;

}

}

 

@SideOnly(Side.CLIENT)

@Override

    public int getRenderBlockPass()

    {

        return 1;

    }

 

@Override

public int getRenderType()

{

return Utils.aedifiliteVaporRenderID;

}

}

 

 

 

The renderer looks like this:

 

 

public class RenderAedifilisVapor implements ISimpleBlockRenderingHandler{

 

@Override

public boolean shouldRender3DInInventory()

{

//For various reasons, this block should never appear in the player's inventory -- hence no inventory renderer

return false;

}

 

@Override

public void renderInventoryBlock(Block block, int metadata, int modelID,

RenderBlocks renderer)

{

 

}

 

@Override

public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,

Block block, int modelId, RenderBlocks renderer) {

int meta = world.getBlockMetadata(x, y, z);

 

int heightInPixels = 2;

if (meta >= 1){heightInPixels += 5;}

if (meta >= 2){heightInPixels += 5;}

if (meta >= 3){heightInPixels = 16;}

 

float height = (heightInPixels / 16.0F);

block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, height, 1.0F);

renderer.renderStandardBlock(block, x, y, z);

 

return false;

}

 

 

 

@Override

public int getRenderId()

{

return Utils.aedifiliteVaporRenderID;

}

}

 

 

 

And I register the renderer in the client proxy like this:

 

 

@Override

public void registerRenderers()

{

Utils.aedifiliteVaporRenderID = RenderingRegistry.getNextAvailableRenderId();

RenderingRegistry.registerBlockHandler(new RenderAedifilisVapor());

}

 

 

 

 

What am I doing wrong?

 

Edit:

I noticed that in the renderer, I was dividing by 1 where I should've been dividing by 16, but fixing that changed absolutely nothing.  I figured out a workaround that involves dropping the whole custom renderer and copy-pasting the render code into an overridden setBlockBoundsBasedOnState, but that a) makes it's inventory appearance change wildly depending on the metadata of the block instance the player looked at last and b) doesn't explain why the custom renderer didn't work.

 

I'm also deeply suspicious of IBlockAccess -- the last time I tried to use it (by overriding the getBlockTexture method) didn't seem to do anything, though I had used to access the block's tile entity to determine which texture to return.  Is it possible that my downloaded forge source is messed up?  I remember back in August I somehow downloaded a version of forge for 1.3.2 that didn't have a working Language Registry.

 

 

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.

Announcements



×
×
  • Create New...

Important Information

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