Search in sources :

Example 6 with BlockChest

use of net.minecraft.block.BlockChest in project BluePower by Qmunity.

the class IOHelper method getInventoryForTE.

public static IInventory getInventoryForTE(TileEntity te) {
    if (te instanceof IInventory) {
        IInventory inv = (IInventory) te;
        Block block = te.getBlockType();
        if (block instanceof BlockChest) {
            inv = ((BlockChest) block).func_149951_m(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
        }
        return inv;
    } else {
        return null;
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Example 7 with BlockChest

use of net.minecraft.block.BlockChest in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunnerClient method onDrawBlockDamageTexture.

public static void onDrawBlockDamageTexture(RenderGlobal renderGlobal, Tessellator tessellatorIn, VertexBuffer worldRendererIn, Entity entityIn, float partialTicks) {
    double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
    double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
    double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;
    if (!renderGlobal.damagedBlocks.isEmpty()) {
        renderGlobal.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        renderGlobal.preRenderDamagedBlocks();
        worldRendererIn.begin(7, DefaultVertexFormats.BLOCK);
        worldRendererIn.setTranslation(-d0, -d1, -d2);
        worldRendererIn.noColor();
        Iterator<DestroyBlockProgress> iterator = renderGlobal.damagedBlocks.values().iterator();
        while (iterator.hasNext()) {
            DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress) iterator.next();
            BlockPos blockpos = destroyblockprogress.getPosition();
            double d3 = (double) blockpos.getX() - d0;
            double d4 = (double) blockpos.getY() - d1;
            double d5 = (double) blockpos.getZ() - d2;
            Block block = renderGlobal.theWorld.getBlockState(blockpos).getBlock();
            TileEntity te = renderGlobal.theWorld.getTileEntity(blockpos);
            boolean hasBreak = block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull;
            if (!hasBreak)
                hasBreak = te != null && te.canRenderBreaking();
            if (!hasBreak) {
                PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(renderGlobal.theWorld, blockpos);
                if (wrapper == null && (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D)) {
                    iterator.remove();
                } else {
                    IBlockState iblockstate = renderGlobal.theWorld.getBlockState(blockpos);
                    if (wrapper != null) {
                        wrapper.wrapping.renderer.setupTranslation(partialTicks);
                        worldRendererIn.setTranslation(-wrapper.wrapping.renderer.offsetPos.getX(), -wrapper.wrapping.renderer.offsetPos.getY(), -wrapper.wrapping.renderer.offsetPos.getZ());
                    }
                    if (iblockstate.getMaterial() != Material.AIR) {
                        int i = destroyblockprogress.getPartialBlockDamage();
                        TextureAtlasSprite textureatlassprite = renderGlobal.destroyBlockIcons[i];
                        BlockRendererDispatcher blockrendererdispatcher = renderGlobal.mc.getBlockRendererDispatcher();
                        try {
                            blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, renderGlobal.theWorld);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    worldRendererIn.setTranslation(-d0, -d1, -d2);
                    // TODO: Reverse the Matrix Transforms here
                    if (wrapper != null) {
                        tessellatorIn.draw();
                        worldRendererIn.begin(7, DefaultVertexFormats.BLOCK);
                        wrapper.wrapping.renderer.inverseTransform(partialTicks);
                    }
                }
            }
        }
        tessellatorIn.draw();
        worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D);
        renderGlobal.postRenderDamagedBlocks();
    }
}
Also used : BlockSkull(net.minecraft.block.BlockSkull) IBlockState(net.minecraft.block.state.IBlockState) BlockChest(net.minecraft.block.BlockChest) BlockEnderChest(net.minecraft.block.BlockEnderChest) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IOException(java.io.IOException) TileEntity(net.minecraft.tileentity.TileEntity) DestroyBlockProgress(net.minecraft.client.renderer.DestroyBlockProgress) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockSign(net.minecraft.block.BlockSign) Block(net.minecraft.block.Block) EnumSkyBlock(net.minecraft.world.EnumSkyBlock) BlockPos(net.minecraft.util.math.BlockPos) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 8 with BlockChest

use of net.minecraft.block.BlockChest in project SecurityCraft by Geforce132.

the class TileEntityKeypadChestRenderer method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntityKeypadChest p_180538_1_, double p_180538_2_, double p_180538_4_, double p_180538_6_, float p_180538_8_, int p_180538_9_) {
    int j;
    if (!p_180538_1_.hasWorldObj())
        j = 0;
    else {
        Block block = p_180538_1_.getBlockType();
        j = p_180538_1_.getBlockMetadata();
        if (block instanceof BlockChest && j == 0) {
            ((BlockChest) block).checkForSurroundingChests(p_180538_1_.getWorld(), p_180538_1_.getPos(), p_180538_1_.getWorld().getBlockState(p_180538_1_.getPos()));
            j = p_180538_1_.getBlockMetadata();
        }
        p_180538_1_.checkForAdjacentChests();
    }
    if (p_180538_1_.adjacentChestZNeg == null && p_180538_1_.adjacentChestXNeg == null) {
        ModelChest modelchest;
        if (p_180538_1_.adjacentChestXPos == null && p_180538_1_.adjacentChestZPos == null) {
            modelchest = field_147510_h;
            if (p_180538_9_ >= 0) {
                bindTexture(DESTROY_STAGES[p_180538_9_]);
                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 (field_147509_j)
                bindTexture(christmasNormal);
            else if (p_180538_1_.lidAngle >= 0.9)
                bindTexture(normalSingleActive);
            else
                bindTexture(normalSingleUnactive);
        } else {
            modelchest = field_147511_i;
            if (p_180538_9_ >= 0) {
                bindTexture(DESTROY_STAGES[p_180538_9_]);
                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 (field_147509_j)
                bindTexture(christmasDouble);
            else if (p_180538_1_.lidAngle >= 0.9)
                bindTexture(normalDoubleActive);
            else
                bindTexture(normalDoubleUnactive);
        }
        GlStateManager.pushMatrix();
        GlStateManager.enableRescaleNormal();
        if (p_180538_9_ < 0)
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.translate((float) p_180538_2_, (float) p_180538_4_ + 1.0F, (float) p_180538_6_ + 1.0F);
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        GlStateManager.translate(0.5F, 0.5F, 0.5F);
        short short1 = 0;
        if (j == 2)
            short1 = 180;
        if (j == 3)
            short1 = 0;
        if (j == 4)
            short1 = 90;
        if (j == 5)
            short1 = -90;
        if (j == 2 && p_180538_1_.adjacentChestXPos != null)
            GlStateManager.translate(1.0F, 0.0F, 0.0F);
        if (j == 5 && p_180538_1_.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 = p_180538_1_.prevLidAngle + (p_180538_1_.lidAngle - p_180538_1_.prevLidAngle) * p_180538_8_;
        float f2;
        if (p_180538_1_.adjacentChestZNeg != null) {
            f2 = p_180538_1_.adjacentChestZNeg.prevLidAngle + (p_180538_1_.adjacentChestZNeg.lidAngle - p_180538_1_.adjacentChestZNeg.prevLidAngle) * p_180538_8_;
            if (f2 > f1)
                f1 = f2;
        }
        if (p_180538_1_.adjacentChestXNeg != null) {
            f2 = p_180538_1_.adjacentChestXNeg.prevLidAngle + (p_180538_1_.adjacentChestXNeg.lidAngle - p_180538_1_.adjacentChestXNeg.prevLidAngle) * p_180538_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();
        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        if (p_180538_9_ >= 0) {
            GlStateManager.matrixMode(5890);
            GlStateManager.popMatrix();
            GlStateManager.matrixMode(5888);
        }
    }
}
Also used : ModelChest(net.minecraft.client.model.ModelChest) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Example 9 with BlockChest

use of net.minecraft.block.BlockChest in project SecurityCraft by Geforce132.

the class TileEntityKeypadChestRenderer method render.

@Override
public void render(TileEntityKeypadChest te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    int j;
    if (!te.hasWorld())
        j = 0;
    else {
        Block block = te.getBlockType();
        j = te.getBlockMetadata();
        if (block instanceof BlockChest && j == 0) {
            ((BlockChest) block).checkForSurroundingChests(te.getWorld(), te.getPos(), te.getWorld().getBlockState(te.getPos()));
            j = te.getBlockMetadata();
        }
        te.checkForAdjacentChests();
    }
    if (te.adjacentChestZNeg == null && te.adjacentChestXNeg == null) {
        ModelChest modelchest;
        if (te.adjacentChestXPos == null && te.adjacentChestZPos == null) {
            modelchest = field_147510_h;
            if (destroyStage >= 0) {
                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 (field_147509_j)
                bindTexture(christmasNormal);
            else if (te.lidAngle >= 0.9)
                bindTexture(normalSingleActive);
            else
                bindTexture(normalSingleUnactive);
        } else {
            modelchest = field_147511_i;
            if (destroyStage >= 0) {
                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 (field_147509_j)
                bindTexture(christmasDouble);
            else if (te.lidAngle >= 0.9)
                bindTexture(normalDoubleActive);
            else
                bindTexture(normalDoubleUnactive);
        }
        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 (j == 2)
            short1 = 180;
        if (j == 3)
            short1 = 0;
        if (j == 4)
            short1 = 90;
        if (j == 5)
            short1 = -90;
        if (j == 2 && te.adjacentChestXPos != null)
            GlStateManager.translate(1.0F, 0.0F, 0.0F);
        if (j == 5 && te.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 = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
        float f2;
        if (te.adjacentChestZNeg != null) {
            f2 = te.adjacentChestZNeg.prevLidAngle + (te.adjacentChestZNeg.lidAngle - te.adjacentChestZNeg.prevLidAngle) * partialTicks;
            if (f2 > f1)
                f1 = f2;
        }
        if (te.adjacentChestXNeg != null) {
            f2 = te.adjacentChestXNeg.prevLidAngle + (te.adjacentChestXNeg.lidAngle - te.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) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Example 10 with BlockChest

use of net.minecraft.block.BlockChest in project SecurityCraft by Geforce132.

the class TileEntityKeypadChestRenderer method func_180538_a.

public void func_180538_a(TileEntityChest p_180538_1_, double p_180538_2_, double p_180538_4_, double p_180538_6_, float p_180538_8_, int p_180538_9_) {
    int j;
    if (!p_180538_1_.hasWorldObj())
        j = 0;
    else {
        Block block = p_180538_1_.getBlockType();
        j = p_180538_1_.getBlockMetadata();
        if (block instanceof BlockChest && j == 0) {
            ((BlockChest) block).checkForSurroundingChests(p_180538_1_.getWorld(), p_180538_1_.getPos(), p_180538_1_.getWorld().getBlockState(p_180538_1_.getPos()));
            j = p_180538_1_.getBlockMetadata();
        }
        p_180538_1_.checkForAdjacentChests();
    }
    if (p_180538_1_.adjacentChestZNeg == null && p_180538_1_.adjacentChestXNeg == null) {
        ModelChest modelchest;
        if (p_180538_1_.adjacentChestXPos == null && p_180538_1_.adjacentChestZPos == null) {
            modelchest = field_147510_h;
            if (p_180538_9_ >= 0) {
                bindTexture(DESTROY_STAGES[p_180538_9_]);
                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 (field_147509_j)
                bindTexture(christmasNormal);
            else if (p_180538_1_.lidAngle >= 0.9)
                bindTexture(normalSingleActive);
            else
                bindTexture(normalSingleUnactive);
        } else {
            modelchest = field_147511_i;
            if (p_180538_9_ >= 0) {
                bindTexture(DESTROY_STAGES[p_180538_9_]);
                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 (field_147509_j)
                bindTexture(christmasDouble);
            else if (p_180538_1_.lidAngle >= 0.9)
                bindTexture(normalDoubleActive);
            else
                bindTexture(normalDoubleUnactive);
        }
        GlStateManager.pushMatrix();
        GlStateManager.enableRescaleNormal();
        if (p_180538_9_ < 0)
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.translate((float) p_180538_2_, (float) p_180538_4_ + 1.0F, (float) p_180538_6_ + 1.0F);
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        GlStateManager.translate(0.5F, 0.5F, 0.5F);
        short short1 = 0;
        if (j == 2)
            short1 = 180;
        if (j == 3)
            short1 = 0;
        if (j == 4)
            short1 = 90;
        if (j == 5)
            short1 = -90;
        if (j == 2 && p_180538_1_.adjacentChestXPos != null)
            GlStateManager.translate(1.0F, 0.0F, 0.0F);
        if (j == 5 && p_180538_1_.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 = p_180538_1_.prevLidAngle + (p_180538_1_.lidAngle - p_180538_1_.prevLidAngle) * p_180538_8_;
        float f2;
        if (p_180538_1_.adjacentChestZNeg != null) {
            f2 = p_180538_1_.adjacentChestZNeg.prevLidAngle + (p_180538_1_.adjacentChestZNeg.lidAngle - p_180538_1_.adjacentChestZNeg.prevLidAngle) * p_180538_8_;
            if (f2 > f1)
                f1 = f2;
        }
        if (p_180538_1_.adjacentChestXNeg != null) {
            f2 = p_180538_1_.adjacentChestXNeg.prevLidAngle + (p_180538_1_.adjacentChestXNeg.lidAngle - p_180538_1_.adjacentChestXNeg.prevLidAngle) * p_180538_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();
        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        if (p_180538_9_ >= 0) {
            GlStateManager.matrixMode(5890);
            GlStateManager.popMatrix();
            GlStateManager.matrixMode(5888);
        }
    }
}
Also used : ModelChest(net.minecraft.client.model.ModelChest) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Aggregations

Block (net.minecraft.block.Block)10 BlockChest (net.minecraft.block.BlockChest)10 ModelChest (net.minecraft.client.model.ModelChest)5 IInventory (net.minecraft.inventory.IInventory)3 TileEntity (net.minecraft.tileentity.TileEntity)3 IBlockState (net.minecraft.block.state.IBlockState)2 BlockPos (net.minecraft.util.math.BlockPos)2 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)1 IOException (java.io.IOException)1 List (java.util.List)1 BlockEnderChest (net.minecraft.block.BlockEnderChest)1 BlockMobSpawner (net.minecraft.block.BlockMobSpawner)1 BlockSign (net.minecraft.block.BlockSign)1 BlockSkull (net.minecraft.block.BlockSkull)1 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)1 DestroyBlockProgress (net.minecraft.client.renderer.DestroyBlockProgress)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 EntityList (net.minecraft.entity.EntityList)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 SPacketUpdateTileEntity (net.minecraft.network.play.server.SPacketUpdateTileEntity)1