Advertisement
Guest User

Untitled

a guest
Dec 21st, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.53 KB | None | 0 0
  1. public class TilePedestal
  2. extends TileThaumcraft
  3. implements ISidedInventory
  4. {
  5. private static final int[] slots = { 0 };
  6. private ItemStack[] inventory = new ItemStack[1];
  7. private String customName;
  8.  
  9. @SideOnly(Side.CLIENT)
  10. public AxisAlignedBB getRenderBoundingBox()
  11. {
  12. return AxisAlignedBB.fromBounds(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX() + 1, getPos().getY() + 2, getPos().getZ() + 1);
  13. }
  14.  
  15. public int getSizeInventory()
  16. {
  17. return 1;
  18. }
  19.  
  20. public ItemStack getStackInSlot(int par1)
  21. {
  22. return this.inventory[par1];
  23. }
  24.  
  25. public ItemStack decrStackSize(int par1, int par2)
  26. {
  27. if (this.inventory[par1] != null)
  28. {
  29. if (!this.worldObj.isRemote) {
  30. this.worldObj.markBlockForUpdate(this.pos);
  31. }
  32. if (this.inventory[par1].stackSize <= par2)
  33. {
  34. ItemStack itemstack = this.inventory[par1];
  35. this.inventory[par1] = null;
  36. markDirty();
  37. return itemstack;
  38. }
  39. ItemStack itemstack = this.inventory[par1].splitStack(par2);
  40. if (this.inventory[par1].stackSize == 0) {
  41. this.inventory[par1] = null;
  42. }
  43. markDirty();
  44. return itemstack;
  45. }
  46. return null;
  47. }
  48.  
  49. public ItemStack getStackInSlotOnClosing(int par1)
  50. {
  51. if (this.inventory[par1] != null)
  52. {
  53. ItemStack itemstack = this.inventory[par1];
  54. this.inventory[par1] = null;
  55. return itemstack;
  56. }
  57. return null;
  58. }
  59.  
  60. public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
  61. {
  62. this.inventory[par1] = par2ItemStack;
  63. if ((par2ItemStack != null) && (par2ItemStack.stackSize > getInventoryStackLimit())) {
  64. par2ItemStack.stackSize = getInventoryStackLimit();
  65. }
  66. markDirty();
  67. if (!this.worldObj.isRemote) {
  68. this.worldObj.markBlockForUpdate(this.pos);
  69. }
  70. }
  71.  
  72. public void setInventorySlotContentsFromInfusion(int par1, ItemStack par2ItemStack)
  73. {
  74. this.inventory[par1] = par2ItemStack;
  75. markDirty();
  76. if (!this.worldObj.isRemote) {
  77. this.worldObj.markBlockForUpdate(this.pos);
  78. }
  79. }
  80.  
  81. public String getName()
  82. {
  83. return hasCustomName() ? this.customName : "container.pedestal";
  84. }
  85.  
  86. public boolean hasCustomName()
  87. {
  88. return (this.customName != null) && (this.customName.length() > 0);
  89. }
  90.  
  91. public IChatComponent getDisplayName()
  92. {
  93. return hasCustomName() ? new ChatComponentText(getName()) : new ChatComponentTranslation(getName(), new Object[0]);
  94. }
  95.  
  96. public void readCustomNBT(NBTTagCompound nbttagcompound)
  97. {
  98. NBTTagList nbttaglist = nbttagcompound.getTagList("Items", 10);
  99. this.inventory = new ItemStack[getSizeInventory()];
  100. for (int i = 0; i < nbttaglist.tagCount(); i++)
  101. {
  102. NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
  103. byte b0 = nbttagcompound1.getByte("Slot");
  104. if ((b0 >= 0) && (b0 < this.inventory.length)) {
  105. this.inventory[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
  106. }
  107. }
  108. }
  109.  
  110. public void writeCustomNBT(NBTTagCompound nbttagcompound)
  111. {
  112. NBTTagList nbttaglist = new NBTTagList();
  113. for (int i = 0; i < this.inventory.length; i++) {
  114. if (this.inventory[i] != null)
  115. {
  116. NBTTagCompound nbttagcompound1 = new NBTTagCompound();
  117. nbttagcompound1.setByte("Slot", (byte)i);
  118. this.inventory[i].writeToNBT(nbttagcompound1);
  119. nbttaglist.appendTag(nbttagcompound1);
  120. }
  121. }
  122. nbttagcompound.setTag("Items", nbttaglist);
  123. }
  124.  
  125. public void readFromNBT(NBTTagCompound nbtCompound)
  126. {
  127. super.readFromNBT(nbtCompound);
  128. if (nbtCompound.hasKey("CustomName")) {
  129. this.customName = nbtCompound.getString("CustomName");
  130. }
  131. }
  132.  
  133. public void writeToNBT(NBTTagCompound nbtCompound)
  134. {
  135. super.writeToNBT(nbtCompound);
  136. if (hasCustomName()) {
  137. nbtCompound.setString("CustomName", this.customName);
  138. }
  139. }
  140.  
  141. public int getInventoryStackLimit()
  142. {
  143. return 1;
  144. }
  145.  
  146. public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
  147. {
  148. return this.worldObj.getTileEntity(this.pos) == this;
  149. }
  150.  
  151. public void openInventory(EntityPlayer player) {}
  152.  
  153. public void closeInventory(EntityPlayer player) {}
  154.  
  155. public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack)
  156. {
  157. return true;
  158. }
  159.  
  160. public int[] getSlotsForFace(EnumFacing side)
  161. {
  162. return slots;
  163. }
  164.  
  165. public boolean canInsertItem(int par1, ItemStack par2ItemStack, EnumFacing par3)
  166. {
  167. return getStackInSlot(par1) == null;
  168. }
  169.  
  170. public boolean canExtractItem(int par1, ItemStack par2ItemStack, EnumFacing par3)
  171. {
  172. return true;
  173. }
  174.  
  175. public boolean receiveClientEvent(int i, int j)
  176. {
  177. if (i == 11)
  178. {
  179. if (this.worldObj.isRemote) {
  180. for (int a = 0; a < Thaumcraft.proxy.getFX().particleCount(5); a++) {
  181. Thaumcraft.proxy.getFX().drawBlockSparkle(this.pos.up(), 12583104, 2);
  182. }
  183. }
  184. return true;
  185. }
  186. if (i == 12)
  187. {
  188. if (this.worldObj.isRemote) {
  189. for (int a = 0; a < Thaumcraft.proxy.getFX().particleCount(10); a++) {
  190. Thaumcraft.proxy.getFX().drawBlockSparkle(this.pos.up(), 55537, 2);
  191. }
  192. }
  193. return true;
  194. }
  195. return super.receiveClientEvent(i, j);
  196. }
  197.  
  198. public int getField(int id)
  199. {
  200. return 0;
  201. }
  202.  
  203. public void setField(int id, int value) {}
  204.  
  205. public int getFieldCount()
  206. {
  207. return 0;
  208. }
  209.  
  210. public void clear() {}
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement