Posted July 17, 201411 yr So I cant seem to get my 3D block model to display whilst holding a block. Ive followed a lot of 1.7.2 guides (couldnt find any 1.7.10 ones) and it dosnt seem to work. I have a 2d image to display in the hand but not the render for the block. Im not too good at explaining. So to cut to the chase, I want my block called an Endite reactor to display in my hand as the 3d model it has when placed in the game. Here is my code: Client Proxy: package main; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.Item; import net.minecraftforge.client.MinecraftForgeClient; import renderer.ItemRenderEnditeReactor; import renderer.RenderEnditeReactor; import tileentity.TileEntityEnditeReactor; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; public class ClientProxy extends ServerProxy { public void registerRenderThings() { //EnditeReactor TileEntitySpecialRenderer render = new RenderEnditeReactor(); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEnditeReactor.class, render); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RunicScrolls.blockEnditeReactor), new ItemRenderEnditeReactor(render, new TileEntityEnditeReactor())); } public int addArmor(String armor) { return RenderingRegistry.addNewArmourRendererPrefix(armor); } } Block Class : package blocks; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import tileentity.TileEntityEnditeReactor; import main.RunicScrolls; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BlockEnditeReactor extends BlockContainer{ public BlockEnditeReactor() { super(Material.iron); } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new TileEntityEnditeReactor(); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(RunicScrolls.modid + ":" + this.getUnlocalizedName().substring(5)); } } Model Class: package model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelBlockEnditeReactor extends ModelBase { //fields ModelRenderer stand1; ModelRenderer stand2; ModelRenderer stand3; ModelRenderer stand4; ModelRenderer topdetail; ModelRenderer top; ModelRenderer centre; ModelRenderer bottom; public ModelBlockEnditeReactor() { textureWidth = 64; textureHeight = 128; stand1 = new ModelRenderer(this, 25, 31); stand1.addBox(0F, 0F, 0F, 1, 12, 1); stand1.setRotationPoint(-6F, 10F, 5F); stand1.setTextureSize(64, 128); stand1.mirror = true; setRotation(stand1, 0F, 0F, 0F); stand2 = new ModelRenderer(this, 30, 31); stand2.addBox(0F, 0F, 0F, 1, 12, 1); stand2.setRotationPoint(-6F, 10F, -6F); stand2.setTextureSize(64, 128); stand2.mirror = true; setRotation(stand2, 0F, 0F, 0F); stand3 = new ModelRenderer(this, 35, 31); stand3.addBox(0F, 0F, 0F, 1, 12, 1); stand3.setRotationPoint(5F, 10F, -6F); stand3.setTextureSize(64, 128); stand3.mirror = true; setRotation(stand3, 0F, 0F, 0F); stand4 = new ModelRenderer(this, 40, 31); stand4.addBox(0F, 0F, 0F, 1, 12, 1); stand4.setRotationPoint(5F, 10F, 5F); stand4.setTextureSize(64, 128); stand4.mirror = true; setRotation(stand4, 0F, 0F, 0F); topdetail = new ModelRenderer(this, 0, 0); topdetail.addBox(0F, 0F, 0F, 12, 1, 12); topdetail.setRotationPoint(-6F, 7F, -6F); topdetail.setTextureSize(64, 128); topdetail.mirror = true; setRotation(topdetail, 0F, 0F, 0F); top = new ModelRenderer(this, 0, 14); top.addBox(0F, 0F, 0F, 14, 2, 14); top.setRotationPoint(-7F, 8F, -7F); top.setTextureSize(64, 128); top.mirror = true; setRotation(top, 0F, 0F, 0F); centre = new ModelRenderer(this, 0, 31); centre.addBox(0F, 0F, 0F, 6, 12, 6); centre.setRotationPoint(-3F, 10F, -3F); centre.setTextureSize(64, 128); centre.mirror = true; setRotation(centre, 0F, 0F, 0F); bottom = new ModelRenderer(this, 0, 50); bottom.addBox(0F, 0F, 0F, 14, 2, 14); bottom.setRotationPoint(-7F, 22F, -7F); bottom.setTextureSize(64, 128); bottom.mirror = true; setRotation(bottom, 0F, 0F, 0F); } public void render() { float r = 0.0625F; stand1.render®; stand2.render®; stand3.render®; stand4.render®; topdetail.render®; top.render®; centre.render®; bottom.render®; } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } public void renderModel(float f) { stand1.render(f); stand2.render(f); stand3.render(f); stand4.render(f); topdetail.render(f); top.render(f); centre.render(f); bottom.render(f); } } Item Render: package renderer; import org.lwjgl.opengl.GL11; import model.ModelBlockEnditeReactor; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.client.IItemRenderer; public class ItemRenderEnditeReactor implements IItemRenderer { TileEntitySpecialRenderer render; TileEntity entity; public ItemRenderEnditeReactor(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) { float scale = 1.0F; GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 4.0F); switch(type){ case EQUIPPED: scale = 1.5F; GL11.glScalef(scale, scale, scale); GL11.glTranslatef(-0.6F, -1.0F, 0.4F); //Sets where the model is placed (you can mess around with this to suit you) break; case ENTITY: scale = 3.0F; GL11.glScalef(scale, scale, scale); GL11.glTranslatef(0.0F, -1.5F, 0.0F); break; case INVENTORY: scale = 0.8F; GL11.glScalef(scale, scale, scale); GL11.glTranslatef(0.0F, -0.5F, 0.0F); break; case EQUIPPED_FIRST_PERSON: scale = 1.5F; GL11.glScalef(scale, scale, scale); GL11.glTranslatef(0.0F, -1.0F, 0.4F); break; default: break; } new ModelBlockEnditeReactor().render(); GL11.glPopMatrix(); } } Render Class: package renderer; import org.lwjgl.opengl.GL11; import main.RunicScrolls; import model.ModelBlockEnditeReactor; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; public class RenderEnditeReactor extends TileEntitySpecialRenderer { private static final ResourceLocation texture = new ResourceLocation(RunicScrolls.modid + ":" + "textures/model/BlockEnditeReactor.png"); private ModelBlockEnditeReactor model; public RenderEnditeReactor() { this.model = new ModelBlockEnditeReactor(); } @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { 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(); } } Tile Entity: package tileentity; import net.minecraft.tileentity.TileEntity; public class TileEntityEnditeReactor extends TileEntity { } There are no errors in eclipse and the block works fine. I just cant get it to display in my hand. I have probably just made some stupid mistake but im not seeing it. This is also my first time doing 3d modelling so im new to it. Here is an image to to show what is happening. Thanks for helping -iLegendx98
July 17, 201411 yr Hi This link might help explain some of the background concepts; see the Item Rendering sections http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html Your code wouldn't work in 1.7.2 anyway, it is missing several things. For example this- what happens if render type is EQUIPPED_BLOCK? @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); } -TGG
July 18, 201411 yr You also need to render the model. For an item or a block model, i always make a new render(float r) method, then make all the model componates render it, make the r = 0.0652F (i think, thats just off my head) then call that method inside your item renderer Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods
July 18, 201411 yr Author Would you be able to be more specific, maybe some example code. I am really new to this and a lot of what I have tried dosn't work.
July 18, 201411 yr The code from this in the model class: public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { setRotationAngles(f, f1, f2, f3, f4, f5, entity); part.render(f5); par1.render(f5); par3.render(f5); } make a new method: public void render(){ float r = 0.0625F; part.render(r); par1.render(r); par3.render(r); } and in the ItemRenderer class that you made float scale = 1.0F; GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 4.0F); switch(type){ case EQUIPPED: scale = 1.5F; GL11.glScalef(scale, scale, scale); GL11.glTranslatef(-0.6F, -1.0F, 0.4F); //Sets where the model is placed (you can mess around with this to suit you) break; case ENTITY: scale = 3.0F; GL11.glScalef(scale, scale, scale); GL11.glTranslatef(0.0F, -1.5F, 0.0F); break; case INVENTORY: scale = 0.8F; GL11.glScalef(scale, scale, scale); GL11.glTranslatef(0.0F, -0.5F, 0.0F); break; case EQUIPPED_FIRST_PERSON: scale = 1.5F; GL11.glScalef(scale, scale, scale); GL11.glTranslatef(0.0F, -1.0F, 0.4F); break; default: break; } new ModelYourBlock().render(); GL11.glPopMatrix(); the switch statement is from my item render code and it goes in this method: @Override public void renderItem(ItemRenderType type, ItemStack i, Object...data) That should be all you need Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods
July 18, 201411 yr Author Ive done what you said and it still isnt working. I could maybe be missing something in my main. Is there any thing that has to go in there in relation to the render. I have the block registry in there and stuff to do with the proxies. I havent had to register anything like render classes, maybe thats it? I have updated my post with my current code after modifying it.
July 18, 201411 yr TileEntityRendererDispatcher.instance.renderTileEntityAt(new YourTileEntity(), 0.0D, 0.0D, 0.0D, 0.0F); Example: https://github.com/KeeperofMee/Survival/blob/master/com/keeperofmee/survival/renderers/ItemRenderGroundStone.java If I helped please press the Thank You button.
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.