Java 类net.minecraft.inventory.InventoryLargeChest 实例源码
项目:ExtraUtilities
文件:TNHelper.java
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;
}
项目:CrystalMod
文件:ItemUtil.java
public static IInventory getInventory(IInventory inv) {
if (inv instanceof TileEntityChest) {
TileEntityChest chest = (TileEntityChest) inv;
TileEntityChest neighbour = null;
if (chest.adjacentChestXNeg != null) {
neighbour = chest.adjacentChestXNeg;
} else if (chest.adjacentChestXPos != null) {
neighbour = chest.adjacentChestXPos;
} else if (chest.adjacentChestZNeg != null) {
neighbour = chest.adjacentChestZNeg;
} else if (chest.adjacentChestZPos != null) {
neighbour = chest.adjacentChestZPos;
}
if (neighbour != null) {
return new InventoryLargeChest("", (ILockableContainer)inv, (ILockableContainer)neighbour);
}
return inv;
}
return inv;
}
项目:EnderCore
文件:ItemUtil.java
public static IInventory getInventory(IInventory inv) {
if (inv instanceof TileEntityChest) {
TileEntityChest chest = (TileEntityChest) inv;
TileEntityChest neighbour = null;
boolean reverse = false;
if (chest.adjacentChestXNeg != null) {
neighbour = chest.adjacentChestXNeg;
reverse = true;
} else if (chest.adjacentChestXPos != null) {
neighbour = chest.adjacentChestXPos;
} else if (chest.adjacentChestZNeg != null) {
neighbour = chest.adjacentChestZNeg;
reverse = true;
} else if (chest.adjacentChestZPos != null) {
neighbour = chest.adjacentChestZPos;
}
if (neighbour != null) {
if (reverse) {
return new InventoryLargeChest("", neighbour, inv);
} else {
return new InventoryLargeChest("", inv, neighbour);
}
}
}
return inv;
}
项目:morecommands
文件:CommandDropstore.java
@Override
public String execute(CommandSender sender, String[] params)throws CommandException {
EntityPlayerMP player = getSenderAsEntity(sender.getMinecraftISender(), EntityPlayerMP.class);
BlockPos coord1 = new BlockPos(player.getPosition().getX() + 1, player.getPosition().getY(), player.getPosition().getZ());
BlockPos coord2 = new BlockPos(player.getPosition().getX() + 1, player.getPosition().getY(), player.getPosition().getZ() + 1);
WorldUtils.setBlock(player.world, coord1, Blocks.CHEST);
WorldUtils.setBlock(player.world, coord2, Blocks.CHEST);
InventoryLargeChest chestInv = new InventoryLargeChest("Large chest", (TileEntityChest) player.world.getTileEntity(coord1), (TileEntityChest) player.world.getTileEntity(coord2));
int count = 0;
for (int i = 0; i < player.inventory.getSizeInventory() && count < chestInv.getSizeInventory(); i++) {
chestInv.setInventorySlotContents(count++, player.inventory.getStackInSlot(i));
player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
}
sender.sendLangfileMessage("command.dropstore.stored");
return null;
}
项目:BaMsGRAVE
文件:BlockHelper.java
public static IInventory getChestInventory(TileEntityChest chest) {
for (EnumFacing face : EnumFacing.Plane.HORIZONTAL) {
BlockPos offsetPos = chest.getPos().offset(face);
if (chest.getWorld().getBlockState(offsetPos).getBlock() == chest.getBlockType()) {
TileEntity te = chest.getWorld().getTileEntity(offsetPos);
if (te instanceof TileEntityChest) {
TileEntityChest chest2 = (TileEntityChest) te;
if (face != EnumFacing.WEST && face != EnumFacing.NORTH) {
return new InventoryLargeChest("container.chestDouble", chest, chest2);
} else {
return new InventoryLargeChest("container.chestDouble", chest2, chest);
}
}
}
}
return chest;
}
项目:LegacyFarms
文件:BlockUtils.java
public static IInventory getChest(IInventory inventory) {
if (!(inventory instanceof TileEntityChest)) {
return inventory;
}
TileEntityChest chest = (TileEntityChest) inventory;
BlockPosition[] adjacent = new BlockPosition[] { new BlockPosition(chest.xCoord + 1, chest.yCoord, chest.zCoord), new BlockPosition(chest.xCoord - 1, chest.yCoord, chest.zCoord), new BlockPosition(chest.xCoord, chest.yCoord, chest.zCoord + 1), new BlockPosition(chest.xCoord, chest.yCoord, chest.zCoord - 1) };
for (BlockPosition pos : adjacent) {
TileEntity otherChest = chest.getWorldObj().getTileEntity(pos.x, pos.y, pos.z);
if (otherChest instanceof TileEntityChest) {
return new InventoryLargeChest("", chest, (TileEntityChest) otherChest);
}
}
return inventory;
}
项目:ForestryLegacy
文件:Utils.java
public static IInventory getChest(IInventory inventory) {
if (!(inventory instanceof TileEntityChest))
return inventory;
TileEntityChest chest = (TileEntityChest) inventory;
Vect[] adjacent = new Vect[] { new Vect(chest.xCoord + 1, chest.yCoord, chest.zCoord), new Vect(chest.xCoord - 1, chest.yCoord, chest.zCoord),
new Vect(chest.xCoord, chest.yCoord, chest.zCoord + 1), new Vect(chest.xCoord, chest.yCoord, chest.zCoord - 1) };
for (Vect pos : adjacent) {
TileEntity otherchest = chest.worldObj.getBlockTileEntity(pos.x, pos.y, pos.z);
if (otherchest instanceof TileEntityChest)
return new InventoryLargeChest("", chest, (TileEntityChest) otherchest);
}
return inventory;
}
项目:4Space-5
文件:InventoryUtils.java
public static IInventory getChest(TileEntityChest chest) {
for (ForgeDirection fside : chestSides) {
if (chest.getWorldObj().getBlock(chest.xCoord + fside.offsetX, chest.yCoord + fside.offsetY, chest.zCoord + fside.offsetZ) == chest.getBlockType())
return new InventoryLargeChest("container.chestDouble",
(TileEntityChest) chest.getWorldObj().getTileEntity(chest.xCoord + fside.offsetX, chest.yCoord + fside.offsetY, chest.zCoord + fside.offsetZ), chest);
}
return chest;
}
项目:CodeChickenLib
文件:InventoryUtils.java
public static IInventory getChest(TileEntityChest chest) {
for (EnumFacing fside : Plane.HORIZONTAL) {
if (chest.getWorld().getBlockState(chest.getPos().offset(fside)).getBlock() == chest.getBlockType()) {
return new InventoryLargeChest("container.chestDouble", (TileEntityChest) chest.getWorld().getTileEntity(chest.getPos().offset(fside)), chest);
}
}
return chest;
}
项目:vsminecraft
文件:InventoryUtils.java
public static IInventory checkChestInv(IInventory inv)
{
if(inv instanceof TileEntityChest)
{
TileEntityChest main = (TileEntityChest)inv;
TileEntityChest adj = null;
if(main.adjacentChestXNeg != null)
{
adj = main.adjacentChestXNeg;
}
else if(main.adjacentChestXPos != null)
{
adj = main.adjacentChestXPos;
}
else if(main.adjacentChestZNeg != null)
{
adj = main.adjacentChestZNeg;
}
else if(main.adjacentChestZPos != null)
{
adj = main.adjacentChestZPos;
}
if(adj != null)
{
return new InventoryLargeChest("", main, adj);
}
}
return inv;
}
项目:MiscUtils
文件:InventoryUtils.java
/**
* Ensures that the given inventory is the full inventory, i.e. takes double
* chests into account.
*
* @param inv
* @return Modified inventory if double chest, unmodified otherwise.
*/
public static IInventory getInventory(IInventory inv) {
if (inv instanceof TileEntityChest) {
TileEntityChest chest = (TileEntityChest) inv;
TileEntityChest adjacent = null;
if (chest.adjacentChestXNeg != null) {
adjacent = chest.adjacentChestXNeg;
}
if (chest.adjacentChestXPos != null) {
adjacent = chest.adjacentChestXPos;
}
if (chest.adjacentChestZNeg != null) {
adjacent = chest.adjacentChestZNeg;
}
if (chest.adjacentChestZPos != null) {
adjacent = chest.adjacentChestZPos;
}
if (adjacent != null) {
return new InventoryLargeChest("", inv, adjacent);
}
return inv;
}
return inv;
}
项目:Dimensional-Pockets
文件:Utils.java
/**
* Ensures that the given inventory is the full inventory, i.e. takes double
* chests into account.<br>
* <i>METHOD COPIED FROM BUILDCRAFT</i>
*
* @param inv
* @return Modified inventory if double chest, unmodified otherwise.
*/
public static IInventory getInventory(IInventory inv) {
if (inv instanceof TileEntityChest) {
TileEntityChest chest = (TileEntityChest) inv;
TileEntityChest adjacent = null;
if (chest.adjacentChestXNeg != null) {
adjacent = chest.adjacentChestXNeg;
}
if (chest.adjacentChestXPos != null) {
adjacent = chest.adjacentChestXPos;
}
if (chest.adjacentChestZNeg != null) {
adjacent = chest.adjacentChestZNeg;
}
if (chest.adjacentChestZPos != null) {
adjacent = chest.adjacentChestZPos;
}
if (adjacent != null)
return new InventoryLargeChest("", inv, adjacent);
return inv;
}
return inv;
}
项目:DBLibOld
文件:InventoryUtils.java
/**
* Ensures that the given inventory is the full inventory, i.e. takes double
* chests into account.
*
* @param inv
* @return Modified inventory if double chest, unmodified otherwise.
*/
public static IInventory getInventory(IInventory inv) {
if (inv instanceof TileEntityChest) {
TileEntityChest chest = (TileEntityChest) inv;
TileEntityChest adjacent = null;
if (chest.adjacentChestXNeg != null) {
adjacent = chest.adjacentChestXNeg;
}
if (chest.adjacentChestXPos != null) {
adjacent = chest.adjacentChestXPos;
}
if (chest.adjacentChestZNeg != null) {
adjacent = chest.adjacentChestZNeg;
}
if (chest.adjacentChestZPos != null) {
adjacent = chest.adjacentChestZPos;
}
if (adjacent != null) {
return new InventoryLargeChest("", inv, adjacent);
}
return inv;
}
return inv;
}
项目:DBLibOld
文件:InventoryUtility.java
public static IInventory checkChestInv(IInventory inv)
{
if (inv instanceof TileEntityChest)
{
TileEntityChest main = (TileEntityChest) inv;
TileEntityChest adj = null;
if (main.adjacentChestXNeg != null)
{
adj = main.adjacentChestXNeg;
}
else if (main.adjacentChestXPos != null)
{
adj = main.adjacentChestXPos;
}
else if (main.adjacentChestZNeg != null)
{
adj = main.adjacentChestZNeg;
}
else if (main.adjacentChestZPos != null)
{
adj = main.adjacentChestZPos;
}
if (adj != null)
{
return new InventoryLargeChest("", main, adj);
}
}
return inv;
}
项目:Toms-Mod
文件:TileEntityLimitableChest.java
/**
* Like the old updateEntity(), except more generic.
*/
@Override
public void update() {
int i = this.pos.getX();
int j = this.pos.getY();
int k = this.pos.getZ();
++this.ticksSinceSync;
if (!this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + i + j + k) % 200 == 0) {
this.numPlayersUsing = 0;
// float f = 5.0F;
for (EntityPlayer entityplayer : this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(i - 5.0F, j - 5.0F, k - 5.0F, i + 1 + 5.0F, j + 1 + 5.0F, k + 1 + 5.0F))) {
if (entityplayer.openContainer instanceof ContainerChest) {
IInventory iinventory = ((ContainerChest) entityplayer.openContainer).getLowerChestInventory();
if (iinventory == this || iinventory instanceof InventoryLargeChest && ((InventoryLargeChest) iinventory).isPartOfLargeChest(this)) {
++this.numPlayersUsing;
}
}
}
}
this.prevLidAngle = this.lidAngle;
// float f1 = 0.1F;
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) {
double d1 = i + 0.5D;
double d2 = k + 0.5D;
if (this.adjacentChestZPos != null) {
d2 += 0.5D;
}
if (this.adjacentChestXPos != null) {
d1 += 0.5D;
}
this.world.playSound((EntityPlayer) null, d1, j + 0.5D, d2, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
}
if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) {
float f2 = this.lidAngle;
if (this.numPlayersUsing > 0) {
this.lidAngle += 0.1F;
} else {
this.lidAngle -= 0.1F;
}
if (this.lidAngle > 1.0F) {
this.lidAngle = 1.0F;
}
// float f3 = 0.5F;
if (this.lidAngle < 0.5F && f2 >= 0.5F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) {
double d3 = i + 0.5D;
double d0 = k + 0.5D;
if (this.adjacentChestZPos != null) {
d0 += 0.5D;
}
if (this.adjacentChestXPos != null) {
d3 += 0.5D;
}
this.world.playSound((EntityPlayer) null, d3, j + 0.5D, d0, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
}
if (this.lidAngle < 0.0F) {
this.lidAngle = 0.0F;
}
}
}
项目:Cauldron
文件:BlockDropper.java
public void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_) // CraftBukkit - protected -> public
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int l = tileentitydispenser.func_146017_i();
if (l < 0)
{
p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(l);
int i1 = p_149941_1_.getBlockMetadata(p_149941_2_, p_149941_3_, p_149941_4_) & 7;
IInventory iinventory = TileEntityHopper.func_145893_b(p_149941_1_, (double)(p_149941_2_ + Facing.offsetsXForSide[i1]), (double)(p_149941_3_ + Facing.offsetsYForSide[i1]), (double)(p_149941_4_ + Facing.offsetsZForSide[i1]));
ItemStack itemstack1;
if (iinventory != null)
{
// CraftBukkit start - Fire event when pushing items into other inventories
CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.copy().splitStack(1));
org.bukkit.inventory.Inventory destinationInventory;
// Have to special case large chests as they work oddly
if (iinventory instanceof InventoryLargeChest)
{
destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
}
else
{
destinationInventory = iinventory.getOwner().getInventory();
}
InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
p_149941_1_.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
itemstack1 = TileEntityHopper.func_145889_a(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.oppositeSide[i1]);
if (event.getItem().equals(oitemstack) && itemstack1 == null)
{
// CraftBukkit end
itemstack1 = itemstack.copy();
if (--itemstack1.stackSize == 0)
{
itemstack1 = null;
}
}
else
{
itemstack1 = itemstack.copy();
}
}
else
{
itemstack1 = this.field_149947_P.dispense(blocksourceimpl, itemstack);
if (itemstack1 != null && itemstack1.stackSize == 0)
{
itemstack1 = null;
}
}
tileentitydispenser.setInventorySlotContents(l, itemstack1);
}
}
}
项目:Cauldron
文件:TileEntityHopper.java
private static boolean func_145892_a(IHopper p_145892_0_, IInventory p_145892_1_, int p_145892_2_, int p_145892_3_)
{
ItemStack itemstack = p_145892_1_.getStackInSlot(p_145892_2_);
if (itemstack != null && func_145890_b(p_145892_1_, itemstack, p_145892_2_, p_145892_3_))
{
ItemStack itemstack1 = itemstack.copy();
// CraftBukkit start - Call event on collection of items from inventories into the hopper
CraftItemStack oitemstack = CraftItemStack.asCraftMirror(p_145892_1_.decrStackSize(p_145892_2_, 1));
Inventory sourceInventory;
// Have to special case large chests as they work oddly
if (p_145892_1_ instanceof InventoryLargeChest)
{
sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) p_145892_1_);
}
else
{
// Cauldron start - support mod inventories, with no owners
try
{
if (p_145892_1_.getOwner() != null)
{
sourceInventory = p_145892_1_.getOwner().getInventory();
}
else
{
// TODO: create a mod inventory for passing to the event, instead of null
sourceInventory = null;
}
}
catch (AbstractMethodError e)
{
sourceInventory = null;
}
// Cauldron end
}
InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), p_145892_0_.getOwner().getInventory(), false);
p_145892_0_.getWorldObj().getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
p_145892_1_.setInventorySlotContents(p_145892_2_, itemstack1);
if (p_145892_0_ instanceof TileEntityHopper)
{
((TileEntityHopper) p_145892_0_).func_145896_c(p_145892_0_.getWorldObj().spigotConfig.hopperTransfer); // Spigot
}
else if (p_145892_0_ instanceof EntityMinecartHopper)
{
((EntityMinecartHopper) p_145892_0_).setDisplayTileData(p_145892_0_.getWorldObj().spigotConfig.hopperTransfer / 2); // Spigot
}
return false;
}
ItemStack itemstack2 = func_145889_a(p_145892_0_, CraftItemStack.asNMSCopy(event.getItem()), -1);
if (itemstack2 == null || itemstack2.stackSize == 0)
{
if (event.getItem().equals(oitemstack))
{
p_145892_1_.markDirty();
}
else
{
p_145892_1_.setInventorySlotContents(p_145892_2_, itemstack1);
}
// CraftBukkit end
return true;
}
p_145892_1_.setInventorySlotContents(p_145892_2_, itemstack1);
}
return false;
}
项目:RuneCraftery
文件:TileEntityChest.java
public void func_70316_g() {
super.func_70316_g();
this.func_70418_i();
++this.field_70426_j;
float var1;
if(!this.field_70331_k.field_72995_K && this.field_70427_h != 0 && (this.field_70426_j + this.field_70329_l + this.field_70330_m + this.field_70327_n) % 200 == 0) {
this.field_70427_h = 0;
var1 = 5.0F;
List var2 = this.field_70331_k.func_72872_a(EntityPlayer.class, AxisAlignedBB.func_72332_a().func_72299_a((double)((float)this.field_70329_l - var1), (double)((float)this.field_70330_m - var1), (double)((float)this.field_70327_n - var1), (double)((float)(this.field_70329_l + 1) + var1), (double)((float)(this.field_70330_m + 1) + var1), (double)((float)(this.field_70327_n + 1) + var1)));
Iterator var3 = var2.iterator();
while(var3.hasNext()) {
EntityPlayer var4 = (EntityPlayer)var3.next();
if(var4.field_71070_bA instanceof ContainerChest) {
IInventory var5 = ((ContainerChest)var4.field_71070_bA).func_85151_d();
if(var5 == this || var5 instanceof InventoryLargeChest && ((InventoryLargeChest)var5).func_90010_a(this)) {
++this.field_70427_h;
}
}
}
}
this.field_70420_g = this.field_70419_f;
var1 = 0.1F;
double var11;
if(this.field_70427_h > 0 && this.field_70419_f == 0.0F && this.field_70423_b == null && this.field_70421_d == null) {
double var8 = (double)this.field_70329_l + 0.5D;
var11 = (double)this.field_70327_n + 0.5D;
if(this.field_70422_e != null) {
var11 += 0.5D;
}
if(this.field_70424_c != null) {
var8 += 0.5D;
}
this.field_70331_k.func_72908_a(var8, (double)this.field_70330_m + 0.5D, var11, "random.chestopen", 0.5F, this.field_70331_k.field_73012_v.nextFloat() * 0.1F + 0.9F);
}
if(this.field_70427_h == 0 && this.field_70419_f > 0.0F || this.field_70427_h > 0 && this.field_70419_f < 1.0F) {
float var9 = this.field_70419_f;
if(this.field_70427_h > 0) {
this.field_70419_f += var1;
} else {
this.field_70419_f -= var1;
}
if(this.field_70419_f > 1.0F) {
this.field_70419_f = 1.0F;
}
float var10 = 0.5F;
if(this.field_70419_f < var10 && var9 >= var10 && this.field_70423_b == null && this.field_70421_d == null) {
var11 = (double)this.field_70329_l + 0.5D;
double var6 = (double)this.field_70327_n + 0.5D;
if(this.field_70422_e != null) {
var6 += 0.5D;
}
if(this.field_70424_c != null) {
var11 += 0.5D;
}
this.field_70331_k.func_72908_a(var11, (double)this.field_70330_m + 0.5D, var6, "random.chestclosed", 0.5F, this.field_70331_k.field_73012_v.nextFloat() * 0.1F + 0.9F);
}
if(this.field_70419_f < 0.0F) {
this.field_70419_f = 0.0F;
}
}
}