Search in sources :

Example 1 with ModelChest

use of net.minecraft.client.model.ModelChest in project BetterStorage by copygirl.

the class TileEntityReinforcedChestRenderer method renderTileEntityAt.

public void renderTileEntityAt(TileEntityReinforcedChest chest, double x, double y, double z, float partialTicks) {
    boolean large = chest.isConnected();
    if (large && !chest.isMain())
        return;
    ModelChest model = (large ? largeChestModel : chestModel);
    bindTexture(chest.getResource());
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslated(x, y, z);
    GL11.glPushMatrix();
    GL11.glScalef(1.0F, -1.0F, -1.0F);
    GL11.glTranslatef(0.5F, -0.5F, -0.5F);
    int rotation = DirectionUtils.getRotation(chest.getOrientation());
    if ((rotation == 180) && large)
        GL11.glTranslatef(1.0F, 0.0F, 0.0F);
    if ((rotation == 270) && large)
        GL11.glTranslatef(0.0F, 0.0F, -1.0F);
    GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    float angle = chest.prevLidAngle + (chest.lidAngle - chest.prevLidAngle) * partialTicks;
    angle = 1.0F - angle;
    angle = 1.0F - angle * angle * angle;
    model.chestLid.rotateAngleX = -(float) (angle * Math.PI / 2.0);
    model.renderAll();
    GL11.glPopMatrix();
    chest.getAttachments().render(partialTicks);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
Also used : ModelChest(net.minecraft.client.model.ModelChest)

Example 2 with ModelChest

use of net.minecraft.client.model.ModelChest in project SecurityCraft by Geforce132.

the class TileEntityKeypadChestRenderer method renderTileEntityAt.

public void renderTileEntityAt(TileEntityChest p_147502_1_, double p_147502_2_, double p_147502_4_, double p_147502_6_, float p_147502_8_) {
    int i;
    if (!p_147502_1_.hasWorldObj()) {
        i = 0;
    } else {
        Block block = p_147502_1_.getBlockType();
        i = p_147502_1_.getBlockMetadata();
        if (block instanceof BlockChest && i == 0) {
            try {
                ((BlockChest) block).func_149954_e(p_147502_1_.getWorldObj(), p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord);
            } catch (ClassCastException e) {
                FMLLog.severe("Attempted to render a chest at %d,  %d, %d that was not a chest", p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord);
            }
            i = p_147502_1_.getBlockMetadata();
        }
        p_147502_1_.checkForAdjacentChests();
    }
    if (p_147502_1_.adjacentChestZNeg == null && p_147502_1_.adjacentChestXNeg == null) {
        ModelChest modelchest;
        if (p_147502_1_.adjacentChestXPos == null && p_147502_1_.adjacentChestZPos == null) {
            modelchest = this.field_147510_h;
            if (p_147502_1_.func_145980_j() == 1) {
                this.bindTexture(trappedNormal);
            } else if (this.field_147509_j) {
                this.bindTexture(christmasNormal);
            } else {
                if (p_147502_1_.lidAngle >= 0.9) {
                    this.bindTexture(normalSingleActive);
                } else {
                    this.bindTexture(normalSingleUnactive);
                }
            }
        } else {
            modelchest = this.field_147511_i;
            if (p_147502_1_.func_145980_j() == 1) {
                this.bindTexture(trappedDouble);
            } else if (this.field_147509_j) {
                this.bindTexture(christmasDouble);
            } else {
                if (p_147502_1_.lidAngle >= 0.9) {
                    this.bindTexture(normalDoubleActive);
                } else {
                    this.bindTexture(normalDoubleUnactive);
                }
            }
        }
        GL11.glPushMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) p_147502_2_, (float) p_147502_4_ + 1.0F, (float) p_147502_6_ + 1.0F);
        GL11.glScalef(1.0F, -1.0F, -1.0F);
        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
        short short1 = 0;
        if (i == 2) {
            short1 = 180;
        }
        if (i == 3) {
            short1 = 0;
        }
        if (i == 4) {
            short1 = 90;
        }
        if (i == 5) {
            short1 = -90;
        }
        if (i == 2 && p_147502_1_.adjacentChestXPos != null) {
            GL11.glTranslatef(1.0F, 0.0F, 0.0F);
        }
        if (i == 5 && p_147502_1_.adjacentChestZPos != null) {
            GL11.glTranslatef(0.0F, 0.0F, -1.0F);
        }
        GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        float f1 = p_147502_1_.prevLidAngle + (p_147502_1_.lidAngle - p_147502_1_.prevLidAngle) * p_147502_8_;
        float f2;
        if (p_147502_1_.adjacentChestZNeg != null) {
            f2 = p_147502_1_.adjacentChestZNeg.prevLidAngle + (p_147502_1_.adjacentChestZNeg.lidAngle - p_147502_1_.adjacentChestZNeg.prevLidAngle) * p_147502_8_;
            if (f2 > f1) {
                f1 = f2;
            }
        }
        if (p_147502_1_.adjacentChestXNeg != null) {
            f2 = p_147502_1_.adjacentChestXNeg.prevLidAngle + (p_147502_1_.adjacentChestXNeg.lidAngle - p_147502_1_.adjacentChestXNeg.prevLidAngle) * p_147502_8_;
            if (f2 > f1) {
                f1 = f2;
            }
        }
        f1 = 1.0F - f1;
        f1 = 1.0F - f1 * f1 * f1;
        modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F);
        modelchest.renderAll();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}
