001package net.minecraft.client.model; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005import net.minecraft.client.renderer.Tessellator; 006 007public class ModelBox 008{ 009 /** 010 * The (x,y,z) vertex positions and (u,v) texture coordinates for each of the 8 points on a cube 011 */ 012 private PositionTextureVertex[] vertexPositions; 013 014 /** An array of 6 TexturedQuads, one for each face of a cube */ 015 private TexturedQuad[] quadList; 016 017 /** X vertex coordinate of lower box corner */ 018 public final float posX1; 019 020 /** Y vertex coordinate of lower box corner */ 021 public final float posY1; 022 023 /** Z vertex coordinate of lower box corner */ 024 public final float posZ1; 025 026 /** X vertex coordinate of upper box corner */ 027 public final float posX2; 028 029 /** Y vertex coordinate of upper box corner */ 030 public final float posY2; 031 032 /** Z vertex coordinate of upper box corner */ 033 public final float posZ2; 034 public String field_78247_g; 035 036 public ModelBox(ModelRenderer par1ModelRenderer, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10) 037 { 038 this.posX1 = par4; 039 this.posY1 = par5; 040 this.posZ1 = par6; 041 this.posX2 = par4 + (float)par7; 042 this.posY2 = par5 + (float)par8; 043 this.posZ2 = par6 + (float)par9; 044 this.vertexPositions = new PositionTextureVertex[8]; 045 this.quadList = new TexturedQuad[6]; 046 float f4 = par4 + (float)par7; 047 float f5 = par5 + (float)par8; 048 float f6 = par6 + (float)par9; 049 par4 -= par10; 050 par5 -= par10; 051 par6 -= par10; 052 f4 += par10; 053 f5 += par10; 054 f6 += par10; 055 056 if (par1ModelRenderer.mirror) 057 { 058 float f7 = f4; 059 f4 = par4; 060 par4 = f7; 061 } 062 063 PositionTextureVertex positiontexturevertex = new PositionTextureVertex(par4, par5, par6, 0.0F, 0.0F); 064 PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(f4, par5, par6, 0.0F, 8.0F); 065 PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(f4, f5, par6, 8.0F, 8.0F); 066 PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(par4, f5, par6, 8.0F, 0.0F); 067 PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(par4, par5, f6, 0.0F, 0.0F); 068 PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(f4, par5, f6, 0.0F, 8.0F); 069 PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(f4, f5, f6, 8.0F, 8.0F); 070 PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(par4, f5, f6, 8.0F, 0.0F); 071 this.vertexPositions[0] = positiontexturevertex; 072 this.vertexPositions[1] = positiontexturevertex1; 073 this.vertexPositions[2] = positiontexturevertex2; 074 this.vertexPositions[3] = positiontexturevertex3; 075 this.vertexPositions[4] = positiontexturevertex4; 076 this.vertexPositions[5] = positiontexturevertex5; 077 this.vertexPositions[6] = positiontexturevertex6; 078 this.vertexPositions[7] = positiontexturevertex7; 079 this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex5, positiontexturevertex1, positiontexturevertex2, positiontexturevertex6}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); 080 this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex, positiontexturevertex4, positiontexturevertex7, positiontexturevertex3}, par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); 081 this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex5, positiontexturevertex4, positiontexturevertex, positiontexturevertex1}, par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); 082 this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex2, positiontexturevertex3, positiontexturevertex7, positiontexturevertex6}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); 083 this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex1, positiontexturevertex, positiontexturevertex3, positiontexturevertex2}, par2 + par9, par3 + par9, par2 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); 084 this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex4, positiontexturevertex5, positiontexturevertex6, positiontexturevertex7}, par2 + par9 + par7 + par9, par3 + par9, par2 + par9 + par7 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); 085 086 if (par1ModelRenderer.mirror) 087 { 088 for (int j1 = 0; j1 < this.quadList.length; ++j1) 089 { 090 this.quadList[j1].flipFace(); 091 } 092 } 093 } 094 095 /** 096 * Draw the six sided box defined by this ModelBox 097 */ 098 @SideOnly(Side.CLIENT) 099 public void render(Tessellator par1Tessellator, float par2) 100 { 101 for (int i = 0; i < this.quadList.length; ++i) 102 { 103 this.quadList[i].draw(par1Tessellator, par2); 104 } 105 } 106 107 public ModelBox func_78244_a(String par1Str) 108 { 109 this.field_78247_g = par1Str; 110 return this; 111 } 112}