2012-04-25 03:17:23 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2012 cpw.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the GNU Public License v3.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.gnu.org/licenses/gpl.html
|
2012-06-29 18:47:09 +02:00
|
|
|
*
|
2012-04-25 03:17:23 +02:00
|
|
|
* Contributors:
|
|
|
|
* cpw - initial API and implementation
|
|
|
|
******************************************************************************/
|
2012-01-26 23:37:39 +01:00
|
|
|
package cpw.mods.ironchest;
|
|
|
|
|
2012-02-11 06:45:56 +01:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Comparator;
|
2013-02-17 04:02:25 +01:00
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
2012-02-11 06:45:56 +01:00
|
|
|
|
2013-09-16 23:04:09 +02:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2012-12-13 14:02:41 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.nbt.NBTTagList;
|
|
|
|
import net.minecraft.network.packet.Packet;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2013-02-17 04:02:25 +01:00
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
2013-04-11 14:43:34 +02:00
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
2012-01-26 23:37:39 +01:00
|
|
|
|
|
|
|
public class TileEntityIronChest extends TileEntity implements IInventory {
|
2013-02-17 04:18:38 +01:00
|
|
|
private int ticksSinceSync = -1;
|
2012-12-18 17:22:21 +01:00
|
|
|
public float prevLidAngle;
|
|
|
|
public float lidAngle;
|
|
|
|
private int numUsingPlayers;
|
|
|
|
private IronChestType type;
|
|
|
|
public ItemStack[] chestContents;
|
|
|
|
private ItemStack[] topStacks;
|
|
|
|
private byte facing;
|
|
|
|
private boolean inventoryTouched;
|
|
|
|
private boolean hadStuff;
|
|
|
|
|
|
|
|
public TileEntityIronChest()
|
|
|
|
{
|
|
|
|
this(IronChestType.IRON);
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
protected TileEntityIronChest(IronChestType type)
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.type = type;
|
|
|
|
this.chestContents = new ItemStack[getSizeInventory()];
|
|
|
|
this.topStacks = new ItemStack[8];
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
public ItemStack[] getContents()
|
|
|
|
{
|
|
|
|
return chestContents;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getSizeInventory()
|
|
|
|
{
|
|
|
|
return type.size;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
public byte getFacing()
|
|
|
|
{
|
|
|
|
return this.facing;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
|
|
|
|
2012-12-18 17:22:21 +01:00
|
|
|
@Override
|
|
|
|
public String getInvName()
|
2012-03-29 06:31:46 +02:00
|
|
|
{
|
2012-12-18 17:22:21 +01:00
|
|
|
return type.name();
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
public IronChestType getType()
|
2012-03-29 06:31:46 +02:00
|
|
|
{
|
2012-12-18 17:22:21 +01:00
|
|
|
return type;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
|
|
|
|
2012-12-18 17:22:21 +01:00
|
|
|
@Override
|
|
|
|
public ItemStack getStackInSlot(int i)
|
2012-03-29 06:31:46 +02:00
|
|
|
{
|
2012-12-18 17:22:21 +01:00
|
|
|
inventoryTouched = true;
|
|
|
|
return chestContents[i];
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onInventoryChanged()
|
2012-03-29 06:31:46 +02:00
|
|
|
{
|
2012-12-18 17:22:21 +01:00
|
|
|
super.onInventoryChanged();
|
|
|
|
sortTopStacks();
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
protected void sortTopStacks()
|
2012-03-29 06:31:46 +02:00
|
|
|
{
|
2012-12-18 17:22:21 +01:00
|
|
|
if (!type.isTransparent() || (worldObj != null && worldObj.isRemote))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ItemStack[] tempCopy = new ItemStack[getSizeInventory()];
|
|
|
|
boolean hasStuff = false;
|
|
|
|
int compressedIdx = 0;
|
|
|
|
mainLoop: for (int i = 0; i < getSizeInventory(); i++)
|
|
|
|
{
|
|
|
|
if (chestContents[i] != null)
|
|
|
|
{
|
|
|
|
for (int j = 0; j < compressedIdx; j++)
|
|
|
|
{
|
|
|
|
if (tempCopy[j].isItemEqual(chestContents[i]))
|
|
|
|
{
|
|
|
|
tempCopy[j].stackSize += chestContents[i].stackSize;
|
|
|
|
continue mainLoop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tempCopy[compressedIdx++] = chestContents[i].copy();
|
|
|
|
hasStuff = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!hasStuff && hadStuff)
|
|
|
|
{
|
|
|
|
hadStuff = false;
|
|
|
|
for (int i = 0; i < topStacks.length; i++)
|
|
|
|
{
|
|
|
|
topStacks[i] = null;
|
|
|
|
}
|
|
|
|
if (worldObj != null)
|
|
|
|
{
|
|
|
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hadStuff = true;
|
|
|
|
Arrays.sort(tempCopy, new Comparator<ItemStack>() {
|
|
|
|
@Override
|
|
|
|
public int compare(ItemStack o1, ItemStack o2)
|
|
|
|
{
|
|
|
|
if (o1 == null)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (o2 == null)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return o2.stackSize - o1.stackSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
int p = 0;
|
|
|
|
for (int i = 0; i < tempCopy.length; i++)
|
|
|
|
{
|
|
|
|
if (tempCopy[i] != null && tempCopy[i].stackSize > 0)
|
|
|
|
{
|
|
|
|
topStacks[p++] = tempCopy[i];
|
|
|
|
if (p == topStacks.length)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = p; i < topStacks.length; i++)
|
|
|
|
{
|
|
|
|
topStacks[i] = null;
|
|
|
|
}
|
|
|
|
if (worldObj != null)
|
|
|
|
{
|
|
|
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
|
|
|
}
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
|
|
|
|
2012-12-18 17:22:21 +01:00
|
|
|
@Override
|
|
|
|
public ItemStack decrStackSize(int i, int j)
|
|
|
|
{
|
|
|
|
if (chestContents[i] != null)
|
|
|
|
{
|
|
|
|
if (chestContents[i].stackSize <= j)
|
|
|
|
{
|
|
|
|
ItemStack itemstack = chestContents[i];
|
|
|
|
chestContents[i] = null;
|
|
|
|
onInventoryChanged();
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
ItemStack itemstack1 = chestContents[i].splitStack(j);
|
|
|
|
if (chestContents[i].stackSize == 0)
|
|
|
|
{
|
|
|
|
chestContents[i] = null;
|
|
|
|
}
|
|
|
|
onInventoryChanged();
|
|
|
|
return itemstack1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2012-03-29 06:31:46 +02:00
|
|
|
|
2012-12-18 17:22:21 +01:00
|
|
|
@Override
|
|
|
|
public void setInventorySlotContents(int i, ItemStack itemstack)
|
|
|
|
{
|
|
|
|
chestContents[i] = itemstack;
|
|
|
|
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
|
|
|
{
|
|
|
|
itemstack.stackSize = getInventoryStackLimit();
|
|
|
|
}
|
|
|
|
onInventoryChanged();
|
|
|
|
}
|
2012-03-29 06:31:46 +02:00
|
|
|
|
2012-12-18 17:22:21 +01:00
|
|
|
@Override
|
|
|
|
public void readFromNBT(NBTTagCompound nbttagcompound)
|
|
|
|
{
|
|
|
|
super.readFromNBT(nbttagcompound);
|
|
|
|
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
|
|
|
|
chestContents = new ItemStack[getSizeInventory()];
|
|
|
|
for (int i = 0; i < nbttaglist.tagCount(); i++)
|
|
|
|
{
|
|
|
|
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
|
|
|
|
int j = nbttagcompound1.getByte("Slot") & 0xff;
|
|
|
|
if (j >= 0 && j < chestContents.length)
|
|
|
|
{
|
|
|
|
chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
facing = nbttagcompound.getByte("facing");
|
|
|
|
sortTopStacks();
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToNBT(NBTTagCompound nbttagcompound)
|
|
|
|
{
|
|
|
|
super.writeToNBT(nbttagcompound);
|
|
|
|
NBTTagList nbttaglist = new NBTTagList();
|
|
|
|
for (int i = 0; i < chestContents.length; i++)
|
|
|
|
{
|
|
|
|
if (chestContents[i] != null)
|
|
|
|
{
|
|
|
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
|
|
|
nbttagcompound1.setByte("Slot", (byte) i);
|
|
|
|
chestContents[i].writeToNBT(nbttagcompound1);
|
|
|
|
nbttaglist.appendTag(nbttagcompound1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nbttagcompound.setTag("Items", nbttaglist);
|
|
|
|
nbttagcompound.setByte("facing", facing);
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getInventoryStackLimit()
|
|
|
|
{
|
|
|
|
return 64;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
|
|
|
{
|
|
|
|
if (worldObj == null)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return entityplayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateEntity()
|
|
|
|
{
|
|
|
|
super.updateEntity();
|
|
|
|
// Resynchronize clients with the server state
|
2013-02-17 04:02:25 +01:00
|
|
|
if (worldObj != null && !this.worldObj.isRemote && this.numUsingPlayers != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0)
|
2012-12-18 17:22:21 +01:00
|
|
|
{
|
2013-02-17 04:02:25 +01:00
|
|
|
this.numUsingPlayers = 0;
|
|
|
|
float var1 = 5.0F;
|
2013-03-09 22:05:06 +01:00
|
|
|
List var2 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getAABBPool().getAABB((double)((float)this.xCoord - var1), (double)((float)this.yCoord - var1), (double)((float)this.zCoord - var1), (double)((float)(this.xCoord + 1) + var1), (double)((float)(this.yCoord + 1) + var1), (double)((float)(this.zCoord + 1) + var1)));
|
2013-02-17 04:02:25 +01:00
|
|
|
Iterator var3 = var2.iterator();
|
|
|
|
|
|
|
|
while (var3.hasNext())
|
2012-12-18 17:22:21 +01:00
|
|
|
{
|
2013-02-17 04:02:25 +01:00
|
|
|
EntityPlayer var4 = (EntityPlayer)var3.next();
|
|
|
|
|
|
|
|
if (var4.openContainer instanceof ContainerIronChestBase)
|
|
|
|
{
|
|
|
|
++this.numUsingPlayers;
|
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
}
|
|
|
|
}
|
2013-02-17 04:02:25 +01:00
|
|
|
|
|
|
|
if (worldObj != null && !worldObj.isRemote && ticksSinceSync < 0)
|
|
|
|
{
|
|
|
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock.blockID, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7));
|
|
|
|
}
|
|
|
|
if (!worldObj.isRemote && inventoryTouched)
|
|
|
|
{
|
|
|
|
inventoryTouched = false;
|
|
|
|
sortTopStacks();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.ticksSinceSync++;
|
2012-12-18 17:22:21 +01:00
|
|
|
prevLidAngle = lidAngle;
|
|
|
|
float f = 0.1F;
|
|
|
|
if (numUsingPlayers > 0 && lidAngle == 0.0F)
|
|
|
|
{
|
|
|
|
double d = (double) xCoord + 0.5D;
|
|
|
|
double d1 = (double) zCoord + 0.5D;
|
|
|
|
worldObj.playSoundEffect(d, (double) yCoord + 0.5D, d1, "random.chestopen", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
|
|
|
}
|
|
|
|
if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0 && lidAngle < 1.0F)
|
|
|
|
{
|
|
|
|
float f1 = lidAngle;
|
|
|
|
if (numUsingPlayers > 0)
|
|
|
|
{
|
|
|
|
lidAngle += f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lidAngle -= f;
|
|
|
|
}
|
|
|
|
if (lidAngle > 1.0F)
|
|
|
|
{
|
|
|
|
lidAngle = 1.0F;
|
|
|
|
}
|
|
|
|
float f2 = 0.5F;
|
|
|
|
if (lidAngle < f2 && f1 >= f2)
|
|
|
|
{
|
|
|
|
double d2 = (double) xCoord + 0.5D;
|
|
|
|
double d3 = (double) zCoord + 0.5D;
|
|
|
|
worldObj.playSoundEffect(d2, (double) yCoord + 0.5D, d3, "random.chestclosed", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
|
|
|
}
|
|
|
|
if (lidAngle < 0.0F)
|
|
|
|
{
|
|
|
|
lidAngle = 0.0F;
|
|
|
|
}
|
|
|
|
}
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
|
|
|
|
2012-12-18 17:22:21 +01:00
|
|
|
@Override
|
2013-03-04 17:18:53 +01:00
|
|
|
public boolean receiveClientEvent(int i, int j)
|
2012-12-18 17:22:21 +01:00
|
|
|
{
|
|
|
|
if (i == 1)
|
|
|
|
{
|
|
|
|
numUsingPlayers = j;
|
|
|
|
}
|
|
|
|
else if (i == 2)
|
|
|
|
{
|
|
|
|
facing = (byte) j;
|
|
|
|
}
|
|
|
|
else if (i == 3)
|
|
|
|
{
|
|
|
|
facing = (byte) (j & 0x7);
|
|
|
|
numUsingPlayers = (j & 0xF8) >> 3;
|
|
|
|
}
|
2013-03-04 17:18:53 +01:00
|
|
|
return true;
|
2012-12-18 17:22:21 +01:00
|
|
|
}
|
2012-06-29 18:47:09 +02:00
|
|
|
|
2012-12-18 17:22:21 +01:00
|
|
|
@Override
|
|
|
|
public void openChest()
|
2012-03-29 06:31:46 +02:00
|
|
|
{
|
2012-12-18 17:22:21 +01:00
|
|
|
if (worldObj == null) return;
|
|
|
|
numUsingPlayers++;
|
|
|
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock.blockID, 1, numUsingPlayers);
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void closeChest()
|
|
|
|
{
|
|
|
|
if (worldObj == null) return;
|
|
|
|
numUsingPlayers--;
|
|
|
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock.blockID, 1, numUsingPlayers);
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
public void setFacing(byte chestFacing)
|
|
|
|
{
|
|
|
|
this.facing = chestFacing;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
public TileEntityIronChest applyUpgradeItem(ItemChestChanger itemChestChanger)
|
|
|
|
{
|
|
|
|
if (numUsingPlayers > 0)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (!itemChestChanger.getType().canUpgrade(this.getType()))
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
TileEntityIronChest newEntity = IronChestType.makeEntity(itemChestChanger.getTargetChestOrdinal(getType().ordinal()));
|
|
|
|
int newSize = newEntity.chestContents.length;
|
|
|
|
System.arraycopy(chestContents, 0, newEntity.chestContents, 0, Math.min(newSize, chestContents.length));
|
|
|
|
BlockIronChest block = IronChest.ironChestBlock;
|
|
|
|
block.dropContent(newSize, this, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
|
|
|
newEntity.setFacing(facing);
|
|
|
|
newEntity.sortTopStacks();
|
2013-02-17 04:02:25 +01:00
|
|
|
newEntity.ticksSinceSync = -1;
|
2012-12-18 17:22:21 +01:00
|
|
|
return newEntity;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
public ItemStack[] getTopItemStacks()
|
|
|
|
{
|
|
|
|
return topStacks;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
public TileEntityIronChest updateFromMetadata(int l)
|
|
|
|
{
|
|
|
|
if (worldObj != null && worldObj.isRemote)
|
|
|
|
{
|
|
|
|
if (l != type.ordinal())
|
|
|
|
{
|
|
|
|
worldObj.setBlockTileEntity(xCoord, yCoord, zCoord, IronChestType.makeEntity(l));
|
|
|
|
return (TileEntityIronChest) worldObj.getBlockTileEntity(xCoord, yCoord, zCoord);
|
|
|
|
}
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Packet getDescriptionPacket()
|
|
|
|
{
|
|
|
|
return PacketHandler.getPacket(this);
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
public void handlePacketData(int typeData, int[] intData)
|
|
|
|
{
|
|
|
|
TileEntityIronChest chest = this;
|
|
|
|
if (this.type.ordinal() != typeData)
|
|
|
|
{
|
|
|
|
chest = updateFromMetadata(typeData);
|
|
|
|
}
|
|
|
|
if (IronChestType.values()[typeData].isTransparent() && intData != null)
|
|
|
|
{
|
|
|
|
int pos = 0;
|
|
|
|
if (intData.length < chest.topStacks.length * 3)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < chest.topStacks.length; i++)
|
|
|
|
{
|
|
|
|
if (intData[pos + 2] != 0)
|
|
|
|
{
|
|
|
|
ItemStack is = new ItemStack(intData[pos], intData[pos + 2], intData[pos + 1]);
|
|
|
|
chest.topStacks[i] = is;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chest.topStacks[i] = null;
|
|
|
|
}
|
|
|
|
pos += 3;
|
|
|
|
}
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-18 17:22:21 +01:00
|
|
|
public int[] buildIntDataList()
|
2012-03-29 06:31:46 +02:00
|
|
|
{
|
2012-12-18 17:22:21 +01:00
|
|
|
if (type.isTransparent())
|
|
|
|
{
|
|
|
|
int[] sortList = new int[topStacks.length * 3];
|
|
|
|
int pos = 0;
|
|
|
|
for (ItemStack is : topStacks)
|
|
|
|
{
|
|
|
|
if (is != null)
|
|
|
|
{
|
|
|
|
sortList[pos++] = is.itemID;
|
|
|
|
sortList[pos++] = is.getItemDamage();
|
|
|
|
sortList[pos++] = is.stackSize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sortList[pos++] = 0;
|
|
|
|
sortList[pos++] = 0;
|
|
|
|
sortList[pos++] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sortList;
|
|
|
|
}
|
|
|
|
return null;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
public ItemStack getStackInSlotOnClosing(int par1)
|
2012-03-29 06:31:46 +02:00
|
|
|
{
|
2012-12-18 17:22:21 +01:00
|
|
|
if (this.chestContents[par1] != null)
|
|
|
|
{
|
|
|
|
ItemStack var2 = this.chestContents[par1];
|
|
|
|
this.chestContents[par1] = null;
|
|
|
|
return var2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-06-29 18:47:09 +02:00
|
|
|
|
2012-12-18 17:22:21 +01:00
|
|
|
public void setMaxStackSize(int size)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2013-01-22 17:23:32 +01:00
|
|
|
|
|
|
|
@Override
|
2013-07-09 22:15:30 +02:00
|
|
|
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
2013-01-22 17:23:32 +01:00
|
|
|
{
|
2013-09-16 19:43:32 +02:00
|
|
|
return type.acceptsStack(itemstack);
|
2013-01-22 17:23:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-03-22 20:30:32 +01:00
|
|
|
public boolean isInvNameLocalized()
|
2013-01-22 17:23:32 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-11 14:43:34 +02:00
|
|
|
|
|
|
|
void rotateAround(ForgeDirection axis)
|
|
|
|
{
|
|
|
|
setFacing((byte)ForgeDirection.getOrientation(facing).getRotation(axis).ordinal());
|
|
|
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock.blockID, 2, getFacing());
|
|
|
|
}
|
2013-09-16 23:04:09 +02:00
|
|
|
|
|
|
|
public void wasPlaced(EntityLivingBase entityliving, ItemStack itemStack)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeAdornments()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2012-01-26 23:37:39 +01:00
|
|
|
}
|