Search in sources :

Example 31 with BlockChest

use of net.minecraft.block.BlockChest in project kull by Sxmurai.

the class RenderGlobal method renderEntities.

public void renderEntities(Entity renderViewEntity, ICamera camera, float partialTicks) {
    if (this.renderEntitiesStartupCounter > 0) {
        --this.renderEntitiesStartupCounter;
    } else {
        double d0 = renderViewEntity.prevPosX + (renderViewEntity.posX - renderViewEntity.prevPosX) * (double) partialTicks;
        double d1 = renderViewEntity.prevPosY + (renderViewEntity.posY - renderViewEntity.prevPosY) * (double) partialTicks;
        double d2 = renderViewEntity.prevPosZ + (renderViewEntity.posZ - renderViewEntity.prevPosZ) * (double) partialTicks;
        this.theWorld.theProfiler.startSection("prepare");
        TileEntityRendererDispatcher.instance.cacheActiveRenderInfo(this.theWorld, this.mc.getTextureManager(), this.mc.fontRendererObj, this.mc.getRenderViewEntity(), partialTicks);
        this.renderManager.cacheActiveRenderInfo(this.theWorld, this.mc.fontRendererObj, this.mc.getRenderViewEntity(), this.mc.pointedEntity, this.mc.gameSettings, partialTicks);
        this.countEntitiesTotal = 0;
        this.countEntitiesRendered = 0;
        this.countEntitiesHidden = 0;
        Entity entity = this.mc.getRenderViewEntity();
        double d3 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
        double d4 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
        double d5 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
        TileEntityRendererDispatcher.staticPlayerX = d3;
        TileEntityRendererDispatcher.staticPlayerY = d4;
        TileEntityRendererDispatcher.staticPlayerZ = d5;
        this.renderManager.setRenderPosition(d3, d4, d5);
        this.mc.entityRenderer.enableLightmap();
        this.theWorld.theProfiler.endStartSection("global");
        List<Entity> list = this.theWorld.getLoadedEntityList();
        this.countEntitiesTotal = list.size();
        for (int i = 0; i < this.theWorld.weatherEffects.size(); ++i) {
            Entity entity1 = (Entity) this.theWorld.weatherEffects.get(i);
            ++this.countEntitiesRendered;
            if (entity1.isInRangeToRender3d(d0, d1, d2)) {
                this.renderManager.renderEntitySimple(entity1, partialTicks);
            }
        }
        if (this.isRenderEntityOutlines()) {
            GlStateManager.depthFunc(519);
            GlStateManager.disableFog();
            this.entityOutlineFramebuffer.framebufferClear();
            this.entityOutlineFramebuffer.bindFramebuffer(false);
            this.theWorld.theProfiler.endStartSection("entityOutlines");
            RenderHelper.disableStandardItemLighting();
            this.renderManager.setRenderOutlines(true);
            for (int j = 0; j < list.size(); ++j) {
                Entity entity3 = (Entity) list.get(j);
                boolean flag = this.mc.getRenderViewEntity() instanceof EntityLivingBase && ((EntityLivingBase) this.mc.getRenderViewEntity()).isPlayerSleeping();
                boolean flag1 = entity3.isInRangeToRender3d(d0, d1, d2) && (entity3.ignoreFrustumCheck || camera.isBoundingBoxInFrustum(entity3.getEntityBoundingBox()) || entity3.riddenByEntity == this.mc.thePlayer) && entity3 instanceof EntityPlayer;
                if ((entity3 != this.mc.getRenderViewEntity() || this.mc.gameSettings.thirdPersonView != 0 || flag) && flag1) {
                    this.renderManager.renderEntitySimple(entity3, partialTicks);
                }
            }
            this.renderManager.setRenderOutlines(false);
            RenderHelper.enableStandardItemLighting();
            GlStateManager.depthMask(false);
            this.entityOutlineShader.loadShaderGroup(partialTicks);
            GlStateManager.enableLighting();
            GlStateManager.depthMask(true);
            this.mc.getFramebuffer().bindFramebuffer(false);
            GlStateManager.enableFog();
            GlStateManager.enableBlend();
            GlStateManager.enableColorMaterial();
            GlStateManager.depthFunc(515);
            GlStateManager.enableDepth();
            GlStateManager.enableAlpha();
        }
        this.theWorld.theProfiler.endStartSection("entities");
        label738: for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation : this.renderInfos) {
            Chunk chunk = this.theWorld.getChunkFromBlockCoords(renderglobal$containerlocalrenderinformation.renderChunk.getPosition());
            ClassInheritanceMultiMap<Entity> classinheritancemultimap = chunk.getEntityLists()[renderglobal$containerlocalrenderinformation.renderChunk.getPosition().getY() / 16];
            if (!classinheritancemultimap.isEmpty()) {
                Iterator iterator = classinheritancemultimap.iterator();
                while (true) {
                    Entity entity2;
                    boolean flag2;
                    while (true) {
                        if (!iterator.hasNext()) {
                            continue label738;
                        }
                        entity2 = (Entity) iterator.next();
                        flag2 = this.renderManager.shouldRender(entity2, camera, d0, d1, d2) || entity2.riddenByEntity == this.mc.thePlayer;
                        if (!flag2) {
                            break;
                        }
                        boolean flag3 = this.mc.getRenderViewEntity() instanceof EntityLivingBase ? ((EntityLivingBase) this.mc.getRenderViewEntity()).isPlayerSleeping() : false;
                        if ((entity2 != this.mc.getRenderViewEntity() || this.mc.gameSettings.thirdPersonView != 0 || flag3) && (entity2.posY < 0.0D || entity2.posY >= 256.0D || this.theWorld.isBlockLoaded(new BlockPos(entity2)))) {
                            ++this.countEntitiesRendered;
                            this.renderManager.renderEntitySimple(entity2, partialTicks);
                            break;
                        }
                    }
                    if (!flag2 && entity2 instanceof EntityWitherSkull) {
                        this.mc.getRenderManager().renderWitherSkull(entity2, partialTicks);
                    }
                }
            }
        }
        this.theWorld.theProfiler.endStartSection("blockentities");
        RenderHelper.enableStandardItemLighting();
        for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation1 : this.renderInfos) {
            List<TileEntity> list1 = renderglobal$containerlocalrenderinformation1.renderChunk.getCompiledChunk().getTileEntities();
            if (!list1.isEmpty()) {
                for (TileEntity tileentity2 : list1) {
                    TileEntityRendererDispatcher.instance.renderTileEntity(tileentity2, partialTicks, -1);
                }
            }
        }
        synchronized (this.field_181024_n) {
            for (TileEntity tileentity : this.field_181024_n) {
                TileEntityRendererDispatcher.instance.renderTileEntity(tileentity, partialTicks, -1);
            }
        }
        this.preRenderDamagedBlocks();
        for (DestroyBlockProgress destroyblockprogress : this.damagedBlocks.values()) {
            BlockPos blockpos = destroyblockprogress.getPosition();
            TileEntity tileentity1 = this.theWorld.getTileEntity(blockpos);
            if (tileentity1 instanceof TileEntityChest) {
                TileEntityChest tileentitychest = (TileEntityChest) tileentity1;
                if (tileentitychest.adjacentChestXNeg != null) {
                    blockpos = blockpos.offset(EnumFacing.WEST);
                    tileentity1 = this.theWorld.getTileEntity(blockpos);
                } else if (tileentitychest.adjacentChestZNeg != null) {
                    blockpos = blockpos.offset(EnumFacing.NORTH);
                    tileentity1 = this.theWorld.getTileEntity(blockpos);
                }
            }
            Block block = this.theWorld.getBlockState(blockpos).getBlock();
            if (tileentity1 != null && (block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull)) {
                TileEntityRendererDispatcher.instance.renderTileEntity(tileentity1, partialTicks, destroyblockprogress.getPartialBlockDamage());
            }
        }
        this.postRenderDamagedBlocks();
        this.mc.entityRenderer.disableLightmap();
        this.mc.mcProfiler.endSection();
    }
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityWitherSkull(net.minecraft.entity.projectile.EntityWitherSkull) ClassInheritanceMultiMap(net.minecraft.util.ClassInheritanceMultiMap) TileEntityChest(net.minecraft.tileentity.TileEntityChest) BlockSkull(net.minecraft.block.BlockSkull) BlockChest(net.minecraft.block.BlockChest) BlockEnderChest(net.minecraft.block.BlockEnderChest) RenderChunk(net.minecraft.client.renderer.chunk.RenderChunk) CompiledChunk(net.minecraft.client.renderer.chunk.CompiledChunk) Chunk(net.minecraft.world.chunk.Chunk) TileEntity(net.minecraft.tileentity.TileEntity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Iterator(java.util.Iterator) BlockSign(net.minecraft.block.BlockSign) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.BlockPos)