Also used : ModelChest(net.minecraft.client.model.ModelChest) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Example 3 with ModelChest

use of net.minecraft.client.model.ModelChest in project MorePlanets by SteveKunG.

the class TileEntityChestRendererMP method render.

@Override
public void render(TileEntityChestMP tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    int meta;
    if (!tile.hasWorld()) {
        meta = 0;
    } else {
        Block block = tile.getBlockType();
        meta = tile.getBlockMetadata();
        if (block instanceof BlockChestMP && meta == 0) {
            ((BlockChestMP) block).checkForSurroundingChests(tile.getWorld(), tile.getPos(), tile.getWorld().getBlockState(tile.getPos()));
            meta = tile.getBlockMetadata();
        }
        tile.checkForAdjacentChests();
    }
    if (tile.adjacentChestZNeg == null && tile.adjacentChestXNeg == null) {
        ModelChest modelchest;
        if (tile.adjacentChestXPos == null && tile.adjacentChestZPos == null) {
            modelchest = this.simpleChest;
            if (destroyStage >= 0) {
                this.bindTexture(DESTROY_STAGES[destroyStage]);
                GlStateManager.matrixMode(5890);
                GlStateManager.pushMatrix();
                GlStateManager.scale(4.0F, 4.0F, 1.0F);
                GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
                GlStateManager.matrixMode(5888);
            } else if (CalendarHelper.isChristmasDay()) {
                this.bindTexture(this.textureChristmas);
            } else if (CalendarHelper.isMorePlanetsBirthDay()) {
                this.bindTexture(this.morePlanetsChestNormal);
            } else {
                this.bindTexture(this.textureNormal);
            }
        } else {
            modelchest = this.largeChest;
            if (destroyStage >= 0) {
                this.bindTexture(DESTROY_STAGES[destroyStage]);
                GlStateManager.matrixMode(5890);
                GlStateManager.pushMatrix();
                GlStateManager.scale(8.0F, 4.0F, 1.0F);
                GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
                GlStateManager.matrixMode(5888);
            } else if (CalendarHelper.isChristmasDay()) {
                this.bindTexture(this.textureChristmasDouble);
            } else if (CalendarHelper.isMorePlanetsBirthDay()) {
                this.bindTexture(this.morePlanetsLargeChestNormal);
            } else {
                this.bindTexture(this.textureNormalDouble);
            }
        }
        GlStateManager.pushMatrix();
        GlStateManager.enableRescaleNormal();
        if (destroyStage < 0) {
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        }
        GlStateManager.translate((float) x, (float) y + 1.0F, (float) z + 1.0F);
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        GlStateManager.translate(0.5F, 0.5F, 0.5F);
        short short1 = 0;
        if (meta == 2) {
            short1 = 180;
        }
        if (meta == 3) {
            short1 = 0;
        }
        if (meta == 4) {
            short1 = 90;
        }
        if (meta == 5) {
            short1 = -90;
        }
        if (meta == 2 && tile.adjacentChestXPos != null) {
            GlStateManager.translate(1.0F, 0.0F, 0.0F);
        }
        if (meta == 5 && tile.adjacentChestZPos != null) {
            GlStateManager.translate(0.0F, 0.0F, -1.0F);
        }
        GlStateManager.rotate(short1, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(-0.5F, -0.5F, -0.5F);
        float f1 = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTicks;
        float f2;
        if (tile.adjacentChestZNeg != null) {
            f2 = tile.adjacentChestZNeg.prevLidAngle + (tile.adjacentChestZNeg.lidAngle - tile.adjacentChestZNeg.prevLidAngle) * partialTicks;
            if (f2 > f1) {
                f1 = f2;
            }
        }
        if (tile.adjacentChestXNeg != null) {
            f2 = tile.adjacentChestXNeg.prevLidAngle + (tile.adjacentChestXNeg.lidAngle - tile.adjacentChestXNeg.prevLidAngle) * partialTicks;
            if (f2 > f1) {
                f1 = f2;
            }
        }
        f1 = 1.0F - f1;
        f1 = 1.0F - f1 * f1 * f1;
        modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F);
        modelchest.renderAll();
        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        if (destroyStage >= 0) {
            GlStateManager.matrixMode(5890);
            GlStateManager.popMatrix();
            GlStateManager.matrixMode(5888);
        }
    }
}
Also used : ModelChest(net.minecraft.client.model.ModelChest) BlockChestMP(stevekung.mods.moreplanets.util.blocks.BlockChestMP) Block(net.minecraft.block.Block)

