Posted July 8, 201411 yr Hey, I have this setup to register a bunch of simular blocks; String[] vanillaBlocks = {"Brick", "Stone", "Stone_Brick", //all vanilla blocks}; for(int i = 0; i < vanillaBlocks.length; i++){ allLarge = new LargeColumnProperties(Material.rock).setBlockName("ModelColumn" + vanillaBlocks[i]).setHardness(20.0F).setResistance(1.0F); GameRegistry.registerBlock(allLarge, "ModelColumn" + vanillaBlocks[i]); GameRegistry.registerTileEntity(TileEntityBlock.class, "ModelColumn" + vanillaBlocks[i]); } In game I can only ever see my model in hand for the last registered block, the other blocks just the the texture colour filling the blocks inventory slot. I wouldn't have though I need to change this, but here is my hand renderer. public class HandEntityRenderer implements IItemRenderer { TileEntitySpecialRenderer render; private TileEntity entity; public HandEntityRenderer(TileEntitySpecialRenderer render, TileEntity entity) { this.entity = entity; this.render = render; } @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.entity, 0.0D, 0.0D, 0.0D, 0.0F); } } In my client proxy I have //All Large Columns TileEntitySpecialRenderer allLarge = new TileEntityRendererLargeColumn(KimptonCore.allLarge.getUnlocalizedName().substring(5), 1); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlock.class, allLarge); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(KimptonCore.allLarge), new HandEntityRenderer(allLarge, new TileEntityBlock())); Where it says, new TileEntityBlock() - I made this class empty, its pretty much a placeholder, can it only handle one block at a time? :L - All the best.
July 8, 201411 yr Author I've been playing around with the args I could put into TileEntityBlock() - Just gives me compile errors.
July 8, 201411 yr Author OK UPDATE: I've tried making loops and objects to try store the other blocks - still no further.
July 9, 201411 yr Author Could you try explain it and tell me where I would want to implement this; because I never call to that object in my code..?
July 9, 201411 yr 1. Why do you use IItemRenderer instead of TileEntitySpecialRenderer? 2. To have TileEntity block must extend BlockContainer and have function @Override public TileEntity createNewTileEntity(World world, int i) { return new TileEntityBlock(); } 3. Also you should register your TileEntityBlock GameRegistry.registerTileEntity(TileEntityBlock.class, "tileEntityBlock"); 4. What do you want to do?
July 9, 201411 yr Author I actually don't know - I was taught how todo this by a friend ''this is how all modders do this'' he says. So if you were me, you'd rewrite your client proxy? Ha?
July 9, 201411 yr Author http://gyazo.com/4dbbf53279b0a9213f1d9c382c6d76df Here you can see the problem visually. Both of these blocks are registered here: String[] vanillaBlocks = new String[]{ "Stone", "Brick" //all blocks I want }; for(int i = 0; i < vanillaBlocks.length; i++){ allLarge = new LargeColumnProperties(Material.rock).setBlockName("ModelColumn" + vanillaBlocks[i]).setHardness(20.0F).setResistance(1.0F); GameRegistry.registerBlock(allLarge, "ModelColumn" + vanillaBlocks[i]); GameRegistry.registerTileEntity(TileEntityBlock.class, "ModelColumn" + vanillaBlocks[i]); } in my client proxy to register the icon I have: @Override public void renderInfomation(){ /* Tile Entity Renderer Columns : * INDEX * 1 = ModelLargeColumn * 2 = ModelMediumColumn * 3 = ModelSmallColumn */ //All Large Columns TileEntitySpecialRenderer allLarge = new TileEntityRendererLargeColumn(KimptonCore.allLarge.getUnlocalizedName().substring(5), 1); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlock.class, allLarge); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(KimptonCore.allLarge), new HandEntityRenderer(allLarge, new TileEntityBlock())); } and in my HandEntityRenderer I have: public class HandEntityRenderer implements IItemRenderer { TileEntitySpecialRenderer render; private TileEntity entity; public HandEntityRenderer(TileEntitySpecialRenderer render, TileEntity entity) { this.entity = entity; this.render = render; } @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.entity, 0.0D, 0.0D, 0.0D, 0.0F); } } THIS CODE DOESNT DO ANYTHING FOR MY PROBLEM BUT YOU MENTIONED IT Here is my special renderer: public class TileEntityRendererLargeColumn extends TileEntitySpecialRenderer{ private ModelLargeColumn model; private ResourceLocation texture; public TileEntityRendererLargeColumn(String name, int x){ switch (x){ case 1: model = new ModelLargeColumn(); break; case 2: model = new ModelLargeColumn(); break; } this.texture = new ResourceLocation(KimptonCore.modid + ":" + "/textures/blocks/" + name + ".png"); } @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f){ //Open GL open with PUSH and close with POP GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glRotatef(180, 0F, 0F, 1F); this.bindTexture(texture); GL11.glPushMatrix(); this.model.renderModel(0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } } and I have registered my Tile Entity in my loop at the top
July 9, 201411 yr Dude, you can't register a tile entity class more than once. Having it in this loop is pointless. Registering more than one block when you have a tileentity is also horribly redundant. Either register one block with its tileentity, or register your bunch of blocks with no tileentity. You also failed to understand that "KimptonCore.allLarge" can only contain one block instance, not all of the blocks you made.
July 9, 201411 yr Author So you're saying If I want this automation - I'd lose all nice rendering inhand? aha? hmm... That's upsetting - the alternative seems like alot of writing haha!
July 10, 201411 yr If you don't need special functionality, and you don't need to store more than 4 bits of data for the block, you may as well look into implementing [url=http://www.minecraftforge.net/wiki/ISimpleBlockRenderingHandler]ISimpleBlockRenderingHandler[/url] , and registering the implemented class with the RenderingRegistry . This way, you can have several blocks using the same BlockRenderingHandler without resorting to a TileEntitySpecialRenderer , and avoiding code duplication. If I recall correctly, registered ISimpleBlockRenderingHandler s are also cached, improving performance over a TileEntitySpecialRenderer. I might be wrong, there, though. Either way, it sounds like an ISimpleBlockRenderingHandler will suffice in your use case. Enjoy
July 11, 201411 yr Author Hey using ISimpleBlockRenderingHandler - I have to remodel my model? I've made my model in techne... and it spits the code out in a format that isn't tessellator - or can tessellators import techne models?
July 11, 201411 yr I don't know what Techne spits out, but it should be simple to convert it to use tessellators. Failing that, you can call Tessellator.instance.draw() in the beginning of your method, and Tessellator.instance.startDrawingQuads() in the end. Using the tessellator would be preferred though, I think. Keep in mind the texture atlas containing the icon you set for the block is bound. If it's a static block with a single simple texture, though, I don't see why you wouldn't want to just use the tessellator in an ISimpleBlockRenderingHandler.
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.