Example 32 with BlockChest

use of net.minecraft.block.BlockChest in project kull by Sxmurai.

the class ItemInWorldManager method activateBlockOrUseItem.

/**
 * Activate the clicked on block, otherwise use the held item.
 */
public boolean activateBlockOrUseItem(EntityPlayer player, World worldIn, ItemStack stack, BlockPos pos, EnumFacing side, float offsetX, float offsetY, float offsetZ) {
    if (this.gameType == WorldSettings.GameType.SPECTATOR) {
        TileEntity tileentity = worldIn.getTileEntity(pos);
        if (tileentity instanceof ILockableContainer) {
            Block block = worldIn.getBlockState(pos).getBlock();
            ILockableContainer ilockablecontainer = (ILockableContainer) tileentity;
            if (ilockablecontainer instanceof TileEntityChest && block instanceof BlockChest) {
                ilockablecontainer = ((BlockChest) block).getLockableContainer(worldIn, pos);
            }
            if (ilockablecontainer != null) {
                player.displayGUIChest(ilockablecontainer);
                return true;
            }
        } else if (tileentity instanceof IInventory) {
            player.displayGUIChest((IInventory) tileentity);
            return true;
        }
        return false;
    } else {
        if (!player.isSneaking() || player.getHeldItem() == null) {
            IBlockState iblockstate = worldIn.getBlockState(pos);
            if (iblockstate.getBlock().onBlockActivated(worldIn, pos, iblockstate, player, side, offsetX, offsetY, offsetZ)) {
                return true;
            }
        }
        if (stack == null) {
            return false;
        } else if (this.isCreative()) {
            int j = stack.getMetadata();
            int i = stack.stackSize;
            boolean flag = stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
            stack.setItemDamage(j);
            stack.stackSize = i;
            return flag;
        } else {
            return stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILockableContainer(net.minecraft.world.ILockableContainer) IInventory(net.minecraft.inventory.IInventory) TileEntityChest(net.minecraft.tileentity.TileEntityChest) IBlockState(net.minecraft.block.state.IBlockState) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Example 33 with BlockChest

use of net.minecraft.block.BlockChest in project GTplusplus by GTNewHorizons.

the class TileEntityRoundRobinator method tryFindInvetoryAtXYZ.

public static IInventory tryFindInvetoryAtXYZ(World aWorld, double aX, double aY, double aZ) {
    IInventory iinventory = null;
    int sX = MathHelper.floor_double(aX);
    int sY = MathHelper.floor_double(aY);
    int sZ = MathHelper.floor_double(aZ);
    TileEntity tileentity = aWorld.getTileEntity(sX, sY, sZ);
    if (tileentity != null && tileentity instanceof IInventory) {
        iinventory = (IInventory) tileentity;
        if (iinventory instanceof TileEntityChest) {
            Block block = aWorld.getBlock(sX, sY, sZ);
            if (block instanceof BlockChest) {
                iinventory = ((BlockChest) block).func_149951_m(aWorld, sX, sY, sZ);
            }
        }
    }
    if (iinventory == null) {
        List list = aWorld.getEntitiesWithinAABBExcludingEntity((Entity) null, AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1.0D, aY + 1.0D, aZ + 1.0D), IEntitySelector.selectInventories);
        if (list != null && list.size() > 0) {
            iinventory = (IInventory) list.get(aWorld.rand.nextInt(list.size()));
        }
    }
    return iinventory;
}
Also used : IInventory(net.minecraft.inventory.IInventory) S35PacketUpdateTileEntity(net.minecraft.network.play.server.S35PacketUpdateTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityChest(net.minecraft.tileentity.TileEntityChest) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block) NBTTagList(net.minecraft.nbt.NBTTagList) List(java.util.List)

Example 34 with BlockChest

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

the class ItemInWorldManager method activateBlockOrUseItem.

/**
 * Activate the clicked on block, otherwise use the held item.
 */
public boolean activateBlockOrUseItem(EntityPlayer player, World worldIn, ItemStack stack, BlockPos pos, EnumFacing side, float offsetX, float offsetY, float offsetZ) {
    if (this.gameType == WorldSettings.GameType.SPECTATOR) {
        TileEntity tileentity = worldIn.getTileEntity(pos);
        if (tileentity instanceof ILockableContainer) {
            Block block = worldIn.getBlockState(pos).getBlock();
            ILockableContainer ilockablecontainer = (ILockableContainer) tileentity;
            if (ilockablecontainer instanceof TileEntityChest && block instanceof BlockChest) {
                ilockablecontainer = ((BlockChest) block).getLockableContainer(worldIn, pos);
            }
            if (ilockablecontainer != null) {
                player.displayGUIChest(ilockablecontainer);
                return true;
            }
        } else if (tileentity instanceof IInventory) {
            player.displayGUIChest((IInventory) tileentity);
            return true;
        }
        return false;
    } else {
        if (!player.isSneaking() || player.getHeldItem() == null) {
            IBlockState iblockstate = worldIn.getBlockState(pos);
            if (iblockstate.getBlock().onBlockActivated(worldIn, pos, iblockstate, player, side, offsetX, offsetY, offsetZ)) {
                return true;
            }
        }
        if (stack == null) {
            return false;
        } else if (this.isCreative()) {
            int j = stack.getMetadata();
            int i = stack.stackSize;
            boolean flag = stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
            stack.setItemDamage(j);
            stack.stackSize = i;
            return flag;
        } else {
            return stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILockableContainer(net.minecraft.world.ILockableContainer) IInventory(net.minecraft.inventory.IInventory) TileEntityChest(net.minecraft.tileentity.TileEntityChest) IBlockState(net.minecraft.block.state.IBlockState) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Example 35 with BlockChest

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

the class TileEntityHopper method getInventoryAtPosition.

/**
 * Returns the IInventory (if applicable) of the TileEntity at the specified position
 */
public static IInventory getInventoryAtPosition(World worldIn, double x, double y, double z) {
    IInventory iinventory = null;
    int i = MathHelper.floor_double(x);
    int j = MathHelper.floor_double(y);
    int k = MathHelper.floor_double(z);
    BlockPos blockpos = new BlockPos(i, j, k);
    Block block = worldIn.getBlockState(blockpos).getBlock();
    if (block.hasTileEntity()) {
        TileEntity tileentity = worldIn.getTileEntity(blockpos);
        if (tileentity instanceof IInventory) {
            iinventory = (IInventory) tileentity;
            if (iinventory instanceof TileEntityChest && block instanceof BlockChest) {
                iinventory = ((BlockChest) block).getLockableContainer(worldIn, blockpos);
            }
        }
    }
    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.selectInventories);
        if (list.size() > 0) {
            iinventory = (IInventory) list.get(worldIn.rand.nextInt(list.size()));
        }
    }
    return iinventory;
}
Also used : IInventory(net.minecraft.inventory.IInventory) Entity(net.minecraft.entity.Entity) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Aggregations

BlockChest (net.minecraft.block.BlockChest)45 Block (net.minecraft.block.Block)42 TileEntity (net.minecraft.tileentity.TileEntity)20 IInventory (net.minecraft.inventory.IInventory)18 IBlockState (net.minecraft.block.state.IBlockState)16 TileEntityChest (net.minecraft.tileentity.TileEntityChest)14 ModelChest (net.minecraft.client.model.ModelChest)13 Entity (net.minecraft.entity.Entity)9 BlockPos (net.minecraft.util.math.BlockPos)9 BlockEnderChest (net.minecraft.block.BlockEnderChest)8 BlockSign (net.minecraft.block.BlockSign)8 BlockSkull (net.minecraft.block.BlockSkull)8 ILockableContainer (net.minecraft.world.ILockableContainer)7 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)6 BlockPos (net.minecraft.util.BlockPos)6 BlockCommandBlock (net.minecraft.block.BlockCommandBlock)4 ItemBlock (net.minecraft.item.ItemBlock)4 EnumActionResult (net.minecraft.util.EnumActionResult)4 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)4 List (java.util.List)3