Guest User

Untitled

a guest
Dec 23rd, 2014
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. public void findBlock()
  2. {
  3. int xCoord = pos.getX();
  4. int yCoord = pos.getY();
  5. int zCoord = pos.getZ();
  6.  
  7. if(isMachine(xCoord+1, yCoord, zCoord))
  8. {
  9. machine[0] = (TileMachineBase) worldObj.getTileEntity(new BlockPos(xCoord+1, yCoord, zCoord));
  10. }
  11. else machine[0] = null;
  12. if(isMachine(xCoord-1, yCoord, zCoord))
  13. {
  14. machine[1] = (TileMachineBase) worldObj.getTileEntity(new BlockPos(xCoord-1, yCoord, zCoord));
  15. }
  16. else machine[1] = null;
  17. if(isMachine(xCoord, yCoord+1, zCoord))
  18. {
  19. machine[2] = (TileMachineBase) worldObj.getTileEntity(new BlockPos(xCoord, yCoord+1, zCoord));
  20. }
  21. else machine[2] = null;
  22. if(isMachine(xCoord, yCoord-1, zCoord))
  23. {
  24. machine[3] = (TileMachineBase) worldObj.getTileEntity(new BlockPos(xCoord, yCoord-1, zCoord));
  25. }
  26. else machine[3] = null;
  27. if(isMachine(xCoord, yCoord, zCoord+1))
  28. {
  29. machine[4] = (TileMachineBase) worldObj.getTileEntity(new BlockPos(xCoord, yCoord, zCoord+1));
  30. }
  31. else machine[4] = null;
  32. if(isMachine(xCoord, yCoord, zCoord-1))
  33. {
  34. machine[5] = (TileMachineBase) worldObj.getTileEntity(new BlockPos(xCoord, yCoord, zCoord-1));
  35. }
  36. else machine[5] = null;
  37. }
  38.  
  39. public void givePower()
  40. {
  41. findBlock();
  42. for (int i = 0; i < machine.length; i++)
  43. {
  44. if (machine[i] != null & machine[i].canAcceptPower())
  45. {
  46. machine[i].setPower(1);
  47. power -= 1;
  48. }
  49. }
  50. }
  51.  
  52. public boolean isMachine(int x, int y, int z){
  53. return this.worldObj.getTileEntity(new BlockPos(x, y, z)) instanceof TileMachineBase;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment