    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 var11 = par4 + (float)par7;
    047        float var12 = par5 + (float)par8;
    048        float var13 = par6 + (float)par9;
    049        par4 -= par10;
    050        par5 -= par10;
    051        par6 -= par10;
    052        var11 += par10;
    053        var12 += par10;
    054        var13 += par10;
    055
    056        if (par1ModelRenderer.mirror)
    057        {
    058            float var14 = var11;
    059            var11 = par4;
    060            par4 = var14;
    061        }
    062
    063        PositionTextureVertex var23 = new PositionTextureVertex(par4, par5, par6, 0.0F, 0.0F);
    064        PositionTextureVertex var15 = new PositionTextureVertex(var11, par5, par6, 0.0F, 8.0F);
    065        PositionTextureVertex var16 = new PositionTextureVertex(var11, var12, par6, 8.0F, 8.0F);
    066        PositionTextureVertex var17 = new PositionTextureVertex(par4, var12, par6, 8.0F, 0.0F);
    067        PositionTextureVertex var18 = new PositionTextureVertex(par4, par5, var13, 0.0F, 0.0F);
    068        PositionTextureVertex var19 = new PositionTextureVertex(var11, par5, var13, 0.0F, 8.0F);
    069        PositionTextureVertex var20 = new PositionTextureVertex(var11, var12, var13, 8.0F, 8.0F);
    070        PositionTextureVertex var21 = new PositionTextureVertex(par4, var12, var13, 8.0F, 0.0F);
    071        this.vertexPositions[0] = var23;
    072        this.vertexPositions[1] = var15;
    073        this.vertexPositions[2] = var16;
    074        this.vertexPositions[3] = var17;
    075        this.vertexPositions[4] = var18;
    076        this.vertexPositions[5] = var19;
    077        this.vertexPositions[6] = var20;
    078        this.vertexPositions[7] = var21;
    079        this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] {var19, var15, var16, var20}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
    080        this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] {var23, var18, var21, var17}, par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
    081        this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] {var19, var18, var23, var15}, par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
    082        this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] {var16, var17, var21, var20}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
    083        this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] {var15, var23, var17, var16}, par2 + par9, par3 + par9, par2 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
    084        this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] {var18, var19, var20, var21}, 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 var22 = 0; var22 < this.quadList.length; ++var22)
    089            {
    090                this.quadList[var22].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 var3 = 0; var3 < this.quadList.length; ++var3)
    102        {
    103            this.quadList[var3].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}