Posted July 5, 201411 yr Hello i Was wondering how to render Items in 3d for my mod if possible an updated tutorial would be nice i have seen Ichun's video and can you please tell me what should be changed. Thanks,
July 5, 201411 yr first make sure you have a client proxy class whre yo uregister clientised rendereing stuff. it needs to be registered in the main class like this: @SidedProxy(clientSide = com.sigurd4.YourModNameHere.References.Client, serverSide = com.sigurd4.YourModNameHere.References.Common) proxy common should be like this: public class ProxyCommon { public void registerRenderInformation(){ } } make the proxy client extend proxy common just in case you were to add something there and put another registerRenderInformation and make it override. inside it you can make it call super.registerRenderInformation(). thats how you set up the proxies, but now you need to make a renderer for your item and call it in registerRenderInformation in proxyClient like this: MinecraftForgeClient.registerItemRenderer(YourMainClassHere.YourItem, new RenderYourItem()); now make your item render class and call it something like i referenced above but with your item. make use IItemRenderer as interface. first make your constructor where you make a variable be the model that you want to use. it should look something like this: public class RenderYourItem implements IItemRenderer { protected ModelYourItem model; public RenderYourItem() { model = new ModelYourItem(); } } now add this to make sure it renders only when equipped: @Override public boolean handleRenderType(ItemStack arg0, ItemRenderType arg1) { if(arg1 == ItemRenderType.EQUIPPED_FIRST_PERSON || arg1 == ItemRenderType.EQUIPPED) { return true; } else { return false; } } and add this to make sure it doesnt use the default item rendering method, but your custom model instead: @Override public boolean shouldUseRenderHelper(ItemRenderType arg0, ItemStack arg1, ItemRendererHelper arg2) { return false; } now add the part where you actually call your model and all that stuff: @Override public void renderItem(ItemRenderType arg0, ItemStack itemstack, Object... data) { if(arg0 == ItemRenderType.EQUIPPED_FIRST_PERSON || arg0 == ItemRenderType.EQUIPPED) { GL11.glPushMatrix(); //this is so you can change the size and position and rotation of your model so it fits Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("bioshock:textures/entity/weapons/pistol_rapture.png")); //the texture for your model. this is just an example. GL11.glRotatef(190F, 1.0F, 0.0F, 0.0F); //rotation (change these to what works best) GL11.glRotatef(-13F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-10F, 0.0F, 0.0F, 1.0F); if(arg0 == ItemRenderType.EQUIPPED) //because you might want it to be in a different position when in first person. { GL11.glTranslatef(0.41F, -0.4F, -0.55F); //position (change these to what works best) } else { GL11.glTranslatef(0.41F, -0.4F, -0.55F); /7these should be different from the above. } float scale = 1.1F; GL11.glScalef(scale, scale, scale); //size (change these to what works best) model.render((Entity)data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); //i seriously dont know what these number values do, but it works. GL11.glPopMatrix(); } } then make sure your model is working liek it should, cause techne has a tendancy to mess things up. this should work for 1.7.2. http://www.planetminecraft.com/member/sigurd4 I'm making the bioshock mod!
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.