QuantumLeaf7895 Posted October 24, 2012 Share Posted October 24, 2012 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.