Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.95 KB | None | 0 0
  1. diff --git a/src/main/java/com/carpentersblocks/block/BlockCoverable.java b/src/main/java/com/carpentersblocks/block/BlockCoverable.java
  2. index 6146486..e10c2fe 100644
  3. --- a/src/main/java/com/carpentersblocks/block/BlockCoverable.java
  4. +++ b/src/main/java/com/carpentersblocks/block/BlockCoverable.java
  5. @@ -605,6 +605,17 @@ public class BlockCoverable extends BlockContainer {
  6.  
  7. return power;
  8. }
  9. +
  10. + /**
  11. + * Check the tile entity to see if it has the attribute specified by the provided byte.
  12. + * Includes null check on the tile entity.
  13. + * @param te
  14. + * @param b
  15. + * @return
  16. + */
  17. + private boolean TEHasAttribute (TEBase te, byte b) {
  18. + return te != null && te.hasAttribute(b);
  19. + }
  20.  
  21. @Override
  22. /**
  23. @@ -618,22 +629,22 @@ public class BlockCoverable extends BlockContainer {
  24.  
  25. /* Strong power is provided by the base cover, or a side cover if one exists. */
  26.  
  27. - if (TE != null) {
  28. - int effectiveSide = ForgeDirection.OPPOSITES[side];
  29. - if (TE.hasAttribute(TE.ATTR_COVER[effectiveSide])) {
  30. - Block block = BlockProperties.toBlock(BlockProperties.getCover(TE, effectiveSide));
  31. - int tempPower = block.isProvidingWeakPower(blockAccess, x, y, z, side);
  32. - if (tempPower > power) {
  33. - power = tempPower;
  34. - }
  35. - } else if (TE.hasAttribute(TE.ATTR_COVER[6])) {
  36. - Block block = BlockProperties.toBlock(BlockProperties.getCover(TE, 6));
  37. - int tempPower = block.isProvidingWeakPower(blockAccess, x, y, z, side);
  38. - if (tempPower > power) {
  39. - power = tempPower;
  40. - }
  41. +
  42. + int effectiveSide = ForgeDirection.OPPOSITES[side];
  43. + if (TEHasAttribute(TE, TE.ATTR_COVER[effectiveSide])) {
  44. + Block block = BlockProperties.toBlock(BlockProperties.getCover(TE, effectiveSide));
  45. + int tempPower = block.isProvidingWeakPower(blockAccess, x, y, z, side);
  46. + if (tempPower > power) {
  47. + power = tempPower;
  48. + }
  49. + } else if (TEHasAttribute(TE, TE.ATTR_COVER[6])) {
  50. + Block block = BlockProperties.toBlock(BlockProperties.getCover(TE, 6));
  51. + int tempPower = block.isProvidingWeakPower(blockAccess, x, y, z, side);
  52. + if (tempPower > power) {
  53. + power = tempPower;
  54. }
  55. }
  56. +
  57.  
  58. return power;
  59. }
  60. @@ -690,7 +701,7 @@ public class BlockCoverable extends BlockContainer {
  61. int effectiveSide = TE.hasAttribute(TE.ATTR_COVER[target.sideHit]) ? target.sideHit : 6;
  62. ItemStack itemStack = BlockProperties.getCover(TE, effectiveSide);
  63.  
  64. - if (TE.hasAttribute(TE.ATTR_OVERLAY[effectiveSide])) {
  65. + if (TEHasAttribute(TE, TE.ATTR_OVERLAY[effectiveSide])) {
  66. Overlay overlay = OverlayHandler.getOverlayType(TE.getAttribute(TE.ATTR_OVERLAY[effectiveSide]));
  67. if (OverlayHandler.coversFullSide(overlay, target.sideHit)) {
  68. itemStack = overlay.getItemStack();
  69. @@ -844,10 +855,8 @@ public class BlockCoverable extends BlockContainer {
  70. {
  71. TEBase TE = getTileEntity(world, x, y, z);
  72.  
  73. - if (TE != null) {
  74. - if (TE.hasAttribute(TE.ATTR_COVER[6])) {
  75. - return BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).getBlockHardness(world, x, y, z);
  76. - }
  77. + if (TEHasAttribute(TE, TE.ATTR_COVER[6])) {
  78. + return BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).getBlockHardness(world, x, y, z);
  79. }
  80.  
  81. return blockHardness;
  82. @@ -893,10 +902,8 @@ public class BlockCoverable extends BlockContainer {
  83. {
  84. TEBase TE = getTileEntity(world, x, y, z);
  85.  
  86. - if (TE != null) {
  87. - if (TE.hasAttribute(TE.ATTR_COVER[6])) {
  88. - return BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).isFireSource(world, x, y, z, side);
  89. - }
  90. + if (TEHasAttribute(TE, TE.ATTR_COVER[6])) {
  91. + return BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).isFireSource(world, x, y, z, side);
  92. }
  93.  
  94. return false;
  95. @@ -910,10 +917,8 @@ public class BlockCoverable extends BlockContainer {
  96. {
  97. TEBase TE = getTileEntity(world, x, y, z);
  98.  
  99. - if (TE != null) {
  100. - if (TE.hasAttribute(TE.ATTR_COVER[6])) {
  101. - return BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).getExplosionResistance(entity);
  102. - }
  103. + if (TEHasAttribute(TE, TE.ATTR_COVER[6])) {
  104. + return BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).getExplosionResistance(entity);
  105. }
  106.  
  107. return this.getExplosionResistance(entity);
  108. @@ -927,10 +932,8 @@ public class BlockCoverable extends BlockContainer {
  109. {
  110. TEBase TE = getTileEntity(blockAccess, x, y, z);
  111.  
  112. - if (TE != null) {
  113. - if (TE.hasAttribute(TE.ATTR_COVER[6])) {
  114. - return BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).isWood(blockAccess, x, y, z);
  115. - }
  116. + if (TEHasAttribute(TE, TE.ATTR_COVER[6])) {
  117. + return BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).isWood(blockAccess, x, y, z);
  118. }
  119.  
  120. return super.isWood(blockAccess, x, y, z);
  121. @@ -944,14 +947,12 @@ public class BlockCoverable extends BlockContainer {
  122. {
  123. TEBase TE = getTileEntity(blockAccess, x, y, z);
  124.  
  125. - if (TE != null) {
  126. - if (TE.hasAttribute(TE.ATTR_COVER[6])) {
  127. - Block block = BlockProperties.toBlock(BlockProperties.getCover(TE, 6));
  128. - if (entity instanceof EntityWither) {
  129. - return !block.equals(Blocks.bedrock) && !block.equals(Blocks.end_portal) && !block.equals(Blocks.end_portal_frame) && !block.equals(Blocks.command_block);
  130. - } else if (entity instanceof EntityDragon) {
  131. - return !block.equals(Blocks.obsidian) && !block.equals(Blocks.end_stone) && !block.equals(Blocks.bedrock);
  132. - }
  133. + if (TEHasAttribute(TE, TE.ATTR_COVER[6])) {
  134. + Block block = BlockProperties.toBlock(BlockProperties.getCover(TE, 6));
  135. + if (entity instanceof EntityWither) {
  136. + return !block.equals(Blocks.bedrock) && !block.equals(Blocks.end_portal) && !block.equals(Blocks.end_portal_frame) && !block.equals(Blocks.command_block);
  137. + } else if (entity instanceof EntityDragon) {
  138. + return !block.equals(Blocks.obsidian) && !block.equals(Blocks.end_stone) && !block.equals(Blocks.bedrock);
  139. }
  140. }
  141.  
  142. @@ -966,10 +967,8 @@ public class BlockCoverable extends BlockContainer {
  143. {
  144. TEBase TE = getTileEntity(world, x, y, z);
  145.  
  146. - if (TE != null) {
  147. - if (TE.hasAttribute(TE.ATTR_COVER[6])) {
  148. - BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).onEntityCollidedWithBlock(world, x, y, z, entity);
  149. - }
  150. + if (TEHasAttribute(TE, TE.ATTR_COVER[6])) {
  151. + BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).onEntityCollidedWithBlock(world, x, y, z, entity);
  152. }
  153. }
  154.  
  155. @@ -1058,11 +1057,8 @@ public class BlockCoverable extends BlockContainer {
  156. {
  157. TEBase TE = getTileEntity(world, x, y, z);
  158.  
  159. - if (TE != null) {
  160. -
  161. - if (TE.hasAttribute(TE.ATTR_COVER[6])) {
  162. - BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).randomDisplayTick(world, x, y, z, random);
  163. - }
  164. + if (TEHasAttribute(TE, TE.ATTR_COVER[6])) {
  165. + BlockProperties.toBlock(BlockProperties.getCover(TE, 6)).randomDisplayTick(world, x, y, z, random);
  166.  
  167. if (TE.hasAttribute(TE.ATTR_OVERLAY[6])) {
  168. if (OverlayHandler.getOverlayType(TE.getAttribute(TE.ATTR_OVERLAY[6])).equals(Overlay.MYCELIUM)) {
  169. (END)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement