Advertisement
Mister-Yaoi

Untitled

Oct 12th, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.51 KB | None | 0 0
  1. /**
  2. * Returns true if the block is emitting direct/strong redstone power on the specified side. Args: World, X, Y, Z,
  3. * side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
  4. */
  5. public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
  6. {
  7. return this.isProvidingWeakPower(par1IBlockAccess, par2, par3, par4, par5);
  8. }
  9.  
  10. /**
  11. * Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube
  12. * returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X,
  13. * Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
  14. */
  15. public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
  16. {
  17. int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
  18. int var6 = getOrientation(var5);
  19.  
  20. {
  21. if (!this.func_96470_c(var5))
  22. {
  23. return 0;
  24. }
  25.  
  26. if (var6 == 0 && par5 == 1) return 15;
  27. if (var6 == 1 && par5 == 0) return 15;
  28. if (var6 == 2 && par5 == 3) return 15;
  29. if (var6 == 3 && par5 == 2) return 15;
  30. if (var6 == 4 && par5 == 5) return 15;
  31. if (var6 == 5 && par5 == 4) return 15;
  32.  
  33. else return 0;
  34. }
  35. }
  36.  
  37.  
  38.  
  39. /**
  40. * Returns the signal strength at one input of the block. Args: world, X, Y, Z, side
  41. */
  42. protected int getInputStrength(World par1World, IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
  43. {
  44. int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
  45. int var6 = getOrientation(var5);
  46. boolean var7 = this.isIndirectlyPowered(par1World, par2, par3, par4, var6);
  47.  
  48. int power = 0;
  49.  
  50. if (var7 && par5 == 0 || var7 && par5 == 1 || var7 && par5 == 2 || var7 && par5 == 3 || var7 && par5 == 4 || var7 && par5 == 5) return power = 15;
  51.  
  52.  
  53. return power;
  54.  
  55. //return var9 >= 15 ? var9 : Math.max(var9, par1World.getBlockId(var7, par3, var8) == Block.redstoneWire.blockID ? par1World.getBlockMetadata(var7, par3, var8) : 0);
  56. }
  57.  
  58. //Determins how many blocks away from side the power source needs to be.
  59. //0 bottom, 1 top, 2 south, 3 north, 4 east, 5 west
  60. public int offsetX (World par1World, IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
  61. {
  62. int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
  63. int var6 = getOrientation(var5);
  64.  
  65. if (var6 == 0) return 0; if (var6 == 1) return 0; if (var6 == 2) return 0; if (var6 == 3) return 0; if (var6 == 4) return 1; if (var6 == 5) return -1;
  66.  
  67. else return 0;
  68. }
  69.  
  70. //Determins how many blocks away from side the power source needs to be.
  71. //0 bottom, 1 top, 2 south, 3 north, 4 east, 5 west
  72. public int offsetY (World par1World, IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
  73. {
  74. int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
  75. int var6 = getOrientation(var5);
  76.  
  77. if (var6 == 0) return 1; if (var6 == 1) return -1; if (var6 == 2) return 0; if (var6 == 3) return 0; if (var6 == 4) return 0; if (var6 == 5) return 0;
  78.  
  79. else return 0;
  80. }
  81.  
  82. //Determins how many blocks away from side the power source needs to be.
  83. //0 bottom, 1 top, 2 south, 3 north, 4 east, 5 west
  84. public int offsetZ (World par1World, IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
  85. {
  86. int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
  87. int var6 = getOrientation(var5);
  88. if (var6 == 0) return 0; if (var6 == 1) return 0; if (var6 == 2) return 1; if (var6 == 3) return -1; if (var6 == 4) return 0; if (var6 == 5) return 0;
  89.  
  90. else return 0;
  91. }
  92.  
  93. /**
  94. * checks the block to that side to see if it is indirectly powered.
  95. */
  96. private boolean isIndirectlyPowered(World par1World, int par2, int par3, int par4, int par5)
  97. {
  98. int var7 = par2 + this.offsetX(par1World, par1World, par2, par3, par4);
  99. int var8 = par3 + this.offsetY(par1World, par1World, par2, par3, par4);
  100. int var9 = par4 + this.offsetZ(par1World, par1World, par2, par3, par4);
  101.  
  102. return par5 != 0 && par1World.getIndirectPowerOutput(var7, var8, var9, 0) ?
  103. true : (par5 != 1 && par1World.getIndirectPowerOutput(var7, var8, var9, 1) ?
  104. true : (par5 != 0 && par1World.getIndirectPowerOutput(par2, par3 - 1, par4, 0) ?
  105. true : (par5 != 1 && par1World.getIndirectPowerOutput(par2, par3 + 1, par4, 1) ?
  106. true : (par5 != 2 && par1World.getIndirectPowerOutput(par2, par3, par4 - 1, 2) ?
  107. true : (par5 != 3 && par1World.getIndirectPowerOutput(par2, par3, par4 + 1, 3) ?
  108. true : (par5 != 5 && par1World.getIndirectPowerOutput(par2 + 1, par3, par4, 5) ?
  109. true : (par5 != 4 && par1World.getIndirectPowerOutput(par2 - 1, par3, par4, 4))))))));
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement