grossik

Untitled

Nov 27th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.82 KB | None | 0 0
  1. package cz.grossik.farmcraft2.racks;
  2.  
  3. import javax.annotation.Nullable;
  4.  
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.entity.player.InventoryPlayer;
  7. import net.minecraft.inventory.Container;
  8. import net.minecraft.inventory.ISidedInventory;
  9. import net.minecraft.inventory.ItemStackHelper;
  10. import net.minecraft.item.ItemStack;
  11. import net.minecraft.nbt.NBTTagCompound;
  12. import net.minecraft.nbt.NBTTagList;
  13. import net.minecraft.tileentity.TileEntityLockable;
  14. import net.minecraft.util.EnumFacing;
  15. import net.minecraft.util.ITickable;
  16. import net.minecraftforge.fml.common.FMLCommonHandler;
  17. import net.minecraftforge.fml.relauncher.Side;
  18. import net.minecraftforge.fml.relauncher.SideOnly;
  19.  
  20. public class TileEntityRacks extends TileEntityLockable implements ITickable, ISidedInventory
  21. {
  22. private ItemStack[] wineItemStacks = new ItemStack[9];
  23. private String furnaceCustomName;
  24. private NBTTagCompound update_packet;
  25.  
  26. public int getSizeInventory()
  27. {
  28. return this.wineItemStacks.length;
  29. }
  30.  
  31. public ItemStack getStackInSlot(int index)
  32. {
  33. return this.wineItemStacks[index];
  34. }
  35.  
  36. @Nullable
  37. public ItemStack decrStackSize(int index, int count)
  38. {
  39. return ItemStackHelper.getAndSplit(this.wineItemStacks, index, count);
  40. }
  41.  
  42. @Nullable
  43. public ItemStack removeStackFromSlot(int index)
  44. {
  45. return ItemStackHelper.getAndRemove(this.wineItemStacks, index);
  46. }
  47.  
  48. public void setCustomInventoryName(String p_145951_1_)
  49. {
  50. this.furnaceCustomName = p_145951_1_;
  51. }
  52.  
  53. public void setInventorySlotContents(int index, ItemStack stack)
  54. {
  55. boolean flag = stack != null && stack.isItemEqual(this.wineItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.wineItemStacks[index]);
  56. this.wineItemStacks[index] = stack;
  57.  
  58. if (stack != null && stack.stackSize > this.getInventoryStackLimit())
  59. {
  60. stack.stackSize = this.getInventoryStackLimit();
  61. }
  62. }
  63.  
  64.  
  65. @Override
  66. public int getInventoryStackLimit() {
  67. return 1;
  68. }
  69.  
  70. public void readFromNBT(NBTTagCompound compound)
  71. {
  72. super.readFromNBT(compound);
  73. NBTTagList nbttaglist = compound.getTagList("Items", 10);
  74. this.wineItemStacks = new ItemStack[this.getSizeInventory()];
  75.  
  76. for (int i = 0; i < nbttaglist.tagCount(); ++i)
  77. {
  78. NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
  79. int j = nbttagcompound.getByte("Slot");
  80.  
  81. if (j >= 0 && j < this.wineItemStacks.length)
  82. {
  83. this.wineItemStacks[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
  84. }
  85. }
  86.  
  87. if (compound.hasKey("CustomName", 8))
  88. {
  89. this.furnaceCustomName = compound.getString("CustomName");
  90. }
  91. }
  92.  
  93. public NBTTagCompound writeToNBT(NBTTagCompound compound)
  94. {
  95. super.writeToNBT(compound);
  96. NBTTagList nbttaglist = new NBTTagList();
  97.  
  98. for (int i = 0; i < this.wineItemStacks.length; ++i)
  99. {
  100. if (this.wineItemStacks[i] != null)
  101. {
  102. NBTTagCompound nbttagcompound = new NBTTagCompound();
  103. nbttagcompound.setByte("Slot", (byte)i);
  104. this.wineItemStacks[i].writeToNBT(nbttagcompound);
  105. nbttaglist.appendTag(nbttagcompound);
  106. }
  107. }
  108.  
  109. compound.setTag("Items", nbttaglist);
  110.  
  111. if (this.hasCustomName())
  112. {
  113. compound.setString("CustomName", this.furnaceCustomName);
  114. }
  115. return compound;
  116. }
  117.  
  118. public boolean isUseableByPlayer(EntityPlayer player)
  119. {
  120. return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
  121. }
  122.  
  123.  
  124. public void openInventory(EntityPlayer player)
  125. {
  126. }
  127.  
  128. public void closeInventory(EntityPlayer player)
  129. {
  130. }
  131.  
  132. public boolean isItemValidForSlot(int index, ItemStack stack) {
  133. return false;
  134. }
  135.  
  136. @Override
  137. public int getField(int id) {
  138. return 0;
  139. }
  140.  
  141. @Override
  142. public void setField(int id, int value) {
  143. }
  144.  
  145. @Override
  146. public int getFieldCount() {
  147. return 0;
  148. }
  149.  
  150. public void clear()
  151. {
  152. for (int i = 0; i < this.wineItemStacks.length; ++i)
  153. {
  154. this.wineItemStacks[i] = null;
  155. }
  156. }
  157.  
  158. public String getName() {
  159. return this.hasCustomName() ? this.furnaceCustomName : "Racks";
  160. }
  161.  
  162. public boolean hasCustomName()
  163. {
  164. return this.furnaceCustomName != null && !this.furnaceCustomName.isEmpty();
  165. }
  166.  
  167. @Override
  168. public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
  169. return new ContainerRacks(playerInventory, this);
  170. }
  171.  
  172. @Override
  173. public String getGuiID() {
  174. return "10";
  175. }
  176.  
  177. @Override
  178. public int[] getSlotsForFace(EnumFacing side) {
  179. return null;
  180. }
  181.  
  182. @Override
  183. public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
  184. return this.isItemValidForSlot(index, itemStackIn);
  185. }
  186.  
  187. public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
  188. return true;
  189. }
  190.  
  191. @Override
  192. public void update() {
  193. boolean Check00 = this.Check0();
  194.  
  195. System.out.println(" " + Check00);
  196. }
  197.  
  198. public boolean Check0(){
  199. if(wineItemStacks[0] != null)
  200. {
  201. return true;
  202. } else {
  203. return false;
  204. }
  205. }
  206.  
  207. public boolean Check1(){
  208. if(wineItemStacks[1] != null)
  209. {
  210. return true;
  211. } else {
  212. return false;
  213. }
  214. }
  215.  
  216. public boolean Check2(){
  217. if(wineItemStacks[2] != null)
  218. {
  219. return true;
  220. } else {
  221. return false;
  222. }
  223. }
  224.  
  225. public boolean Check3(){
  226. if(wineItemStacks[3] != null)
  227. {
  228. return true;
  229. } else {
  230. return false;
  231. }
  232. }
  233.  
  234. public boolean Check4(){
  235. if(wineItemStacks[4] != null)
  236. {
  237. return true;
  238. } else {
  239. return false;
  240. }
  241. }
  242.  
  243. public boolean Check5(){
  244. if(wineItemStacks[5] != null)
  245. {
  246. return true;
  247. } else {
  248. return false;
  249. }
  250. }
  251.  
  252. public boolean Check6(){
  253. if(wineItemStacks[6] != null)
  254. {
  255. return true;
  256. } else {
  257. return false;
  258. }
  259. }
  260.  
  261. public boolean Check7(){
  262. if(wineItemStacks[7] != null)
  263. {
  264. return true;
  265. } else {
  266. return false;
  267. }
  268. }
  269.  
  270. public boolean Check8(){
  271. if(wineItemStacks[8] != null)
  272. {
  273. return true;
  274. } else {
  275. return false;
  276. }
  277. }
  278. }
Advertisement
Add Comment
Please, Sign In to add comment