Example 4 with ModelChest

use of net.minecraft.client.model.ModelChest in project SecurityCraft by Geforce132.

the class TileEntityKeypadChestRenderer method renderTileEntityAt.

public void renderTileEntityAt(TileEntityChest p_147502_1_, double p_147502_2_, double p_147502_4_, double p_147502_6_, float p_147502_8_) {
    int i;
    if (!p_147502_1_.hasWorldObj())
        i = 0;
    else {
        Block block = p_147502_1_.getBlockType();
        i = p_147502_1_.getBlockMetadata();
        if (block instanceof BlockChest && i == 0) {
            try {
                ((BlockChest) block).initMetadata(p_147502_1_.getWorld(), p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord);
            } catch (ClassCastException e) {
                FMLLog.severe("Attempted to render a chest at %d,  %d, %d that was not a chest", p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord);
            }
            i = p_147502_1_.getBlockMetadata();
        }
        p_147502_1_.checkForAdjacentChests();
    }
    if (p_147502_1_.adjacentChestZNeg == null && p_147502_1_.adjacentChestXNeg == null) {
        ModelChest modelchest;
        if (p_147502_1_.adjacentChestXPos == null && p_147502_1_.adjacentChestZPos == null) {
            modelchest = field_147510_h;
            if (field_147509_j)
                bindTexture(christmasNormal);
            else if (p_147502_1_.lidAngle >= 0.9)
                bindTexture(normalSingleActive);
            else
                bindTexture(normalSingleUnactive);
        } else {
            modelchest = field_147511_i;
            if (field_147509_j)
                bindTexture(christmasDouble);
            else if (p_147502_1_.lidAngle >= 0.9)
                bindTexture(normalDoubleActive);
            else
                bindTexture(normalDoubleUnactive);
        }
        GL11.glPushMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) p_147502_2_, (float) p_147502_4_ + 1.0F, (float) p_147502_6_ + 1.0F);
        GL11.glScalef(1.0F, -1.0F, -1.0F);
        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
        short short1 = 0;
        if (i == 2)
            short1 = 180;
        if (i == 3)
            short1 = 0;
        if (i == 4)
            short1 = 90;
        if (i == 5)
            short1 = -90;
        if (i == 2 && p_147502_1_.adjacentChestXPos != null)
            GL11.glTranslatef(1.0F, 0.0F, 0.0F);
        if (i == 5 && p_147502_1_.adjacentChestZPos != null)
            GL11.glTranslatef(0.0F, 0.0F, -1.0F);
        GL11.glRotatef(short1, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        float f1 = p_147502_1_.prevLidAngle + (p_147502_1_.lidAngle - p_147502_1_.prevLidAngle) * p_147502_8_;
        float f2;
        if (p_147502_1_.adjacentChestZNeg != null) {
            f2 = p_147502_1_.adjacentChestZNeg.prevLidAngle + (p_147502_1_.adjacentChestZNeg.lidAngle - p_147502_1_.adjacentChestZNeg.prevLidAngle) * p_147502_8_;
            if (f2 > f1)
                f1 = f2;
        }
        if (p_147502_1_.adjacentChestXNeg != null) {
            f2 = p_147502_1_.adjacentChestXNeg.prevLidAngle + (p_147502_1_.adjacentChestXNeg.lidAngle - p_147502_1_.adjacentChestXNeg.prevLidAngle) * p_147502_8_;
            if (f2 > f1)
                f1 = f2;
        }
        f1 = 1.0F - f1;
        f1 = 1.0F - f1 * f1 * f1;
        modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F);
        modelchest.renderAll();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}
Also used : ModelChest(net.minecraft.client.model.ModelChest) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Example 5 with ModelChest

use of net.minecraft.client.model.ModelChest in project Bookshelf by Darkhax-Minecraft.

the class TileEntityBasicChestRenderer method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntityBasicChest te, double x, double y, double z, float partialTicks, int destroyStage) {
    GlStateManager.enableDepth();
    GlStateManager.depthFunc(GL11.GL_LEQUAL);
    GlStateManager.depthMask(true);
    int meta;
    if (te.hasWorld()) {
        meta = te.getBlockMetadata();
        te.checkForAdjacentChests();
    } else {
        meta = 0;
    }
    if (te.adjacentChestZNeg == null && te.adjacentChestXNeg == null) {
        ModelChest model;
        // Single Chest
        if (te.adjacentChestXPos == null && te.adjacentChestZPos == null) {
            model = this.modelSingle;
            if (destroyStage >= 0) {
                this.bindTexture(DESTROY_STAGES[destroyStage]);
                GlStateManager.matrixMode(GL11.GL_TEXTURE);
                GlStateManager.pushMatrix();
                GlStateManager.scale(4.0F, 4.0F, 1.0F);
                GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
                GlStateManager.matrixMode(GL11.GL_MODELVIEW);
            } else {
                this.bindTexture(te.getType().getNormalTexture());
            }
        } else // Double Chest
        {
            model = this.modelDouble;
            if (destroyStage >= 0) {
                this.bindTexture(DESTROY_STAGES[destroyStage]);
                GlStateManager.matrixMode(GL11.GL_TEXTURE);
                GlStateManager.pushMatrix();
                GlStateManager.scale(8.0F, 4.0F, 1.0F);
                GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
                GlStateManager.matrixMode(GL11.GL_MODELVIEW);
            } else {
                this.bindTexture(te.getType().getDoubleTexture());
            }
        }
        GlStateManager.pushMatrix();
        GlStateManager.enableRescaleNormal();
        if (destroyStage < 0) {
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        }
        GlStateManager.translate(x, y + 1.0F, z + 1.0F);
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        GlStateManager.translate(0.5F, 0.5F, 0.5F);
        int angle = 0;
        if (meta == 2) {
            angle = 180;
        }
        if (meta == 3) {
            angle = 0;
        }
        if (meta == 4) {
            angle = 90;
        }
        if (meta == 5) {
            angle = -90;
        }
        if (meta == 2 && te.adjacentChestXPos != null) {
            GlStateManager.translate(1.0F, 0.0F, 0.0F);
        }
        if (meta == 5 && te.adjacentChestZPos != null) {
            GlStateManager.translate(0.0F, 0.0F, -1.0F);
        }
        GlStateManager.rotate(angle, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(-0.5F, -0.5F, -0.5F);
        float lidAngle = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
        if (te.adjacentChestZNeg != null) {
            final float adjLidAngle = te.adjacentChestZNeg.prevLidAngle + (te.adjacentChestZNeg.lidAngle - te.adjacentChestZNeg.prevLidAngle) * partialTicks;
            if (adjLidAngle > lidAngle) {
                lidAngle = adjLidAngle;
            }
        }
        if (te.adjacentChestXNeg != null) {
            final float adjLidAngle = te.adjacentChestXNeg.prevLidAngle + (te.adjacentChestXNeg.lidAngle - te.adjacentChestXNeg.prevLidAngle) * partialTicks;
            if (adjLidAngle > lidAngle) {
                lidAngle = adjLidAngle;
            }
        }
        lidAngle = 1.0F - lidAngle;
        lidAngle = 1.0F - lidAngle * lidAngle * lidAngle;
        model.chestLid.rotateAngleX = -(lidAngle * ((float) Math.PI / 2F));
        for (final IRenderHook renderHook : te.getType().renderHooks()) {
            renderHook.setup(te, x, y, z, partialTicks, destroyStage, this, model, model == this.modelSingle);
        }
        model.renderAll();
        for (final IRenderHook renderHook : te.getType().renderHooks()) {
            renderHook.render(te, x, y, z, partialTicks, destroyStage, this, model, model == this.modelSingle);
        }
        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        if (destroyStage >= 0) {
            GlStateManager.matrixMode(GL11.GL_TEXTURE);
            GlStateManager.popMatrix();
            GlStateManager.matrixMode(GL11.GL_MODELVIEW);
        }
    }
}
Also used : ModelChest(net.minecraft.client.model.ModelChest) IRenderHook(net.darkhax.bookshelf.builder.ChestBuilder.IRenderHook)

Aggregations

ModelChest (net.minecraft.client.model.ModelChest)9 Block (net.minecraft.block.Block)7 BlockChest (net.minecraft.block.BlockChest)5 IRenderHook (net.darkhax.bookshelf.builder.ChestBuilder.IRenderHook)1 BlockAncientChestMP (stevekung.mods.moreplanets.util.blocks.BlockAncientChestMP)1 BlockChestMP (stevekung.mods.moreplanets.util.blocks.BlockChestMP)1