Two Posted December 19, 2013 Posted December 19, 2013 Hi everyone, I am currently trying to add a new block - a lava tank - that keeps the fuel amount when picked up. So far I have been successful with almost everything, except for properly creating an item that tracks the fuel limit but is rendered as the block at the same time. I can obviously write my own renderer, but why do that if one already exists and is much more upward-compatible? What I have tried so far: My first attempt was to use the ItemBlockWithMetadata item, which works except for the inaccurate storage, but Forge complains that this anonymous item class will not survive a 1.7 update. I tried to create my own ItemBlock sub-class, which works fine, except that the item is now rendered flat instead of the 3d block look. I tried to use ItemBlockWithMetadata and register it with the block, but now Forge obviously complains that I am overwriting an existing block. Could someone please give me a hint how I can do this properly, or if possible a short tutorial (for experienced programmers)? Thanks in advance! Edit: Thanks to Draco18s this was solved in the following way: [*]Created a sub-class of ItemBlockWithMetadata that forwards getIcon(side, metadata) to the same block function [*]Added a new renderer. (Basically a copy of this tutorial) [*]Registered item with renderer in ProxyClient: itemRendererBlock3d = new ItemRendererBlock3d(); MinecraftForgeClient.registerItemRenderer(itemLavaTank.itemID, itemRendererBlock3d); Quote My Mods New Dawn - A completely new terrain engine for Minecraft TwoTility - Blocks and Items for a better Minecraft TwoGraves - Keeps your items safe on death
Draco18s Posted December 19, 2013 Posted December 19, 2013 Look at ItemRedstone and BlockRedstoneWire Quote 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.
Two Posted December 19, 2013 Author Posted December 19, 2013 Look at ItemRedstone and BlockRedstoneWire I am not sure how this is supposed to help me. The Redstone ore/wire renders as an item in the inventory and not as a block. This is what I already got with my 2nd attempt, but I do want the icon in the inventory to render as the 3D-block. Quote My Mods New Dawn - A completely new terrain engine for Minecraft TwoTility - Blocks and Items for a better Minecraft TwoGraves - Keeps your items safe on death
Draco18s Posted December 19, 2013 Posted December 19, 2013 Ah, rendering problem. You need a custom IItemRenderer Here's an example: public class ItemRenderPedestal implements IItemRenderer { TileEntitySpecialRenderer render; private TileEntity dummytile; public ItemRenderPedestal(TileEntitySpecialRenderer render, TileEntity dummy) { this.render = render; this.dummytile = dummy; } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return true; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { if (type == IItemRenderer.ItemRenderType.ENTITY) GL11.glTranslatef(-0.5F, 0.0F, -0.5F); this.render.renderTileEntityAt(this.dummytile, 0.0D, 0.0D, 0.0D, 0.0F); } } And client prox registration: TileEntitySpecialRenderer render = new PedestalRenderer(); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDisplayPedestal.class, render); MinecraftForgeClient.registerItemRenderer(BlockPedestal.instance.blockID, new ItemRenderPedestal(render, new TileEntityDisplayPedestal())); Quote 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.
luisc99 Posted December 19, 2013 Posted December 19, 2013 Will the inventory item show the liquid in it? If not can't you just make the texture icon one that looks like a block? Quote
Two Posted December 19, 2013 Author Posted December 19, 2013 Ah, rendering problem. You need a custom IItemRenderer Just before I start some probably unnecessary work: If I understand you correctly, I need to implement my own renderer to get a block to render like a block, and there is no way I can use the already existing rendering code for blocks from Minecraft (except for copy&paste), just because I must use my own item so the block retains the meta value if dropped, correct? Quote My Mods New Dawn - A completely new terrain engine for Minecraft TwoTility - Blocks and Items for a better Minecraft TwoGraves - Keeps your items safe on death
Draco18s Posted December 19, 2013 Posted December 19, 2013 Because your inventory item is of Class Item, you need to implement an IItemRenderer to override the default 2D item renderer. Quote 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.
Two Posted December 19, 2013 Author Posted December 19, 2013 Awww... crap! Thanks! Quote My Mods New Dawn - A completely new terrain engine for Minecraft TwoTility - Blocks and Items for a better Minecraft TwoGraves - Keeps your items safe on death
Draco18s Posted December 19, 2013 Posted December 19, 2013 Its not hard. Annoying sure, but not hard. Quote 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.
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.