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;
}
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);
}
}
}
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();
}
}
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);
}
}
}
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;
}
Aggregations