Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TilePedestal
- extends TileThaumcraft
- implements ISidedInventory
- {
- private static final int[] slots = { 0 };
- private ItemStack[] inventory = new ItemStack[1];
- private String customName;
- @SideOnly(Side.CLIENT)
- public AxisAlignedBB getRenderBoundingBox()
- {
- return AxisAlignedBB.fromBounds(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX() + 1, getPos().getY() + 2, getPos().getZ() + 1);
- }
- public int getSizeInventory()
- {
- return 1;
- }
- public ItemStack getStackInSlot(int par1)
- {
- return this.inventory[par1];
- }
- public ItemStack decrStackSize(int par1, int par2)
- {
- if (this.inventory[par1] != null)
- {
- if (!this.worldObj.isRemote) {
- this.worldObj.markBlockForUpdate(this.pos);
- }
- if (this.inventory[par1].stackSize <= par2)
- {
- ItemStack itemstack = this.inventory[par1];
- this.inventory[par1] = null;
- markDirty();
- return itemstack;
- }
- ItemStack itemstack = this.inventory[par1].splitStack(par2);
- if (this.inventory[par1].stackSize == 0) {
- this.inventory[par1] = null;
- }
- markDirty();
- return itemstack;
- }
- return null;
- }
- public ItemStack getStackInSlotOnClosing(int par1)
- {
- if (this.inventory[par1] != null)
- {
- ItemStack itemstack = this.inventory[par1];
- this.inventory[par1] = null;
- return itemstack;
- }
- return null;
- }
- public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
- {
- this.inventory[par1] = par2ItemStack;
- if ((par2ItemStack != null) && (par2ItemStack.stackSize > getInventoryStackLimit())) {
- par2ItemStack.stackSize = getInventoryStackLimit();
- }
- markDirty();
- if (!this.worldObj.isRemote) {
- this.worldObj.markBlockForUpdate(this.pos);
- }
- }
- public void setInventorySlotContentsFromInfusion(int par1, ItemStack par2ItemStack)
- {
- this.inventory[par1] = par2ItemStack;
- markDirty();
- if (!this.worldObj.isRemote) {
- this.worldObj.markBlockForUpdate(this.pos);
- }
- }
- public String getName()
- {
- return hasCustomName() ? this.customName : "container.pedestal";
- }
- public boolean hasCustomName()
- {
- return (this.customName != null) && (this.customName.length() > 0);
- }
- public IChatComponent getDisplayName()
- {
- return hasCustomName() ? new ChatComponentText(getName()) : new ChatComponentTranslation(getName(), new Object[0]);
- }
- public void readCustomNBT(NBTTagCompound nbttagcompound)
- {
- NBTTagList nbttaglist = nbttagcompound.getTagList("Items", 10);
- this.inventory = new ItemStack[getSizeInventory()];
- for (int i = 0; i < nbttaglist.tagCount(); i++)
- {
- NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
- byte b0 = nbttagcompound1.getByte("Slot");
- if ((b0 >= 0) && (b0 < this.inventory.length)) {
- this.inventory[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
- }
- }
- }
- public void writeCustomNBT(NBTTagCompound nbttagcompound)
- {
- NBTTagList nbttaglist = new NBTTagList();
- for (int i = 0; i < this.inventory.length; i++) {
- if (this.inventory[i] != null)
- {
- NBTTagCompound nbttagcompound1 = new NBTTagCompound();
- nbttagcompound1.setByte("Slot", (byte)i);
- this.inventory[i].writeToNBT(nbttagcompound1);
- nbttaglist.appendTag(nbttagcompound1);
- }
- }
- nbttagcompound.setTag("Items", nbttaglist);
- }
- public void readFromNBT(NBTTagCompound nbtCompound)
- {
- super.readFromNBT(nbtCompound);
- if (nbtCompound.hasKey("CustomName")) {
- this.customName = nbtCompound.getString("CustomName");
- }
- }
- public void writeToNBT(NBTTagCompound nbtCompound)
- {
- super.writeToNBT(nbtCompound);
- if (hasCustomName()) {
- nbtCompound.setString("CustomName", this.customName);
- }
- }
- public int getInventoryStackLimit()
- {
- return 1;
- }
- public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
- {
- return this.worldObj.getTileEntity(this.pos) == this;
- }
- public void openInventory(EntityPlayer player) {}
- public void closeInventory(EntityPlayer player) {}
- public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack)
- {
- return true;
- }
- public int[] getSlotsForFace(EnumFacing side)
- {
- return slots;
- }
- public boolean canInsertItem(int par1, ItemStack par2ItemStack, EnumFacing par3)
- {
- return getStackInSlot(par1) == null;
- }
- public boolean canExtractItem(int par1, ItemStack par2ItemStack, EnumFacing par3)
- {
- return true;
- }
- public boolean receiveClientEvent(int i, int j)
- {
- if (i == 11)
- {
- if (this.worldObj.isRemote) {
- for (int a = 0; a < Thaumcraft.proxy.getFX().particleCount(5); a++) {
- Thaumcraft.proxy.getFX().drawBlockSparkle(this.pos.up(), 12583104, 2);
- }
- }
- return true;
- }
- if (i == 12)
- {
- if (this.worldObj.isRemote) {
- for (int a = 0; a < Thaumcraft.proxy.getFX().particleCount(10); a++) {
- Thaumcraft.proxy.getFX().drawBlockSparkle(this.pos.up(), 55537, 2);
- }
- }
- return true;
- }
- return super.receiveClientEvent(i, j);
- }
- public int getField(int id)
- {
- return 0;
- }
- public void setField(int id, int value) {}
- public int getFieldCount()
- {
- return 0;
- }
- public void clear() {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement