Guest User

TileEntityForge

a guest
Mar 8th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. public class TileEntityForge extends TileEntity implements ISidedInventory
  2. {
  3. private String localizedName;
  4.  
  5. private static final int[] slots_top = new int[] {0, 1, 2, 3};
  6. private static final int[] slots_bottom = new int[] {4, 5};
  7. private static final int[] slots_sides = new int[] {4};
  8.  
  9.  
  10. private ItemStack[] slots = new ItemStack[6];
  11.  
  12. public int furnaceSpeed = 500;
  13.  
  14.  
  15.  
  16. public int burnTime;
  17.  
  18. public int currentItemBurnTime;
  19.  
  20. public int cookTime;
  21.  
  22. public int getSizeInventory()
  23. {
  24. return this.slots.length;
  25. }
  26.  
  27. public boolean isInvNameLocalized()
  28. {
  29. return this.localizedName != null && this.localizedName.length() > 0;
  30.  
  31. }
  32.  
  33. public String getInvName()
  34. {
  35. return this.isInvNameLocalized() ? this.localizedName : "container.Forge";
  36. }
  37.  
  38. public void setGuiDisplayName(String displayName)
  39. {
  40. this.localizedName = displayName;
  41. }
  42.  
  43.  
  44. public ItemStack getStackInSlot(int i)
  45. {
  46. return null;
  47. }
  48.  
  49.  
  50. public ItemStack decrStackSize(int i, int j)
  51. {
  52. return null;
  53. }
  54.  
  55.  
  56. public ItemStack getStackInSlotOnClosing(int i)
  57. {
  58. return null;
  59. }
  60.  
  61.  
  62. public void setInventorySlotContents(int i, ItemStack itemstack)
  63. {
  64.  
  65. }
  66.  
  67.  
  68. public int getInventoryStackLimit()
  69. {
  70. return 0;
  71. }
  72.  
  73.  
  74. public boolean isUseableByPlayer(EntityPlayer entityplayer)
  75. {
  76. return false;
  77. }
  78.  
  79.  
  80. public void openChest()
  81. {
  82.  
  83. }
  84.  
  85.  
  86. public void closeChest()
  87. {
  88.  
  89. }
  90.  
  91. public boolean isBurning()
  92. {
  93. return this.burnTime > 0;
  94. }
  95.  
  96. public void updateEntity()
  97. {
  98. boolean flag = this.burnTime > 0;
  99. boolean flag1 = false;
  100.  
  101. if(this.burnTime > 0)
  102. {
  103. this.burnTime--;
  104. }
  105.  
  106. if(!this.worldObj.isRemote)
  107. {
  108. if(this.burnTime == 0 && this.canSmelt())
  109. {
  110. this.currentItemBurnTime = this.burnTime = getItemBurnTime(this.slots[4]);
  111.  
  112. if(this.burnTime > 0)
  113. {
  114. flag1 = true;
  115.  
  116. if(this.slots[4] != null)
  117. {
  118. this.slots[4].stackSize--;
  119.  
  120. if(this.slots[4].stackSize == 0)
  121. {
  122. this.slots[4] = this.slots[4].getItem().getContainerItemStack(this.slots[4]);
  123. }
  124. }
  125. }
  126. }
  127.  
  128. if(this.isBurning() && this.canSmelt())
  129. {
  130. this.cookTime++;
  131.  
  132. if(this.cookTime == this.furnaceSpeed)
  133. {
  134. this.cookTime = 0;
  135. this.smeltItem();
  136. flag1 = true;
  137. }
  138. }
  139.  
  140. else
  141. {
  142. this.cookTime = 0;
  143. }
  144.  
  145. if(flag != this.burnTime > 0)
  146. {
  147. flag1 = true;
  148. BlockForge.updateForgeBlockState(this.burnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
  149. }
  150. }
  151.  
  152. if(flag1)
  153. {
  154. this.onInventoryChanged();
  155. }
  156. }
  157.  
  158. private boolean canSmelt()
  159. {
  160. if(this.slots[0] == null)
  161. {
  162. return false;
  163. }
  164. else
  165. {
  166.  
  167. }
  168.  
  169. if(this.slots[1] == null)
  170. {
  171. return false;
  172. }
  173. else
  174. {
  175.  
  176. }
  177.  
  178. if(this.slots[2] == null)
  179. {
  180. return false;
  181. }
  182. else
  183. {
  184.  
  185. }
  186.  
  187. if(this.slots[3] == null)
  188. {
  189. return false;
  190. }
  191. else
  192. {
  193.  
  194. }
  195.  
  196. }
  197.  
  198. public static int getItemBurnTime(ItemStack itemstack)
  199. {
  200. if(itemstack == null)
  201. {
  202. return 0;
  203. }
  204. else
  205. {
  206. int i = itemstack.getItem().itemID;
  207.  
  208. if(i == Item.coal.itemID) return 1600;
  209.  
  210. return GameRegistry.getFuelValue(itemstack);
  211. }
  212. }
  213.  
  214. public static boolean isItemFuel(ItemStack itemstack)
  215. {
  216. return getItemBurnTime(itemstack) == 1600;
  217. }
  218.  
  219. public boolean isItemValidForSlot(int i, ItemStack itemstack)
  220. {
  221. return i == 5 ? false : (i == 4 ? isItemFuel(itemstack) : true);
  222. }
  223.  
  224.  
  225. public int[] getAccessibleSlotsFromSide(int var1)
  226. {
  227. return var1 == 0 ? slots_bottom : (var1 == 4 ? slots_top : slots_sides);
  228. }
  229.  
  230.  
  231. public boolean canInsertItem(int i, ItemStack itemstack, int j)
  232. {
  233. return this.isItemValidForSlot(i, itemstack);
  234. }
  235.  
  236.  
  237. public boolean canExtractItem(int i, ItemStack itemstack, int j)
  238. {
  239. return j != 0 || i != 1 || itemstack.itemID == Item.bucketEmpty.itemID;
  240. }
  241.  
  242. }
Advertisement
Add Comment
Please, Sign In to add comment