/** * Compiles a GL display list for this model */ @SideOnly(Side.CLIENT) protected void compileDisplayList(float scale) { this.displayList = GLAllocation.generateDisplayLists(1); GlStateManager.glNewList(this.displayList, 4864); VertexBuffer vertexbuffer = Tessellator.getInstance().getBuffer(); for (int i = 0; i < this.cubeList.size(); ++i) { ((ModelBox) this.cubeList.get(i)).render(vertexbuffer, scale); } GlStateManager.glEndList(); this.compiled = true; }
public ModelToolRack() { upperStrip = new ModelRendererVC(this); lowerStrip = new ModelRendererVC(this); upperStrip.cubeList.add(new ModelBox(upperStrip, 0, 0, 0F, 8, 0.1F, 32, 3, 2, 0)); lowerStrip.cubeList.add(new ModelBox(upperStrip, 0, 4, 0F, 24, 0.1F, 32, 3, 2, 0)); for (int i = 0; i < nails.length; i++) { nails[i] = new ModelRendererVC(this); nails[i].cubeList.add(new ModelBox(upperStrip, 0, 0, (i % 2 > 0) ? 3 : 27, // x (i > 1) ? 9 : 25, // y 2, // z 1, 1, 1, 0)); } }
void initFillMaterial(int height) { fillmaterial = new ModelRendererVC(this); fillmaterial.cubeList.add(new ModelBox(fillmaterial, 0, 0, stoneWallPadding + stoneWallThickness, // x stoneWallThickness, // y stoneWallPadding + stoneWallThickness, // z stoneWallWidth - stoneWallThickness, // width height * scale, // height stoneWallWidth - stoneWallThickness, // length 0 )); fillmaterialheight = height; }
public HeraldryArmourModel(EntityEquipmentSlot par1) { super(par1==EntityEquipmentSlot.LEGS ? 0.4F : 1F); this.armourSlot = par1; bipedHeadwear.cubeList.clear(); if(armourSlot == EntityEquipmentSlot.LEGS){ //bipedRightLeg = bipedRightLeg.setTextureOffset(40, 16); bipedRightLeg.cubeList.clear(); bipedRightLeg.setTextureOffset(40, 16); bipedRightLeg.mirror = true; List<ModelBox> legBoxlist = bipedLeftLeg.cubeList; for (ModelBox modelBox : legBoxlist) { bipedRightLeg.addBox(modelBox.posX1, modelBox.posY1, modelBox.posZ1, (int)(modelBox.posX2 - modelBox.posX1), (int)(modelBox.posY2 - modelBox.posY1), (int)(modelBox.posZ2 - modelBox.posZ1)); } } }
/** * Compiles a GL display list for this model */ @SideOnly(Side.CLIENT) private void compileDisplayList(float par1) { this.displayList = GLAllocation.generateDisplayLists(1); GL11.glNewList(this.displayList, GL11.GL_COMPILE); Tessellator var2 = Tessellator.instance; for (int var3 = 0; var3 < this.cubeList.size(); ++var3) { ((ModelBox) this.cubeList.get(var3)).render(var2, par1); } for(int i = 0; i < this.objs.size(); i++){ this.objs.get(i).render(par1); } GL11.glEndList(); this.compiled = true; }
@SideOnly(Side.CLIENT) private void compileDisplayList(float par1) { this.displayList = GLAllocation.generateDisplayLists(1); GL11.glNewList(this.displayList, GL11.GL_COMPILE); Tessellator tessellator = Tessellator.instance; for (int i = 0; i < this.cubeList.size(); ++i) { ((ModelBox) this.cubeList.get(i)).render(tessellator, par1); } GL11.glEndList(); this.compiled = true; }
/** * Compute model size based on the box in the model renderer */ private int[] getModelSize(ModelBox box) { int w = (int) (box.posX2 - box.posX1); int h = (int) (box.posY2 - box.posY1); int d = (int) (box.posZ2 - box.posZ1); return new int[] {w, h, d}; }
/** * Compute anchor based on the renderer */ private float[] getAnchor(ModelBox box, int[] size) { float w = size[0] != 0 ? -box.posX1 / size[0] : 0; float h = size[1] != 0 ? -box.posY1 / size[1] : 0; float d = size[2] != 0 ? -box.posZ1 / size[2] : 0; return new float[] {w, h, d}; }
/** * Compiles a GL display list for this model. * EDITED VERSION BECAUSE OF THE PRIVATE FIELDS */ public void DDScompileDisplayList(float par1) { this.DDSdisplayList = GLAllocation.generateDisplayLists(1); GL11.glNewList(this.DDSdisplayList, GL11.GL_COMPILE); Tessellator tessellator = Tessellator.instance; for (int i = 0; i < this.cubeList.size(); ++i) { ((ModelBox)this.cubeList.get(i)).render(tessellator, par1); } GL11.glEndList(); this.DDScompiled = true; }
public ModelTopBox(ModelRenderer p_i1171_1_, int p_i1171_2_, int p_i1171_3_, float p_i1171_4_, float p_i1171_5_, float p_i1171_6_, float p_i1171_7_, float p_i1171_8_, float p_i1171_9_, float p_i1171_10_) { super(p_i1171_1_, p_i1171_2_, p_i1171_3_, p_i1171_4_, p_i1171_5_, p_i1171_6_, (int) p_i1171_7_, (int) p_i1171_8_, (int) p_i1171_9_, p_i1171_10_); try{ Field field = ModelBox.class.getDeclaredField("quadList"); quads = (TexturedQuad[]) field.get(this); } catch(Throwable th){ th.printStackTrace(); } }
@SuppressWarnings("unchecked") public ModelPart addBox(int u, int v, float xOffset, float yOffset, float zOffset, int width, int height, int depth, float scale) { cubeList.add(new ModelBox(this, u, v, xOffset, yOffset, zOffset, width, height, depth, scale)); return this; }
public void initComponents() { hori = new ModelRendererVC(this); // vert = new ModelRendererVC(this); support = new ModelRendererVC(this); // x1 y1 z1 wdt hgt depth scalechange hori.cubeList.add(new ModelBox(hori, 0, 0, 14f, 12f, 0F, 4, 8, 32, 0)); hori.cubeList.add(new ModelBox(hori, 0, 0, 12f, 14f, 0.05F, 8, 4, 32, 0)); //vert.cubeList.add(new ModelBox(hori, 0, 0, 12f, 14f, 0.05F, 8, 4, 32, 0)); support.cubeList.add(new ModelBox(support, 0, 0, 10F, 0f, 4F, 12, 24, 2, 0)); }
public void initComponents() { fireclayMolds = new ModelRendererVC(this); ingots = new ModelRendererVC(this); canal = new ModelRendererVC(this); furnaceHole = new ModelRendererVC(this); // x1 y1 z1 wdt hgt depth scalechange // hori.cubeList.add(new ModelBox(hori, 0, 0, 14f, 12f, 0F, 4, 8, 32, 0)); // Base fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 0f, 0f, 0f, 32, 24, 32, 0)); // Left border fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 0f, 24f, 0f, 4, 6, 32, 0)); // Right border fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 28f, 24f, 0f, 4, 6, 32, 0)); // Bottom border fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 4f, 24f, 28f, 24, 6, 4, 0)); // Topleft border fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 4f, 24f, 0f, 10, 6, 4, 0)); // Topright border fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 18f, 24f, 0f, 10, 6, 4, 0)); // Seperator 1 right fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 18f, 24f, 10.5f, 10, 6, 2, 0)); // Seperator 2 right fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 18f, 24f, 19f, 10, 6, 2, 0)); // Seperator 1 left fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 4f, 24f, 10.5f, 10, 6, 2, 0)); // Seperator 2 left fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 4f, 24f, 19f, 10, 6, 2, 0)); // Canal fireclayMolds.cubeList.add(new ModelBox(fireclayMolds, 0, 0, 14f, 24f, 0f, 4, 5, 28, 0)); canal.cubeList.add(new ModelBox(canal, 0, 0, 14f, 29f, 0f, 4, 1, 28, 0)); furnaceHole.cubeList.add(new ModelBox(furnaceHole, 0, 0, 12f, 32f, -6f, 8, 8, 7, 0)); ingots.cubeList.add(new ModelBox(ingots, 0, 0, 4f, 24f, 4f, 24, 5, 24, 0)); }
public void initComponents() { base = new ModelRendererVC(this); // x1 y1 z1 wdt hgt detph scalechange base.cubeList.add(new ModelBox(base, 0, 0, 8F, 8f, 0F, 16, 16, 2, 0)); for (int i = 0; i < pegs.length; i++) { pegs[i] = new ModelRendererVC(this); } pegs[0].cubeList.add(new ModelBox(pegs[0], 0, 0, 8F + 0.5f, 8f + 0.5f, 1F, 2, 2, 8, 0)); pegs[1].cubeList.add(new ModelBox(pegs[1], 0, 0, 8F + 13.5f, 8f + 0.5f, 1F, 2, 2, 8, 0)); pegs[2].cubeList.add(new ModelBox(pegs[2], 0, 0, 8F + 0.5f, 8f + 13.5f, 1F, 2, 2, 8, 0)); pegs[3].cubeList.add(new ModelBox(pegs[3], 0, 0, 8F + 13.5f, 8f + 13.5f, 1F, 2, 2, 8, 0)); }
public ModelVessel() { boxes = new ModelRendererVC[boxSizes.length]; int bottom = 0; for (int i = 0; i < boxSizes.length; i++) { boxes[i] = new ModelRendererVC(this); float wdt = boxSizes[i][0]; float hgt = boxSizes[i][1]; float left = 32 - wdt; boxes[i].cubeList.add(new ModelBox(boxes[i], 0, (int) hgt, left / 2, 22 - bottom - hgt, left/ 2, (int)wdt, (int)hgt, (int)wdt, 0)); bottom += hgt; } }
public void initComponents() { // x1 y1 z1 wdt hgt depth scalechange woodCover = new ModelRendererVC(this); leather = new ModelRendererVC(this); ironTipAndTuyere = new ModelRendererVC(this); gearBase = new ModelRendererVC(this); gearPegs = new ModelRendererVC(this); woodCover.cubeList.add(new ModelBox(woodCover, 0, 0, 2f, 0f, 2f, 28, 2, 28, 0)); // Leather Base leather.cubeList.add(new ModelBox(leather, 0, 0, 4f, 2f, 4f, 24, 24, 24, 0)); // Leather lower fold leather.cubeList.add(new ModelBox(leather, 0, 0, 2f, 10f, 2f, 28, 2, 28, 0)); // Leather upper fold leather.cubeList.add(new ModelBox(leather, 0, 0, 2f, 20f, 2f, 28, 2, 28, 0)); // x1 y1 z1 wdt hgt detph scalechange gearBase.cubeList.add(new ModelBox(gearBase, 0, 0, 5F, 5f, 0F, 22, 22, 2, 0)); gearPegs.cubeList.add(new ModelBox(gearPegs, 0, 0, 9F + 0.5f, 9f + 0.5f, 1F, 2, 2, 4, 0)); ironTipAndTuyere.cubeList.add(new ModelBox(ironTipAndTuyere, 16, 0, 13f, 1, 0, 6, 6, 58, 0)); ironTipAndTuyere.cubeList.add(new ModelBox(ironTipAndTuyere, 0, 0, 12f, 0, 0, 8, 8, 6, 0)); }
protected void func_85093_e(EntityLivingBase p_85093_1_, float p_85093_2_) { int var3 = p_85093_1_.func_85035_bI(); if(var3 > 0) { EntityArrow var4 = new EntityArrow(p_85093_1_.field_70170_p, p_85093_1_.field_70165_t, p_85093_1_.field_70163_u, p_85093_1_.field_70161_v); Random var5 = new Random((long)p_85093_1_.field_70157_k); RenderHelper.func_74518_a(); for(int var6 = 0; var6 < var3; ++var6) { GL11.glPushMatrix(); ModelRenderer var7 = this.field_77045_g.func_85181_a(var5); ModelBox var8 = (ModelBox)var7.field_78804_l.get(var5.nextInt(var7.field_78804_l.size())); var7.func_78794_c(0.0625F); float var9 = var5.nextFloat(); float var10 = var5.nextFloat(); float var11 = var5.nextFloat(); float var12 = (var8.field_78252_a + (var8.field_78248_d - var8.field_78252_a) * var9) / 16.0F; float var13 = (var8.field_78250_b + (var8.field_78249_e - var8.field_78250_b) * var10) / 16.0F; float var14 = (var8.field_78251_c + (var8.field_78246_f - var8.field_78251_c) * var11) / 16.0F; GL11.glTranslatef(var12, var13, var14); var9 = var9 * 2.0F - 1.0F; var10 = var10 * 2.0F - 1.0F; var11 = var11 * 2.0F - 1.0F; var9 *= -1.0F; var10 *= -1.0F; var11 *= -1.0F; float var15 = MathHelper.func_76129_c(var9 * var9 + var11 * var11); var4.field_70126_B = var4.field_70177_z = (float)(Math.atan2((double)var9, (double)var11) * 180.0D / 3.1415927410125732D); var4.field_70127_C = var4.field_70125_A = (float)(Math.atan2((double)var10, (double)var15) * 180.0D / 3.1415927410125732D); double var16 = 0.0D; double var18 = 0.0D; double var20 = 0.0D; float var22 = 0.0F; this.field_76990_c.func_78719_a(var4, var16, var18, var20, var22, p_85093_2_); GL11.glPopMatrix(); } RenderHelper.func_74519_b(); } }
public ModelRenderer func_78786_a(String p_78786_1_, float p_78786_2_, float p_78786_3_, float p_78786_4_, int p_78786_5_, int p_78786_6_, int p_78786_7_) { p_78786_1_ = this.field_78802_n + "." + p_78786_1_; TextureOffset var8 = this.field_78810_s.func_78084_a(p_78786_1_); this.func_78784_a(var8.field_78783_a, var8.field_78782_b); this.field_78804_l.add((new ModelBox(this, this.field_78803_o, this.field_78813_p, p_78786_2_, p_78786_3_, p_78786_4_, p_78786_5_, p_78786_6_, p_78786_7_, 0.0F)).func_78244_a(p_78786_1_)); return this; }
private void func_78788_d(float p_78788_1_) { this.field_78811_r = GLAllocation.func_74526_a(1); GL11.glNewList(this.field_78811_r, 4864); Tessellator var2 = Tessellator.field_78398_a; for(int var3 = 0; var3 < this.field_78804_l.size(); ++var3) { ((ModelBox)this.field_78804_l.get(var3)).func_78245_a(var2, p_78788_1_); } GL11.glEndList(); this.field_78812_q = true; }
public static void createEmptyContents(ModelBase base, ModelRenderer ori, ModelRenderer copy, int depth) { if(depth > 20) { return; } if(copy.cubeList.size() < ori.cubeList.size()) { for(int j = copy.cubeList.size(); j < ori.cubeList.size(); j++) { ModelBox box = (ModelBox)ori.cubeList.get(j); float param7 = 0.0F; ModelBox randBox = (ModelBox)ori.cubeList.get(rand.nextInt(ori.cubeList.size())); float x = randBox.posX1 + ((randBox.posX2 - randBox.posX1) > 0F ? rand.nextInt(((int)(randBox.posX2 - randBox.posX1) > 0) ? (int)(randBox.posX2 - randBox.posX1) : 1) : 0F); float y = randBox.posY1 + ((randBox.posY2 - randBox.posY1) > 0F ? rand.nextInt(((int)(randBox.posY2 - randBox.posY1) > 0) ? (int)(randBox.posY2 - randBox.posY1) : 1) : 0F); float z = randBox.posZ1 + ((randBox.posZ2 - randBox.posZ1) > 0F ? rand.nextInt(((int)(randBox.posZ2 - randBox.posZ1) > 0) ? (int)(randBox.posZ2 - randBox.posZ1) : 1) : 0F); copy.addBox(x, y, z, 0, 0, 0, param7); } } if(ori.childModels != null && (copy.childModels == null || copy.childModels.size() < ori.childModels.size())) { for(int i = 0; i < ori.childModels.size(); i++) { ModelRenderer childCopy = buildCopy((ModelRenderer)ori.childModels.get(i), base, 0, false); createEmptyContents(base, (ModelRenderer)ori.childModels.get(i), childCopy, depth + 1); copy.addChild(childCopy); } } }
public static int getModelHeight(ModelRenderer model) { int height = 0;//Y1 lower than Y2 for(int i = 0; i < model.cubeList.size(); i++) { ModelBox box = (ModelBox)model.cubeList.get(i); if((int)Math.abs(box.posY2 - box.posY1) > height) { height = (int)Math.abs(box.posY2 - box.posY1); } } return height; }
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { int i = entitylivingbaseIn.getArrowCountInEntity(); if (i > 0) { Entity entity = new EntityArrow(entitylivingbaseIn.worldObj, entitylivingbaseIn.posX, entitylivingbaseIn.posY, entitylivingbaseIn.posZ); Random random = new Random((long)entitylivingbaseIn.getEntityId()); RenderHelper.disableStandardItemLighting(); for (int j = 0; j < i; ++j) { GlStateManager.pushMatrix(); ModelRenderer modelrenderer = this.field_177168_a.getMainModel().getRandomModelBox(random); ModelBox modelbox = (ModelBox)modelrenderer.cubeList.get(random.nextInt(modelrenderer.cubeList.size())); modelrenderer.postRender(0.0625F); float f = random.nextFloat(); float f1 = random.nextFloat(); float f2 = random.nextFloat(); float f3 = (modelbox.posX1 + (modelbox.posX2 - modelbox.posX1) * f) / 16.0F; float f4 = (modelbox.posY1 + (modelbox.posY2 - modelbox.posY1) * f1) / 16.0F; float f5 = (modelbox.posZ1 + (modelbox.posZ2 - modelbox.posZ1) * f2) / 16.0F; GlStateManager.translate(f3, f4, f5); f = f * 2.0F - 1.0F; f1 = f1 * 2.0F - 1.0F; f2 = f2 * 2.0F - 1.0F; f = f * -1.0F; f1 = f1 * -1.0F; f2 = f2 * -1.0F; float f6 = MathHelper.sqrt_float(f * f + f2 * f2); entity.prevRotationYaw = entity.rotationYaw = (float)(Math.atan2((double)f, (double)f2) * 180.0D / Math.PI); entity.prevRotationPitch = entity.rotationPitch = (float)(Math.atan2((double)f1, (double)f6) * 180.0D / Math.PI); double d0 = 0.0D; double d1 = 0.0D; double d2 = 0.0D; this.field_177168_a.getRenderManager().renderEntityWithPosYaw(entity, d0, d1, d2, 0.0F, partialTicks); GlStateManager.popMatrix(); } RenderHelper.enableStandardItemLighting(); } }
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { int i = entitylivingbaseIn.getArrowCountInEntity(); if (i > 0) { Entity entity = new EntityTippedArrow(entitylivingbaseIn.world, entitylivingbaseIn.posX, entitylivingbaseIn.posY, entitylivingbaseIn.posZ); Random random = new Random((long)entitylivingbaseIn.getEntityId()); RenderHelper.disableStandardItemLighting(); for (int j = 0; j < i; ++j) { GlStateManager.pushMatrix(); ModelRenderer modelrenderer = this.renderer.getMainModel().getRandomModelBox(random); ModelBox modelbox = (ModelBox)modelrenderer.cubeList.get(random.nextInt(modelrenderer.cubeList.size())); modelrenderer.postRender(0.0625F); float f = random.nextFloat(); float f1 = random.nextFloat(); float f2 = random.nextFloat(); float f3 = (modelbox.posX1 + (modelbox.posX2 - modelbox.posX1) * f) / 16.0F; float f4 = (modelbox.posY1 + (modelbox.posY2 - modelbox.posY1) * f1) / 16.0F; float f5 = (modelbox.posZ1 + (modelbox.posZ2 - modelbox.posZ1) * f2) / 16.0F; GlStateManager.translate(f3, f4, f5); f = f * 2.0F - 1.0F; f1 = f1 * 2.0F - 1.0F; f2 = f2 * 2.0F - 1.0F; f = f * -1.0F; f1 = f1 * -1.0F; f2 = f2 * -1.0F; float f6 = MathHelper.sqrt(f * f + f2 * f2); entity.rotationYaw = (float)(Math.atan2((double)f, (double)f2) * (180D / Math.PI)); entity.rotationPitch = (float)(Math.atan2((double)f1, (double)f6) * (180D / Math.PI)); entity.prevRotationYaw = entity.rotationYaw; entity.prevRotationPitch = entity.rotationPitch; double d0 = 0.0D; double d1 = 0.0D; double d2 = 0.0D; this.renderer.getRenderManager().doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks, false); GlStateManager.popMatrix(); } RenderHelper.enableStandardItemLighting(); } }
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { int i = entitylivingbaseIn.getArrowCountInEntity(); if (i > 0) { Entity entity = new EntityTippedArrow(entitylivingbaseIn.worldObj, entitylivingbaseIn.posX, entitylivingbaseIn.posY, entitylivingbaseIn.posZ); Random random = new Random((long)entitylivingbaseIn.getEntityId()); RenderHelper.disableStandardItemLighting(); for (int j = 0; j < i; ++j) { GlStateManager.pushMatrix(); ModelRenderer modelrenderer = this.renderer.getMainModel().getRandomModelBox(random); ModelBox modelbox = (ModelBox)modelrenderer.cubeList.get(random.nextInt(modelrenderer.cubeList.size())); modelrenderer.postRender(0.0625F); float f = random.nextFloat(); float f1 = random.nextFloat(); float f2 = random.nextFloat(); float f3 = (modelbox.posX1 + (modelbox.posX2 - modelbox.posX1) * f) / 16.0F; float f4 = (modelbox.posY1 + (modelbox.posY2 - modelbox.posY1) * f1) / 16.0F; float f5 = (modelbox.posZ1 + (modelbox.posZ2 - modelbox.posZ1) * f2) / 16.0F; GlStateManager.translate(f3, f4, f5); f = f * 2.0F - 1.0F; f1 = f1 * 2.0F - 1.0F; f2 = f2 * 2.0F - 1.0F; f = f * -1.0F; f1 = f1 * -1.0F; f2 = f2 * -1.0F; float f6 = MathHelper.sqrt_float(f * f + f2 * f2); entity.rotationYaw = (float)(Math.atan2((double)f, (double)f2) * (180D / Math.PI)); entity.rotationPitch = (float)(Math.atan2((double)f1, (double)f6) * (180D / Math.PI)); entity.prevRotationYaw = entity.rotationYaw; entity.prevRotationPitch = entity.rotationPitch; double d0 = 0.0D; double d1 = 0.0D; double d2 = 0.0D; this.renderer.getRenderManager().doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks, false); GlStateManager.popMatrix(); } RenderHelper.enableStandardItemLighting(); } }
/** * renders arrows the Entity has been attacked with, attached to it */ protected void renderArrowsStuckInEntity(EntityLivingBase p_85093_1_, float p_85093_2_) { int i = p_85093_1_.getArrowCountInEntity(); if (i > 0) { EntityArrow entityarrow = new EntityArrow(p_85093_1_.worldObj, p_85093_1_.posX, p_85093_1_.posY, p_85093_1_.posZ); Random random = new Random((long)p_85093_1_.getEntityId()); RenderHelper.disableStandardItemLighting(); for (int j = 0; j < i; ++j) { GL11.glPushMatrix(); ModelRenderer modelrenderer = this.mainModel.getRandomModelBox(random); ModelBox modelbox = (ModelBox)modelrenderer.cubeList.get(random.nextInt(modelrenderer.cubeList.size())); modelrenderer.postRender(0.0625F); float f1 = random.nextFloat(); float f2 = random.nextFloat(); float f3 = random.nextFloat(); float f4 = (modelbox.posX1 + (modelbox.posX2 - modelbox.posX1) * f1) / 16.0F; float f5 = (modelbox.posY1 + (modelbox.posY2 - modelbox.posY1) * f2) / 16.0F; float f6 = (modelbox.posZ1 + (modelbox.posZ2 - modelbox.posZ1) * f3) / 16.0F; GL11.glTranslatef(f4, f5, f6); f1 = f1 * 2.0F - 1.0F; f2 = f2 * 2.0F - 1.0F; f3 = f3 * 2.0F - 1.0F; f1 *= -1.0F; f2 *= -1.0F; f3 *= -1.0F; float f7 = MathHelper.sqrt_float(f1 * f1 + f3 * f3); entityarrow.prevRotationYaw = entityarrow.rotationYaw = (float)(Math.atan2((double)f1, (double)f3) * 180.0D / Math.PI); entityarrow.prevRotationPitch = entityarrow.rotationPitch = (float)(Math.atan2((double)f2, (double)f7) * 180.0D / Math.PI); double d0 = 0.0D; double d1 = 0.0D; double d2 = 0.0D; float f8 = 0.0F; this.renderManager.renderEntityWithPosYaw(entityarrow, d0, d1, d2, f8, p_85093_2_); GL11.glPopMatrix(); } RenderHelper.enableStandardItemLighting(); } }
/** * Generate limbs from the given model */ private Map<String, ModelRenderer> generateLimbs(Model data, ModelBase model) { Map<String, ModelRenderer> limbs = new HashMap<String, ModelRenderer>(); int i = 0; int width = 0; int height = 0; for (ModelRenderer renderer : this.getModelRenderers(model)) { int j = 0; String firstName = ""; for (ModelBox box : renderer.cubeList) { Model.Limb limb = new Model.Limb(); String boxName = box.boxName != null ? box.boxName : ""; String name = boxName.isEmpty() ? "limb_" + i : boxName; if (j == 0) { limb.mirror = renderer.mirror; firstName = name; } else { limb.parent = firstName; } limb.size = this.getModelSize(box); limb.texture = this.getModelOffset(box, renderer, model); limb.anchor = this.getAnchor(box, limb.size); data.limbs.put(name, limb); limbs.put(name, renderer); j++; i++; } width = Math.max(width, (int) renderer.textureWidth); height = Math.max(height, (int) renderer.textureHeight); } /* Some bastard decided that it was a smart idea to define two variables * in Model's constructor and inject those values directly into the * ModelRenderer via setTextureSize() instead of setting model's * properties textureWidth and textureHeight. Therefore ModelBase * properties has misleading result. * * This is a workaround to inject the right texture size for exporting * JSON model. Basically, if the texture size from JSON model doesn't * correspond with values that has been set from ModelRenderers, * it uses the greater value that was got from ModelRenderers. * * Zero check for width and height is just in case. * * See ModelIronGolem for more information. I hope it wasn't jeb. */ if (data.texture[0] != width || data.texture[1] != height && width != 0 && height != 0) { data.texture = new int[] {width, height}; } return limbs; }
/** * Get texture offset of the model based on its box */ private int[] getModelOffset(ModelBox box, ModelRenderer renderer, ModelBase model) { TextureOffset offset = model.getTextureOffset(box.boxName); if (offset != null) { return new int[] {offset.textureOffsetX, offset.textureOffsetY}; } int[] zero = new int[] {0, 0}; Field field = this.getFieldByType(TexturedQuad[].class, ModelBox.class); TexturedQuad[] quads; field.setAccessible(true); try { quads = (TexturedQuad[]) field.get(box); } catch (Exception e) { e.printStackTrace(); return zero; } /* Getting the minimum */ float minX = 1.0F; float minY = 1.0F; for (TexturedQuad quad : quads) { for (PositionTextureVertex vertex : quad.vertexPositions) { minX = Math.min(vertex.texturePositionX, minX); minY = Math.min(vertex.texturePositionY, minY); } } minX *= renderer.textureWidth; minY *= renderer.textureHeight; return new int[] {(int) minX, (int) minY}; }
@Override public void render(float scale) { if (!this.isHidden) { if (this.showModel) { if (!compiledEx) { this.displayListEx = GLAllocation.generateDisplayLists(1); GL11.glNewList(this.displayListEx, GL11.GL_COMPILE); WorldRenderer worldrenderer = Tessellator.getInstance().getWorldRenderer(); for (int i = 0; i < this.cubeList.size(); ++i) { ((ModelBox)this.cubeList.get(i)).render(worldrenderer, scale); } GL11.glEndList(); this.compiledEx = true; } GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ); GL11.glPushMatrix(); GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); if (this.rotateAngleZ != 0.0F) { GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); } if (this.rotateAngleY != 0.0F) { GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); } if (this.rotateAngleX != 0.0F) { GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); } /* move offset position */ GL11.glTranslatef(this.boxOffsetX * scale, this.boxOffsetY * scale, this.boxOffsetZ * scale); /* adjust position (consider scale) */ if (widthScale != 1.0F || heightScale != 1.0F) { float xDiff = (width - (width * widthScale))/2.0F; float yDiff = (height - (height * heightScale))/2.0F; GL11.glTranslatef(xDiff * scale, yDiff * scale, 0); } /* move */ if (moveX != 0.0F || moveY != 0.0F) { GL11.glTranslatef(moveX * scale, moveY * scale, 0); } if (widthScale != 1.0F || heightScale != 1.0F) { GL11.glScalef(widthScale, heightScale, 1.0F); } /* rotate */ if (this.rotate != 0.0F) { GL11.glRotatef(this.rotate, 0.0F, 0.0F, 1.0F); } GL11.glCallList(this.displayListEx); GL11.glPopMatrix(); GL11.glTranslatef(-this.offsetX, -this.offsetY, -this.offsetZ); } } }
/** * renders arrows the Entity has been attacked with, attached to it */ protected void renderArrowsStuckInEntity(EntityLivingBase par1EntityLivingBase, float par2) { int var3 = par1EntityLivingBase.getArrowCountInEntity(); if (var3 > 0) { EntityArrow var4 = new EntityArrow(par1EntityLivingBase.worldObj, par1EntityLivingBase.posX, par1EntityLivingBase.posY, par1EntityLivingBase.posZ); Random var5 = new Random((long)par1EntityLivingBase.getEntityId()); RenderHelper.disableStandardItemLighting(); for (int var6 = 0; var6 < var3; ++var6) { GL11.glPushMatrix(); ModelRenderer var7 = this.mainModel.getRandomModelBox(var5); ModelBox var8 = (ModelBox)var7.cubeList.get(var5.nextInt(var7.cubeList.size())); var7.postRender(0.0625F); float var9 = var5.nextFloat(); float var10 = var5.nextFloat(); float var11 = var5.nextFloat(); float var12 = (var8.posX1 + (var8.posX2 - var8.posX1) * var9) / 16.0F; float var13 = (var8.posY1 + (var8.posY2 - var8.posY1) * var10) / 16.0F; float var14 = (var8.posZ1 + (var8.posZ2 - var8.posZ1) * var11) / 16.0F; GL11.glTranslatef(var12, var13, var14); var9 = var9 * 2.0F - 1.0F; var10 = var10 * 2.0F - 1.0F; var11 = var11 * 2.0F - 1.0F; var9 *= -1.0F; var10 *= -1.0F; var11 *= -1.0F; float var15 = MathHelper.sqrt_float(var9 * var9 + var11 * var11); var4.prevRotationYaw = var4.rotationYaw = (float)(Math.atan2((double)var9, (double)var11) * 180.0D / Math.PI); var4.prevRotationPitch = var4.rotationPitch = (float)(Math.atan2((double)var10, (double)var15) * 180.0D / Math.PI); double var16 = 0.0D; double var18 = 0.0D; double var20 = 0.0D; float var22 = 0.0F; this.renderManager.func_147940_a(var4, var16, var18, var20, var22, par2); GL11.glPopMatrix(); } RenderHelper.enableStandardItemLighting(); } }
/** * renders arrows the Entity has been attacked with, attached to it */ protected void renderArrowsStuckInEntity(EntityLivingBase living, float f) { int i = living.getArrowCountInEntity(); if (i > 0) { EntityArrow entityarrow = new EntityArrow(living.worldObj, living.posX, living.posY, living.posZ); Random random = new Random((long)living.entityId); RenderHelper.disableStandardItemLighting(); for (int j = 0; j < i; ++j) { GL11.glPushMatrix(); ModelRenderer modelrenderer = this.mainModel.getRandomModelBox(random); ModelBox modelbox = (ModelBox)modelrenderer.cubeList.get(random.nextInt(modelrenderer.cubeList.size())); modelrenderer.postRender(0.0625F); float f1 = random.nextFloat(); float f2 = random.nextFloat(); float f3 = random.nextFloat(); float f4 = (modelbox.posX1 + (modelbox.posX2 - modelbox.posX1) * f1) / 16.0F; float f5 = (modelbox.posY1 + (modelbox.posY2 - modelbox.posY1) * f2) / 16.0F; float f6 = (modelbox.posZ1 + (modelbox.posZ2 - modelbox.posZ1) * f3) / 16.0F; GL11.glTranslatef(f4, f5, f6); f1 = f1 * 2.0F - 1.0F; f2 = f2 * 2.0F - 1.0F; f3 = f3 * 2.0F - 1.0F; f1 *= -1.0F; f2 *= -1.0F; f3 *= -1.0F; float f7 = MathHelper.sqrt_float(f1 * f1 + f3 * f3); entityarrow.prevRotationYaw = entityarrow.rotationYaw = (float)(Math.atan2((double)f1, (double)f3) * 180.0D / Math.PI); entityarrow.prevRotationPitch = entityarrow.rotationPitch = (float)(Math.atan2((double)f2, (double)f7) * 180.0D / Math.PI); double d0 = 0.0D; double d1 = 0.0D; double d2 = 0.0D; float f8 = 0.0F; this.renderManager.renderEntityWithPosYaw(entityarrow, d0, d1, d2, f8, f); GL11.glPopMatrix(); } RenderHelper.enableStandardItemLighting(); } }
public void initComponents() { axleHoriPart = new ModelRendererVC(this); axleVertiPart = new ModelRendererVC(this); horiBlade = new ModelRendererVC[maxSize+1]; vertiBlade = new ModelRendererVC[maxSize+1]; horiWingFirst = new ModelRendererVC[maxSize]; vertiWingFirst = new ModelRendererVC[maxSize]; horiWingSecond = new ModelRendererVC[maxSize]; vertiWingSecond = new ModelRendererVC[maxSize]; // x1 y1 z1 wdt hgt depth scalechange axleHoriPart.cubeList.add(new ModelBox(axleHoriPart, 0, 0, 13f, 10f, 0F, 6, 12, 32, 0)); axleVertiPart.cubeList.add(new ModelBox(axleVertiPart, 0, 0, 10f, 13f, 0.05F, 12, 6, 32, 0)); for (int i = 0; i < maxSize+1; i++) { horiBlade[i] = new ModelRendererVC(this); vertiBlade[i] = new ModelRendererVC(this); horiBlade[i].cubeList.add(new ModelBox( horiBlade[i], 0, 0, -32*i, 14.5f, 20F, 32 + 64 * i, 4, 4, 0)); vertiBlade[i].cubeList.add(new ModelBox(vertiBlade[i], 0, 0, 14f, -32*i, 20F, 4, 32 + 64 * i, 4, 0)); } for (int i = 0; i < maxSize; i++) { horiWingFirst[i] = new ModelRendererVC(this); vertiWingFirst[i] = new ModelRendererVC(this); horiWingSecond[i] = new ModelRendererVC(this); vertiWingSecond[i] = new ModelRendererVC(this); int ip = i+1; horiWingFirst[i].cubeList.add(new ModelBox( horiWingFirst[i], 0, 0, -32*ip, 14.5f - 24, 20F + 2, 32 * ip - 8, 24, 1, 0)); vertiWingFirst[i].cubeList.add(new ModelBox(vertiWingFirst[i], 0, 0, 14f + 4, -32*ip, 20F + 2, 24, 32 * ip - 8, 1, 0)); horiWingSecond[i].cubeList.add(new ModelBox( horiWingSecond[i], 0, 0, 32 , 14.5f + 4, 20F + 2, 32 * ip, 24, 1, 0)); vertiWingSecond[i].cubeList.add(new ModelBox(vertiWingSecond[i], 0, 0, 14f - 24, 32, 20F + 2, 24, 32 * ip, 1, 0)); } }
public ModelBox newBox(ModelRendererVC parent, float x, float y, float z, int width, int height, int depth) { // woodCover.cubeList.add(new ModelBox(woodCover, 0, 0, 2f, 0f, 2f, 28, 2, 28, 0)); ModelBox box = new ModelBox(parent, 0, 0, resolution * x, resolution * y, resolution * z, resolution * width, resolution * height, resolution * depth, 0); return box; }
/** * Creates a textured box. Args: originX, originY, originZ, width, height, depth, scaleFactor. */ public void addBox(float par1, float par2, float par3, int par4, int par5, int par6, float par7) { this.cubeList.add(new ModelBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, par7)); }
/** * Creates a textured box. Args: originX, originY, originZ, width, height, depth, scaleFactor. */ public void addBox(ModelBox box) { this.cubeList.add(box); }
protected void renderArrowsStuckInEntity(EntityLivingBase p_85093_1_, float p_85093_2_) { int i = p_85093_1_.getArrowCountInEntity(); if (i > 0) { EntityArrow entityarrow = new EntityArrow(p_85093_1_.worldObj, p_85093_1_.posX, p_85093_1_.posY, p_85093_1_.posZ); Random random = new Random((long)p_85093_1_.getEntityId()); RenderHelper.disableStandardItemLighting(); for (int j = 0; j < i; ++j) { GL11.glPushMatrix(); ModelRenderer modelrenderer = this.mainModel.getRandomModelBox(random); ModelBox modelbox = (ModelBox)modelrenderer.cubeList.get(random.nextInt(modelrenderer.cubeList.size())); modelrenderer.postRender(0.0625F); float f1 = random.nextFloat(); float f2 = random.nextFloat(); float f3 = random.nextFloat(); float f4 = (modelbox.posX1 + (modelbox.posX2 - modelbox.posX1) * f1) / 16.0F; float f5 = (modelbox.posY1 + (modelbox.posY2 - modelbox.posY1) * f2) / 16.0F; float f6 = (modelbox.posZ1 + (modelbox.posZ2 - modelbox.posZ1) * f3) / 16.0F; GL11.glTranslatef(f4, f5, f6); f1 = f1 * 2.0F - 1.0F; f2 = f2 * 2.0F - 1.0F; f3 = f3 * 2.0F - 1.0F; f1 *= -1.0F; f2 *= -1.0F; f3 *= -1.0F; float f7 = MathHelper.sqrt_float(f1 * f1 + f3 * f3); entityarrow.prevRotationYaw = entityarrow.rotationYaw = (float)(Math.atan2((double)f1, (double)f3) * 180.0D / Math.PI); entityarrow.prevRotationPitch = entityarrow.rotationPitch = (float)(Math.atan2((double)f2, (double)f7) * 180.0D / Math.PI); double d0 = 0.0D; double d1 = 0.0D; double d2 = 0.0D; float f8 = 0.0F; this.renderManager.renderEntityWithPosYaw(entityarrow, d0, d1, d2, f8, p_85093_2_); GL11.glPopMatrix(); } RenderHelper.enableStandardItemLighting(); } }