Posted May 16, 201411 yr I have created a custom modelled mob. I wanted it to have a item equipped. (a sword) So I grabbed the renderEquippedItems methode from the renderplayer and modified it. It works all fine, but there is one problem. This: Every time I spawn my mob, a sword will render above the player. This will be a cpu load, because every mob is a extra render, because it renders in first person too (just a little) This is the renderer code: public class RenderGoblin extends RenderLiving { protected ModelGoblin model; public RenderGoblin (ModelGoblin modelTutorial, float f) { super(modelTutorial, f); model = ((ModelGoblin)mainModel); } public void renderGo(EntityGoblin entity, double par2, double par4, double par6, float par8, float par9) { super.doRender(entity, par2, par4, par6, par8, par9); this.renderEquippedItems(entity, 1.0F); this.model.heldItem = entity.getHeldItem() != null ? 1 : 0; } public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) { renderGo((EntityGoblin)par1EntityLiving, par2, par4, par6, par8, par9); } public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { renderGo((EntityGoblin)par1Entity, par2, par4, par6, par8, par9); } @Override protected ResourceLocation getEntityTexture(Entity var1) { return new ResourceLocation("agecraft" + ":textures/entities/" + "Goblin" + ".png"); } protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2) { GL11.glColor3f(1.0F, 1.0F, 1.0F); super.renderEquippedItems(par1EntityLiving, par2); ItemStack itemstack = par1EntityLiving.getHeldItem(); Item item; float f1; if (itemstack != null && itemstack.getItem() != null) { item = itemstack.getItem(); GL11.glPushMatrix(); this.model.rightarm.postRender(0.0625F); GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F); if (item.isFull3D()) { f1 = 0.625F; if (item.shouldRotateAroundWhenRendering()) { GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -0.125F, 0.0F); } this.func_82422_c(); GL11.glScalef(f1, -f1, f1); GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); } else { f1 = 0.375F; GL11.glTranslatef(0.25F, 0.1875F, -0.1875F); GL11.glScalef(f1, f1, f1); GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); } float f2; float f3; int i; if (itemstack.getItem().requiresMultipleRenderPasses()) { for (i = 0; i < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++i) { int j = itemstack.getItem().getColorFromItemStack(itemstack, i); f2 = (float)(j >> 16 & 255) / 255.0F; f3 = (float)(j >> 8 & 255) / 255.0F; float f4 = (float)(j & 255) / 255.0F; GL11.glColor4f(f2, f3, f4, 1.0F); this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, i); } } else { i = itemstack.getItem().getColorFromItemStack(itemstack, 0); float f5 = (float)(i >> 16 & 255) / 255.0F; f2 = (float)(i >> 8 & 255) / 255.0F; f3 = (float)(i & 255) / 255.0F; GL11.glColor4f(f5, f2, f3, 1.0F); this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, 0); } GL11.glPopMatrix(); } } protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) { this.renderEquippedItems((EntityLiving)par1EntityLivingBase, par2); } protected void func_82422_c() { GL11.glTranslatef(0.0F, 0.1875F, 0.0F); } } Coding, Testing, Smiling, Publishing!
May 17, 201411 yr Author Tried several thing, but all failed. One thing left to do: BUMP Coding, Testing, Smiling, Publishing!
May 18, 201411 yr You can find the correct snippet in RenderWitch. You would have to fiddle around with the rotation and position of the rendered item though.
May 20, 201411 yr Author You can find the correct snippet in RenderWitch. You would have to fiddle around with the rotation and position of the rendered item though. It is rendering correctly, I don't know why it is rendering above my player. that must not be! Coding, Testing, Smiling, Publishing!
May 20, 201411 yr Here.. Mess around with the opengl to make the items fit to your liking. protected void renderEquippedItems(EntityClayGolem par1EntityClayGolem, float par2) { GL11.glColor3f(1.0F, 1.0F, 1.0F); super.renderEquippedItems(par1EntityClayGolem, par2); ItemStack itemstack = par1EntityClayGolem.getHeldItem(); if (itemstack != null) { GL11.glPushMatrix(); float f1; if (this.mainModel.isChild) { f1 = 0.5F; GL11.glTranslatef(0.0F, 0.625F, 0.0F); GL11.glRotatef(-20.0F, -1.0F, 0.0F, 0.0F); GL11.glScalef(f1, f1, f1); } this.claygolemModel.GolemRightArm.postRender(0.0625F);//.villagerNose.postRender(0.0625F); GL11.glTranslatef(-0.2625F, 1.33125F, 0.61875F); if (itemstack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType())) { f1 = 0.5F; GL11.glTranslatef(-0.0451F, 0.0425F, -0.1125F); f1 *= 0.75F; GL11.glRotatef(60.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(145.0F, 0.0F, 100.0F, 0.0F); GL11.glScalef(f1, -f1, f1); } else if (itemstack.getItem() == Items.bow) { f1 = 0.625F; GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(f1, -f1, f1); GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); // GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); } else if (itemstack.getItem().isFull3D()) { f1 = 0.625F; if (itemstack.getItem().shouldRotateAroundWhenRendering()) { GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -0.125F, 0.0F); } GL11.glTranslatef(0.0F, 0.1875F, 0.0F); GL11.glScalef(f1, -f1, f1); GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); } else { f1 = 0.375F; GL11.glTranslatef(0.1F, 0.1875F, -0.1875F); GL11.glScalef(f1, f1, f1); GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); } //GL11.glRotatef(-15.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(40.0F, 0.0F, 0.0F, 1.0F); this.renderManager.itemRenderer.renderItem(par1EntityClayGolem, itemstack, 0); if (itemstack.getItem().requiresMultipleRenderPasses()) { this.renderManager.itemRenderer.renderItem(par1EntityClayGolem, itemstack, 1); } GL11.glPopMatrix(); } } protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) { this.renderEquippedItems((EntityClayGolem)par1EntityLivingBase, par2); }
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.