wasliebob

Dahell

Dec 30th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.33 KB | None | 0 0
  1. package thaumcraftextras.blocks.tileEntity;
  2.  
  3. import net.minecraft.nbt.NBTTagCompound;
  4. import net.minecraft.network.INetworkManager;
  5. import net.minecraft.network.packet.Packet;
  6. import net.minecraft.network.packet.Packet132TileEntityData;
  7. import net.minecraft.tileentity.TileEntity;
  8. import net.minecraftforge.common.ForgeDirection;
  9. import thaumcraft.api.aspects.Aspect;
  10. import thaumcraft.common.tiles.TileJarFillable;
  11. import thaumcraftextras.main.Config;
  12.  
  13. public class TileEntityGenerator extends TileEntity {
  14. private String am = "amount";
  15. private static String AMOUNT = "AMOUNT";
  16. private int ticks;
  17. int x, y, z;
  18. public ForgeDirection orientation;
  19.  
  20. public TileEntityGenerator()
  21. {
  22. orientation.getOrientation(1) ;
  23. ticks = 10;
  24. }
  25.  
  26. @Override
  27. public void updateEntity()
  28. {
  29. findEssentia();
  30. TileEntity potentia = super.worldObj.getBlockTileEntity(x, y, z);
  31. if (potentia != null && (potentia instanceof TileJarFillable)) {
  32. if (checkJar((TileJarFillable) potentia))
  33. {
  34. System.out.print("YEAHHH");
  35. }
  36. }
  37. }
  38.  
  39. public void setName(String value)
  40. {
  41. am = value;
  42. }
  43.  
  44. public String getName()
  45. {
  46. return am;
  47. }
  48.  
  49. @Override
  50. public void writeToNBT(NBTTagCompound nbt)
  51. {
  52. super.writeToNBT(nbt);
  53. nbt.setString(AMOUNT, am);
  54. }
  55.  
  56. @Override
  57. public void readFromNBT(NBTTagCompound nbt)
  58. {
  59. super.readFromNBT(nbt);
  60. am = nbt.getString(AMOUNT);
  61. }
  62.  
  63. @Override
  64. public Packet getDescriptionPacket() {
  65. NBTTagCompound tagCompound = new NBTTagCompound();
  66. writeToNBT(tagCompound);
  67. return new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, tagCompound);
  68. }
  69.  
  70. @Override
  71. public void onDataPacket(INetworkManager networkManager, Packet132TileEntityData packet) {
  72. this.readFromNBT(packet.data);
  73. }
  74.  
  75. public void findEssentia()
  76. {
  77. if(x != 0x7fffffff)
  78. {
  79. TileEntity te = super.worldObj.getBlockTileEntity(x, y, z);
  80. if(te != null && (te instanceof TileJarFillable))
  81. {
  82. if(checkJar((TileJarFillable)te))
  83. return;
  84. x = 0x7fffffff;
  85. }
  86. }
  87. int xx = 0;
  88. int yy = 0;
  89. int zz = 0;
  90. for(int y = -5; y <= 5; y++)
  91. {
  92. for(int bb = -5; bb <= 5; bb++)
  93. {
  94. for(int cc = 1; cc < 6; cc++)
  95. {
  96. x = 0;
  97. y = 0;
  98. z = 0;
  99. if(orientation.getOpposite().offsetX == 0)
  100. {
  101. x += bb;
  102. z += cc * orientation.getOpposite().offsetZ;
  103. } else
  104. {
  105. zz += bb;
  106. xx += cc * orientation.getOpposite().offsetX;
  107. }
  108. TileEntity te = super.worldObj.getBlockTileEntity(x, y, z);
  109. if(te != null && (te instanceof TileJarFillable) && checkJar((TileJarFillable)te))
  110. return;
  111. }
  112.  
  113. }
  114.  
  115. }
  116.  
  117. }
  118.  
  119. private boolean checkJar(TileJarFillable jar)
  120. {
  121. if(jar.doesContainerContainAmount(Aspect.ENTROPY, 1))
  122. {
  123. x = ((TileEntity) (jar)).xCoord;
  124. y = ((TileEntity) (jar)).yCoord;
  125. z = ((TileEntity) (jar)).zCoord;
  126. if (!super.worldObj.isRemote)
  127. {
  128. jar.takeFromContainer(Aspect.ENTROPY, 1);
  129. super.worldObj.addBlockEvent(super.xCoord, super.yCoord,
  130. super.zCoord, Config.generatorId,
  131. 5, 0);
  132. }
  133. return true;
  134. }
  135. else
  136. {
  137. return false;
  138. }
  139. }
  140.  
  141. /*
  142. private boolean checkEssentia(TileJarFillable jar) {
  143. if (jar.doesContainerContainAmount(Aspect.FIRE, 1)) {
  144. x = ((TileEntity) (jar)).xCoord;
  145. y = ((TileEntity) (jar)).yCoord;
  146. z = ((TileEntity) (jar)).zCoord;
  147. if (!super.worldObj.isRemote) {
  148. jar.takeFromContainer(Aspect.FIRE, 1);
  149. super.worldObj.addBlockEvent(super.xCoord, super.yCoord,
  150. super.zCoord, Config.generatorId,
  151. 5, 0);
  152. }
  153. return true;
  154. } else {
  155. return false;
  156. }
  157. }
  158.  
  159. public void findEssentia()
  160. {
  161. if (x != 0x7fffffff)
  162. {
  163. TileEntity ja = super.worldObj.getBlockTileEntity(x, y, z);
  164. if (ja != null && (ja instanceof TileJarFillable)) {
  165. if (checkEssentia((TileJarFillable) ja)) {
  166. return;
  167. }
  168. x = 0x7fffffff;
  169. }
  170. }
  171. int xx = 0;
  172. int yy = 0;
  173. int zz = 0;
  174. for (int y = -5; y <= 5; y++) {
  175. for (int bb = -5; bb <= 5; bb++) {
  176. for (int cc = 1; cc < 6; cc++) {
  177. xx = super.xCoord;
  178. yy = super.yCoord + y;
  179. zz = super.zCoord;
  180. if (orientation.getOpposite().offsetX == 0) {
  181. xx += bb;
  182. zz += cc * orientation.getOpposite().offsetZ;
  183. } else {
  184. zz += bb;
  185. xx += cc * orientation.getOpposite().offsetX;
  186. }
  187. TileEntity te = super.worldObj.getBlockTileEntity(xx, yy,
  188. zz);
  189. if (te != null && (te instanceof TileJarFillable)
  190. && checkEssentia((TileJarFillable) te)) {
  191. return;
  192. }
  193. }
  194. }
  195. }
  196. }
  197. */
  198. }
Advertisement
Add Comment
Please, Sign In to add comment