本文整理匯總了Java中net.minecraft.block.BlockChest類的典型用法代碼示例。如果您正苦於以下問題:Java BlockChest類的具體用法?Java BlockChest怎麽用?Java BlockChest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BlockChest類屬於net.minecraft.block包,在下文中一共展示了BlockChest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generate
import net.minecraft.block.BlockChest; //導入依賴的package包/類
@Override
public boolean generate(World worldIn, Random rand, BlockPos position) {
if(size.equals(BlockPos.ORIGIN) && rand.nextFloat() < this.chance)
{
worldIn.setBlockState(position, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[rand.nextInt(4)]), 3);
((TileEntityChest)worldIn.getTileEntity(position)).setLootTable(lootTable, rand.nextLong());
return false;
}
for(int x = 0; x < size.getX(); x++)
for(int z = 0; z < size.getZ(); z++)
if(rand.nextFloat() < this.chance)
{
BlockPos blockpos = new BlockPos(position.add(x, 0, z));
boolean flag = false;
for(EnumFacing facing : EnumFacing.HORIZONTALS)
if(worldIn.getBlockState(blockpos.offset(facing)).getBlock() == Blocks.CHEST)
flag = true;
if(flag || !worldIn.isAirBlock(blockpos))
continue;
if(setBlock)
worldIn.setBlockState(blockpos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[rand.nextInt(4)]), 3);
((TileEntityChest)worldIn.getTileEntity(blockpos)).setLootTable(lootTable, rand.nextLong());
}
return false;
}
示例2: postAddition
import net.minecraft.block.BlockChest; //導入依賴的package包/類
@Override
public void postAddition(World world, BlockPos pos, Random random) {
pos = pos.subtract(originAddition);
world.setBlockState(pos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[random.nextInt(4)]), 3);
if(world instanceof WorldServer && world.getTileEntity(pos) != null)
{
TileEntityChest chest = (TileEntityChest)world.getTileEntity(pos);
chest.setInventorySlotContents(13, HarshenUtils.getItemsFromLootTable(world, HarshenLootTables.shrine).get(0));
for(ItemStack stack : HarshenUtils.getItemsFromLootPool(world, HarshenLootTables.shrine, "extras"))
for(int count = 0; count < stack.getCount(); count++)
{
int slot = new Random().nextInt(27);
while(chest.getStackInSlot(slot).getItem() != Item.getItemFromBlock(Blocks.AIR))
slot = new Random().nextInt(27);
ItemStack stack1 = stack.copy();
stack1.setCount(1);
chest.setInventorySlotContents(slot, stack1);
}
}
}
示例3: openInventory
import net.minecraft.block.BlockChest; //導入依賴的package包/類
public void openInventory(EntityPlayer player)
{
if (!player.isSpectator())
{
if (this.numPlayersUsing < 0)
{
this.numPlayersUsing = 0;
}
++this.numPlayersUsing;
this.world.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing);
this.world.notifyNeighborsOfStateChange(this.pos, this.getBlockType(), false);
if (this.getChestType() == BlockChest.Type.TRAP)
{
this.world.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType(), false);
}
}
}
示例4: getInventory
import net.minecraft.block.BlockChest; //導入依賴的package包/類
public static IInventory getInventory(final TileEntity tile) {
if (tile instanceof IInventory) {
if (tile instanceof TileEntityChest) {
final int x = tile.xCoord;
final int y = tile.yCoord;
final int z = tile.zCoord;
final Block blockID = tile.getWorldObj().getBlock(x, y, z);
if (!tile.getWorldObj().isAirBlock(x, y, z) && blockID instanceof BlockChest) {
if (tile.getWorldObj().getBlock(x - 1, y, z) == blockID) {
return (IInventory)new InventoryLargeChest("container.chestDouble", (IInventory)tile.getWorldObj().getTileEntity(x - 1, y, z), (IInventory)tile);
}
if (tile.getWorldObj().getBlock(x + 1, y, z) == blockID) {
return (IInventory)new InventoryLargeChest("container.chestDouble", (IInventory)tile, (IInventory)tile.getWorldObj().getTileEntity(x + 1, y, z));
}
if (tile.getWorldObj().getBlock(x, y, z - 1) == blockID) {
return (IInventory)new InventoryLargeChest("container.chestDouble", (IInventory)tile.getWorldObj().getTileEntity(x, y, z - 1), (IInventory)tile);
}
if (tile.getWorldObj().getBlock(x, y, z + 1) == blockID) {
return (IInventory)new InventoryLargeChest("container.chestDouble", (IInventory)tile, (IInventory)tile.getWorldObj().getTileEntity(x, y, z + 1));
}
}
}
return (IInventory)tile;
}
return null;
}
示例5: getChestBlock
import net.minecraft.block.BlockChest; //導入依賴的package包/類
private IBlockState getChestBlock(int x, int z) {
IBlockState currentBlock;
if (x > 1) {
currentBlock = ((BlockChest) Blocks.CHEST).getStateFromMeta(4);
} else if (x < -1) {
currentBlock = ((BlockChest) Blocks.CHEST).getStateFromMeta(5);
} else if (z > 1) {
currentBlock = ((BlockChest) Blocks.CHEST).getStateFromMeta(2);
} else if (z < -1) {
currentBlock = ((BlockChest) Blocks.CHEST).getStateFromMeta(3);
} else {
currentBlock = Blocks.AIR.getDefaultState();
}
return currentBlock;
}
示例6: placeChest
import net.minecraft.block.BlockChest; //導入依賴的package包/類
protected boolean placeChest(World world, StructureBoundingBox box, Random rand, int x, int y, int z, EnumFacing f, boolean a) {
int i1 = this.getXWithOffset(x, z);
int j1 = this.getYWithOffset(y);
int k1 = this.getZWithOffset(x, z);
BlockPos pos = new BlockPos(i1, j1, k1);
if (f.getAxis() == Axis.Y)
f = EnumFacing.NORTH;
if (box.isVecInside(pos) && (world.getBlockState(pos).getBlock() != Blocks.CHEST)) {
world.setBlockState(pos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, f), 2);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityChest)
((TileEntityChest) tile).setLootTable(a ? loot2 : rand.nextInt(10) < 2 ? lootB : loot, rand.nextLong());
return true;
} else
return false;
}
示例7: openInventory
import net.minecraft.block.BlockChest; //導入依賴的package包/類
@Override
public void openInventory(EntityPlayer player) {
if (!player.isSpectator()) {
if (this.numPlayersUsing < 0) {
this.numPlayersUsing = 0;
}
++this.numPlayersUsing;
this.world.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing);
this.world.notifyNeighborsOfStateChange(this.pos, this.getBlockType(), false);
if (this.getChestType() == BlockChest.Type.TRAP) {
this.world.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType(), false);
}
}
}
示例8: func_96117_b
import net.minecraft.block.BlockChest; //導入依賴的package包/類
public static IInventory func_96117_b(World p_96117_0_, double p_96117_1_, double p_96117_3_, double p_96117_5_) {
IInventory var7 = null;
int var8 = MathHelper.func_76128_c(p_96117_1_);
int var9 = MathHelper.func_76128_c(p_96117_3_);
int var10 = MathHelper.func_76128_c(p_96117_5_);
TileEntity var11 = p_96117_0_.func_72796_p(var8, var9, var10);
if(var11 != null && var11 instanceof IInventory) {
var7 = (IInventory)var11;
if(var7 instanceof TileEntityChest) {
int var12 = p_96117_0_.func_72798_a(var8, var9, var10);
Block var13 = Block.field_71973_m[var12];
if(var13 instanceof BlockChest) {
var7 = ((BlockChest)var13).func_94442_h_(p_96117_0_, var8, var9, var10);
}
}
}
if(var7 == null) {
List var14 = p_96117_0_.func_94576_a((Entity)null, AxisAlignedBB.func_72332_a().func_72299_a(p_96117_1_, p_96117_3_, p_96117_5_, p_96117_1_ + 1.0D, p_96117_3_ + 1.0D, p_96117_5_ + 1.0D), IEntitySelector.field_96566_b);
if(var14 != null && var14.size() > 0) {
var7 = (IInventory)var14.get(p_96117_0_.field_73012_v.nextInt(var14.size()));
}
}
return var7;
}
示例9: isChestAt
import net.minecraft.block.BlockChest; //導入依賴的package包/類
private boolean isChestAt(BlockPos posIn)
{
if (this.worldObj == null)
{
return false;
}
else
{
Block block = this.worldObj.getBlockState(posIn).getBlock();
return block instanceof BlockChest && ((BlockChest)block).chestType == this.getChestType();
}
}
示例10: closeInventory
import net.minecraft.block.BlockChest; //導入依賴的package包/類
public void closeInventory(EntityPlayer player)
{
if (!player.isSpectator() && this.getBlockType() instanceof BlockChest)
{
--this.numPlayersUsing;
this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing);
this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType());
this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
}
}
示例11: getChestType
import net.minecraft.block.BlockChest; //導入依賴的package包/類
public int getChestType()
{
if (this.cachedChestType == -1)
{
if (this.worldObj == null || !(this.getBlockType() instanceof BlockChest))
{
return 0;
}
this.cachedChestType = ((BlockChest)this.getBlockType()).chestType;
}
return this.cachedChestType;
}
示例12: drawChestESP
import net.minecraft.block.BlockChest; //導入依賴的package包/類
public void drawChestESP(TileEntityChest chest, double x, double y, double z) {
if(isEnabled()) {
boolean isAdjacent = chest.adjacentChestChecked;
if(chest.adjacentChestXPos != null)
{
if(chest.getChestType() == BlockChest.Type.TRAP) { //if is trapped chest
RenderUtils.blockESP(chest.getPos(), Color.red, 1.0, 2.0);
}else{
RenderUtils.blockESP(chest.getPos(), Color.green, 1.0, 2.0);
}
}
if(chest.adjacentChestZPos != null)
{
if(chest.getChestType() == BlockChest.Type.TRAP) { //if is trapped chest
RenderUtils.blockESP(chest.getPos(), Color.red, 2.0, 1.0);
}else{
RenderUtils.blockESP(chest.getPos(), Color.green, 2.0, 1.0);
}
}
if(chest.adjacentChestZNeg == null && chest.adjacentChestXNeg == null && chest.adjacentChestXPos == null && chest.adjacentChestZPos == null)
{
if(chest.getChestType() == BlockChest.Type.TRAP) { //if is trapped chest
RenderUtils.blockESP(chest.getPos(), Color.red, 1.0, 1.0);
}else{
RenderUtils.blockESP(chest.getPos(),
Color.green,
1.0,
1.0);
}
}
}
}
示例13: isChestAt
import net.minecraft.block.BlockChest; //導入依賴的package包/類
private boolean isChestAt(BlockPos posIn)
{
if (this.world == null)
{
return false;
}
else
{
Block block = this.world.getBlockState(posIn).getBlock();
return block instanceof BlockChest && ((BlockChest)block).chestType == this.getChestType();
}
}
示例14: closeInventory
import net.minecraft.block.BlockChest; //導入依賴的package包/類
public void closeInventory(EntityPlayer player)
{
if (!player.isSpectator() && this.getBlockType() instanceof BlockChest)
{
--this.numPlayersUsing;
this.world.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing);
this.world.notifyNeighborsOfStateChange(this.pos, this.getBlockType(), false);
if (this.getChestType() == BlockChest.Type.TRAP)
{
this.world.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType(), false);
}
}
}
示例15: getChestType
import net.minecraft.block.BlockChest; //導入依賴的package包/類
public BlockChest.Type getChestType()
{
if (this.cachedChestType == null)
{
if (this.world == null || !(this.getBlockType() instanceof BlockChest))
{
return BlockChest.Type.BASIC;
}
this.cachedChestType = ((BlockChest)this.getBlockType()).chestType;
}
return this.cachedChestType;
}