Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.45 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 74ea01d..c941a10 100644
  3. --- a/src/main/java/com/carpentersblocks/block/BlockCoverable.java
  4. +++ b/src/main/java/com/carpentersblocks/block/BlockCoverable.java
  5. @@ -3,6 +3,7 @@ package com.carpentersblocks.block;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8. import java.util.Random;
  9. +
  10. import net.minecraft.block.Block;
  11. import net.minecraft.block.BlockContainer;
  12. import net.minecraft.block.BlockDirectional;
  13. @@ -29,6 +30,7 @@ import net.minecraftforge.client.ForgeHooksClient;
  14. import net.minecraftforge.common.ForgeHooks;
  15. import net.minecraftforge.common.IPlantable;
  16. import net.minecraftforge.common.util.ForgeDirection;
  17. +
  18. import com.carpentersblocks.api.ICarpentersChisel;
  19. import com.carpentersblocks.api.ICarpentersHammer;
  20. import com.carpentersblocks.renderer.helper.FancyFluidsHelper;
  21. @@ -44,6 +46,7 @@ import com.carpentersblocks.util.protection.PlayerPermissions;
  22. import com.carpentersblocks.renderer.helper.FancyFluidsHelper;
  23. @@ -44,6 +46,7 @@ import com.carpentersblocks.util.protection.PlayerPermissions;
  24. import com.carpentersblocks.util.registry.FeatureRegistry;
  25. import com.carpentersblocks.util.registry.IconRegistry;
  26. import com.carpentersblocks.util.registry.ItemRegistry;
  27. +
  28. import cpw.mods.fml.relauncher.Side;
  29. import cpw.mods.fml.relauncher.SideOnly;
  30.  
  31. @@ -312,78 +315,67 @@ public class BlockCoverable extends BlockContainer {
  32. */
  33. public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer)
  34. {
  35. - if (!world.isRemote)
  36. - {
  37. - TEBase TE = getTileEntity(world, x, y, z);
  38. -
  39. - if (TE != null)
  40. - {
  41. - if (PlayerPermissions.canPlayerEdit(TE, TE.xCoord, TE.yCoord, TE.zCoord, entityPlayer))
  42. - {
  43. - ActionResult actionResult = new ActionResult();
  44. - ItemStack itemStack = entityPlayer.getCurrentEquippedItem();
  45. -
  46. - if (itemStack != null) {
  47. -
  48. - int effectiveSide = TE.hasAttribute(TE.ATTR_COVER[EventHandler.eventFace]) ? EventHandler.eventFace : 6;
  49. - Item item = itemStack.getItem();
  50. -
  51. - if (item instanceof ICarpentersHammer && ((ICarpentersHammer)item).canUseHammer(world, entityPlayer)) {
  52. -
  53. - preOnBlockClicked(TE, world, x, y, z, entityPlayer, actionResult);
  54. -
  55. - if (!actionResult.altered) {
  56. -
  57. - if (entityPlayer.isSneaking()) {
  58. -
  59. - if (TE.hasAttribute(TE.ATTR_ILLUMINATOR)) {
  60. - TE.removeAttribute(TE.ATTR_ILLUMINATOR);
  61. - actionResult.setAltered();
  62. - } else if (TE.hasAttribute(TE.ATTR_OVERLAY[effectiveSide])) {
  63. - TE.removeAttribute(TE.ATTR_OVERLAY[effectiveSide]);
  64. - actionResult.setAltered();
  65. - } else if (TE.hasAttribute(TE.ATTR_DYE[effectiveSide])) {
  66. - TE.removeAttribute(TE.ATTR_DYE[effectiveSide]);
  67. - actionResult.setAltered();
  68. - } else if (TE.hasAttribute(TE.ATTR_COVER[effectiveSide])) {
  69. - TE.removeAttribute(TE.ATTR_COVER[effectiveSide]);
  70. - TE.removeChiselDesign(effectiveSide);
  71. - actionResult.setAltered();
  72. - }
  73. -
  74. - } else {
  75. -
  76. - onHammerLeftClick(TE, entityPlayer);
  77. - actionResult.setAltered();
  78. -
  79. - }
  80. -
  81. - }
  82. -
  83. - if (actionResult.altered) {
  84. - onNeighborBlockChange(world, x, y, z, this);
  85. - world.notifyBlocksOfNeighborChange(x, y, z, this);
  86. - }
  87. -
  88. - } else if (item instanceof ICarpentersChisel && ((ICarpentersChisel)item).canUseChisel(world, entityPlayer)) {
  89. -
  90. - if (entityPlayer.isSneaking()) {
  91. -
  92. - if (TE.hasChiselDesign(effectiveSide)) {
  93. - TE.removeChiselDesign(effectiveSide);
  94. - }
  95. + if (world.isRemote) {
  96. + return;
  97. + }
  98. +
  99. + TEBase TE = getTileEntity(world, x, y, z);
  100.  
  101. - } else if (TE.hasAttribute(TE.ATTR_COVER[effectiveSide])) {
  102. + if (TE == null && !PlayerPermissions.canPlayerEdit(TE, TE.xCoord, TE.yCoord, TE.zCoord, entityPlayer)) {
  103. + return;
  104. + }
  105. +
  106. + ItemStack itemStack = entityPlayer.getCurrentEquippedItem();
  107.  
  108. - onChiselClick(TE, effectiveSide, true);
  109. + if (itemStack == null) {
  110. + return;
  111. + }
  112.  
  113. - }
  114. - }
  115. - }
  116. + int effectiveSide = TE.hasAttribute(TE.ATTR_COVER[EventHandler.eventFace]) ? EventHandler.eventFace : 6;
  117. + Item item = itemStack.getItem();
  118. +
  119. + if (item instanceof ICarpentersHammer && ((ICarpentersHammer)item).canUseHammer(world, entityPlayer)) {
  120. +
  121. + ActionResult actionResult = new ActionResult();
  122. + preOnBlockClicked(TE, world, x, y, z, entityPlayer, actionResult);
  123. +
  124. + if (!actionResult.altered) {
  125. + if (entityPlayer.isSneaking()) {
  126. + checkTileEntityAttribute(TE, effectiveSide);
  127. + } else {
  128. + onHammerLeftClick(TE, entityPlayer);
  129. }
  130. + actionResult.setAltered();
  131. + } else {
  132. + onNeighborBlockChange(world, x, y, z, this);
  133. + world.notifyBlocksOfNeighborChange(x, y, z, this);
  134. + }
  135. +
  136. + } else if (item instanceof ICarpentersChisel && ((ICarpentersChisel)item).canUseChisel(world, entityPlayer)) {
  137. +
  138. + if (entityPlayer.isSneaking() && TE.hasChiselDesign(effectiveSide)) {
  139. + TE.removeChiselDesign(effectiveSide);
  140. + } else if (TE.hasAttribute(TE.ATTR_COVER[effectiveSide])) {
  141. + onChiselClick(TE, effectiveSide, true);
  142. }
  143. +
  144. }
  145. +
  146. + }
  147. +
  148. + private void checkTileEntityAttribute (TEBase te, int effectiveSide) {
  149. + if (te.hasAttribute(te.ATTR_ILLUMINATOR)) {
  150. + te.removeAttribute(te.ATTR_ILLUMINATOR);
  151. + } else if (te.hasAttribute(te.ATTR_OVERLAY[effectiveSide])) {
  152. + te.removeAttribute(te.ATTR_OVERLAY[effectiveSide]);
  153. + } else if (te.hasAttribute(te.ATTR_DYE[effectiveSide])) {
  154. + te.removeAttribute(te.ATTR_DYE[effectiveSide]);
  155. + } else if (te.hasAttribute(te.ATTR_COVER[effectiveSide])) {
  156. + te.removeAttribute(te.ATTR_COVER[effectiveSide]);
  157. + te.removeChiselDesign(effectiveSide);
  158. + }
  159. }
  160. +
  161.  
  162. @Override
  163. /**
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement