Search in sources :

Example 11 with BlockChest

use of net.minecraft.block.BlockChest in project clientcommands by Earthcomputer.

the class CommandFindItem method shouldSearch.

private static boolean shouldSearch(World world, BlockPos pos) {
    Block block = world.getBlockState(pos).getBlock();
    TileEntity te = world.getTileEntity(pos);
    if (block == Blocks.ENDER_CHEST) {
        return true;
    }
    if (block instanceof BlockChest) {
        if (!(te instanceof TileEntityChest)) {
            return false;
        }
        TileEntityChest chest = (TileEntityChest) te;
        if (!chest.adjacentChestChecked) {
            chest.checkForAdjacentChests();
        }
        return chest.adjacentChestXNeg == null && chest.adjacentChestZNeg == null;
    }
    if (te instanceof IInventory) {
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) TileEntityChest(net.minecraft.tileentity.TileEntityChest) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Example 12 with BlockChest

use of net.minecraft.block.BlockChest in project UtilityClient2 by Utility-Client.

the class TileEntityChestRenderer method renderTileEntityAt.

public void renderTileEntityAt(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage) {
    GlStateManager.enableDepth();
    GlStateManager.depthFunc(515);
    GlStateManager.depthMask(true);
    int i;
    if (!te.hasWorldObj()) {
        i = 0;
    } else {
        Block block = te.getBlockType();
        i = te.getBlockMetadata();
        if (block instanceof BlockChest && i == 0) {
            ((BlockChest) block).checkForSurroundingChests(te.getWorld(), te.getPos(), te.getWorld().getBlockState(te.getPos()));
            i = te.getBlockMetadata();
        }
        te.checkForAdjacentChests();
    }
    if (te.adjacentChestZNeg == null && te.adjacentChestXNeg == null) {
        ModelChest modelchest;
        if (te.adjacentChestXPos == null && te.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 (te.getChestType() == 1) {
                this.bindTexture(textureTrapped);
            } else if (this.isChristams) {
                this.bindTexture(textureChristmas);
            } else {
                this.bindTexture(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 (te.getChestType() == 1) {
                this.bindTexture(textureTrappedDouble);
            } else if (this.isChristams) {
                this.bindTexture(textureChristmasDouble);
            } else {
                this.bindTexture(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);
        int j = 0;
        if (i == 2) {
            j = 180;
        }
        if (i == 3) {
            j = 0;
        }
        if (i == 4) {
            j = 90;
        }
        if (i == 5) {
            j = -90;
        }
        if (i == 2 && te.adjacentChestXPos != null) {
            GlStateManager.translate(1.0F, 0.0F, 0.0F);
        }
        if (i == 5 && te.adjacentChestZPos != null) {
            GlStateManager.translate(0.0F, 0.0F, -1.0F);
        }
        GlStateManager.rotate((float) j, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(-0.5F, -0.5F, -0.5F);
        float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
        if (te.adjacentChestZNeg != null) {
            float f1 = te.adjacentChestZNeg.prevLidAngle + (te.adjacentChestZNeg.lidAngle - te.adjacentChestZNeg.prevLidAngle) * partialTicks;
            if (f1 > f) {
                f = f1;
            }
        }
        if (te.adjacentChestXNeg != null) {
            float f2 = te.adjacentChestXNeg.prevLidAngle + (te.adjacentChestXNeg.lidAngle - te.adjacentChestXNeg.prevLidAngle) * partialTicks;
            if (f2 > f) {
                f = f2;
            }
        }
        f = 1.0F - f;
        f = 1.0F - f * f * f;
        modelchest.chestLid.rotateAngleX = -(f * (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 13 with BlockChest

use of net.minecraft.block.BlockChest in project CumServerPro by MCUmbrella.

the class RenderGlobal method drawBlockDamageTexture.

public void drawBlockDamageTexture(Tessellator tessellatorIn, BufferBuilder bufferBuilderIn, Entity entityIn, float partialTicks) {
    double d3 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
    double d4 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
    double d5 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;
    if (!this.damagedBlocks.isEmpty()) {
        this.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        this.preRenderDamagedBlocks();
        bufferBuilderIn.begin(7, DefaultVertexFormats.BLOCK);
        bufferBuilderIn.setTranslation(-d3, -d4, -d5);
        bufferBuilderIn.noColor();
        Iterator<DestroyBlockProgress> iterator = this.damagedBlocks.values().iterator();
        while (iterator.hasNext()) {
            DestroyBlockProgress destroyblockprogress = iterator.next();
            BlockPos blockpos = destroyblockprogress.getPosition();
            double d6 = (double) blockpos.getX() - d3;
            double d7 = (double) blockpos.getY() - d4;
            double d8 = (double) blockpos.getZ() - d5;
            Block block = this.world.getBlockState(blockpos).getBlock();
            TileEntity te = this.world.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) {
                if (d6 * d6 + d7 * d7 + d8 * d8 > 1024.0D) {
                    iterator.remove();
                } else {
                    IBlockState iblockstate = this.world.getBlockState(blockpos);
                    if (iblockstate.getMaterial() != Material.AIR) {
                        int k1 = destroyblockprogress.getPartialBlockDamage();
                        TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[k1];
                        BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
                        blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, this.world);
                    }
                }
            }
        }
        tessellatorIn.draw();
        bufferBuilderIn.setTranslation(0.0D, 0.0D, 0.0D);
        this.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) TileEntity(net.minecraft.tileentity.TileEntity) BlockSign(net.minecraft.block.BlockSign) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos)

Example 14 with BlockChest

use of net.minecraft.block.BlockChest in project CumServerPro by MCUmbrella.

the class TileEntityChestRenderer method render.

public void render(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    GlStateManager.enableDepth();
    GlStateManager.depthFunc(515);
    GlStateManager.depthMask(true);
    int i;
    if (te.hasWorld()) {
        Block block = te.getBlockType();
        i = te.getBlockMetadata();
        if (block instanceof BlockChest && i == 0) {
            ((BlockChest) block).checkForSurroundingChests(te.getWorld(), te.getPos(), te.getWorld().getBlockState(te.getPos()));
            i = te.getBlockMetadata();
        }
        te.checkForAdjacentChests();
    } else {
        i = 0;
    }
    if (te.adjacentChestZNeg == null && te.adjacentChestXNeg == null) {
        ModelChest modelchest;
        if (te.adjacentChestXPos == null && te.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 (this.isChristmas) {
                this.bindTexture(TEXTURE_CHRISTMAS);
            } else if (te.getChestType() == BlockChest.Type.TRAP) {
                this.bindTexture(TEXTURE_TRAPPED);
            } else {
                this.bindTexture(TEXTURE_NORMAL);
            }
        } 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 (this.isChristmas) {
                this.bindTexture(TEXTURE_CHRISTMAS_DOUBLE);
            } else if (te.getChestType() == BlockChest.Type.TRAP) {
                this.bindTexture(TEXTURE_TRAPPED_DOUBLE);
            } else {
                this.bindTexture(TEXTURE_NORMAL_DOUBLE);
            }
        }
        GlStateManager.pushMatrix();
        GlStateManager.enableRescaleNormal();
        if (destroyStage < 0) {
            GlStateManager.color(1.0F, 1.0F, 1.0F, alpha);
        }
        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);
        int j = 0;
        if (i == 2) {
            j = 180;
        }
        if (i == 3) {
            j = 0;
        }
        if (i == 4) {
            j = 90;
        }
        if (i == 5) {
            j = -90;
        }
        if (i == 2 && te.adjacentChestXPos != null) {
            GlStateManager.translate(1.0F, 0.0F, 0.0F);
        }
        if (i == 5 && te.adjacentChestZPos != null) {
            GlStateManager.translate(0.0F, 0.0F, -1.0F);
        }
        GlStateManager.rotate((float) j, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(-0.5F, -0.5F, -0.5F);
        float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
        if (te.adjacentChestZNeg != null) {
            float f1 = te.adjacentChestZNeg.prevLidAngle + (te.adjacentChestZNeg.lidAngle - te.adjacentChestZNeg.prevLidAngle) * partialTicks;
            if (f1 > f) {
                f = f1;
            }
        }
        if (te.adjacentChestXNeg != null) {
            float f2 = te.adjacentChestXNeg.prevLidAngle + (te.adjacentChestXNeg.lidAngle - te.adjacentChestXNeg.prevLidAngle) * partialTicks;
            if (f2 > f) {
                f = f2;
            }
        }
        f = 1.0F - f;
        f = 1.0F - f * f * f;
        modelchest.chestLid.rotateAngleX = -(f * ((float) Math.PI / 2F));
        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 15 with BlockChest

use of net.minecraft.block.BlockChest in project CumServerPro by MCUmbrella.

the class TileEntityHopper method getInventoryAtPosition.

public static IInventory getInventoryAtPosition(World worldIn, double x, double y, double z) {
    IInventory iinventory = null;
    int i = MathHelper.floor(x);
    int j = MathHelper.floor(y);
    int k = MathHelper.floor(z);
    BlockPos blockpos = new BlockPos(i, j, k);
    // Spigot
    if (!worldIn.isBlockLoaded(blockpos))
        return null;
    net.minecraft.block.state.IBlockState state = worldIn.getBlockState(blockpos);
    Block block = state.getBlock();
    if (block.hasTileEntity(state)) {
        TileEntity tileentity = worldIn.getTileEntity(blockpos);
        if (tileentity instanceof IInventory) {
            iinventory = (IInventory) tileentity;
            if (iinventory instanceof TileEntityChest && block instanceof BlockChest) {
                iinventory = ((BlockChest) block).getContainer(worldIn, blockpos, true);
            }
        }
    }
    if (iinventory == null) {
        List<Entity> list = worldIn.getEntitiesInAABBexcluding((Entity) null, new AxisAlignedBB(x - 0.5D, y - 0.5D, z - 0.5D, x + 0.5D, y + 0.5D, z + 0.5D), EntitySelectors.HAS_INVENTORY);
        if (!list.isEmpty()) {
            iinventory = (IInventory) list.get(worldIn.rand.nextInt(list.size()));
        }
    }
    return iinventory;
}
Also used : IInventory(net.minecraft.inventory.IInventory) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) CraftHumanEntity(org.bukkit.craftbukkit.entity.CraftHumanEntity) HumanEntity(org.bukkit.entity.HumanEntity) Entity(net.minecraft.entity.Entity) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BlockChest (net.minecraft.block.BlockChest)35 Block (net.minecraft.block.Block)32 TileEntity (net.minecraft.tileentity.TileEntity)15 IInventory (net.minecraft.inventory.IInventory)14 IBlockState (net.minecraft.block.state.IBlockState)12 ModelChest (net.minecraft.client.model.ModelChest)11 TileEntityChest (net.minecraft.tileentity.TileEntityChest)10 BlockPos (net.minecraft.util.math.BlockPos)9 Entity (net.minecraft.entity.Entity)5 ILockableContainer (net.minecraft.world.ILockableContainer)5 BlockCommandBlock (net.minecraft.block.BlockCommandBlock)4 BlockEnderChest (net.minecraft.block.BlockEnderChest)4 BlockSign (net.minecraft.block.BlockSign)4 BlockSkull (net.minecraft.block.BlockSkull)4 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)4 ItemBlock (net.minecraft.item.ItemBlock)4 ItemStack (net.minecraft.item.ItemStack)4 EnumActionResult (net.minecraft.util.EnumActionResult)4 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)4 BlockStructure (net.minecraft.block.BlockStructure)3