MCPcopy Index your code
hub / github.com/GregTech6/gregtech6 / onToolClick

Method onToolClick

src/main/java/gregapi/block/ToolCompat.java:82–380  ·  view source on GitHub ↗

Providing compatibility for vanilla Blocks and certain Mod Interfaces.

(Block aBlock, String aTool, long aRemainingDurability, long aQuality, Entity aPlayer, List<String> aChatReturn, IInventory aPlayerInventory, boolean aSneaking, ItemStack aStack, World aWorld, byte aSide, int aX, int aY, int aZ, float aHitX, float aHitY, float aHitZ)

Source from the content-addressed store, hash-verified

80
81 /** Providing compatibility for vanilla Blocks and certain Mod Interfaces. */
82 public static long onToolClick(Block aBlock, String aTool, long aRemainingDurability, long aQuality, Entity aPlayer, List<String> aChatReturn, IInventory aPlayerInventory, boolean aSneaking, ItemStack aStack, World aWorld, byte aSide, int aX, int aY, int aZ, float aHitX, float aHitY, float aHitZ) {
83 byte aMeta = WD.meta(aWorld, aX, aY, aZ);
84 TileEntity aTileEntity = WD.te(aWorld, aX, aY, aZ, T);
85 EntityPlayer aEntityPlayer = aPlayer instanceof EntityPlayer ? (EntityPlayer)aPlayer : null;
86 EntityLivingBase aEntityLiving = aPlayer instanceof EntityLivingBase ? (EntityLivingBase)aPlayer : null;
87
88 try {
89
90 if (aTool.equals(TOOL_hoe) && (aEntityPlayer == null || aEntityPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack))) {
91 if (!MinecraftForge.EVENT_BUS.post(new UseHoeEvent(aEntityPlayer, aStack, aWorld, aX, aY, aZ))) {
92 if (SIDES_TOP_HORIZONTAL[aSide] && !WD.hasCollide(aWorld, aX, aY+1, aZ) && (aBlock == Blocks.grass || aBlock == Blocks.dirt || aBlock == BlocksGT.Grass || IL.EtFu_Path.equal(aBlock) || IL.BoP_Grass_Origin.equal(aBlock) || IL.BoP_Grass_Long.equal(aBlock))) {
93 aWorld.playSoundEffect(aX + 0.5F, aY + 0.5F, aZ + 0.5F, Blocks.farmland.stepSound.getStepResourcePath(), (Blocks.farmland.stepSound.getVolume() + 1.0F) * 0.5F, Blocks.farmland.stepSound.getPitch() * 0.8F);
94 if (!aWorld.isRemote) aWorld.setBlock(aX, aY, aZ, Blocks.farmland);
95 return 10000;
96 }
97 }
98 }
99
100 if (aWorld.isRemote) return 0;
101
102 boolean aCanCollect = (ST.item(aStack) instanceof MultiItemTool && ((MultiItemTool)ST.item_(aStack)).canCollectDropsDirectly(aStack));
103
104 if (aTool.equals(TOOL_axe) || aTool.equals(TOOL_saw) || aTool.equals(TOOL_knife)) {
105 boolean rReturn = F;
106 ItemStack tBark = OM.dust(MT.Bark);
107
108 if (!rReturn && BlocksGT.BeamA != null) {
109 if (IL.HaC_Log_Maple.equal(aBlock)) {
110 rReturn = aWorld.setBlock(aX, aY, aZ, BlocksGT.BeamA, 1, 3);
111 }
112 }
113 if (!rReturn && BlocksGT.BeamB != null) {
114 if (IL.HaC_Log_Cinnamon.equal(aBlock)) {
115 rReturn = aWorld.setBlock(aX, aY, aZ, BlocksGT.BeamB, 1, 3);
116 if (rReturn) tBark = IL.HaC_Cinnamon.get(2, IL.Food_Cinnamon.get(2, OM.dust(MT.Cinnamon, U*2)));
117 }
118 }
119 if (!rReturn && MD.NeLi.mLoaded && (aMeta & 1) == 0) {
120 if (IL.NeLi_Stem_Crimson.equal(aBlock) || IL.NeLi_Stem_FoxFire.equal(aBlock) || IL.NeLi_Hyphae_Crimson.equal(aBlock) ) {
121 rReturn = aWorld.setBlock(aX, aY, aZ, aBlock, aMeta+1, 3);
122 tBark = null;
123 }
124 }
125 if (!rReturn && BlocksGT.Beam1 != null) {
126 if (aBlock == Blocks.log || IL.EtFu_Bark_Oak.equal(aBlock)) {
127 rReturn = aWorld.setBlock(aX, aY, aZ, BlocksGT.Beam1, aMeta, 3);
128 } else if (IL.TF_Log_Darkwood.equal(aBlock) && (aMeta & 3) != 3) {
129 rReturn = aWorld.setBlock(aX, aY, aZ, BlocksGT.Beam1, aMeta, 3);
130 } else if (IL.TF_Log_Time.equal(aBlock) && (aMeta & 1) == 0) {
131 rReturn = aWorld.setBlock(aX, aY, aZ, BlocksGT.Beam1, (aMeta&12)|((aMeta & 2) == 0 ? 1 : 2), 3);
132 } else if (IL.HaC_Log_Paperbark.equal(aBlock)) {
133 rReturn = aWorld.setBlock(aX, aY, aZ, BlocksGT.Beam1, 3, 3);
134 if (rReturn) tBark = ST.make(Items.paper, 4, 0);
135 }
136 }
137 if (!rReturn && BlocksGT.Beam3 != null) {
138 if (IL.TC_Greatwood_Log.equal(aBlock)) {
139 if ((aMeta & 3) < 2)

Callers 15

onToolClickMethod · 0.95
onToolClickMethod · 0.95
onToolClickMethod · 0.95
onToolClickMethod · 0.95
onToolClickMethod · 0.95
onToolClickMethod · 0.95
onToolClickMethod · 0.95
onToolClickMethod · 0.95
onToolClickMethod · 0.95
onToolClickMethod · 0.95
onToolClickMethod · 0.95
onToolClickMethod · 0.95

Calls 15

metaMethod · 0.95
teMethod · 0.95
hasCollideMethod · 0.95
itemMethod · 0.95
item_Method · 0.95
dustMethod · 0.95
makeMethod · 0.95
leafdecayMethod · 0.95
giveMethod · 0.95
suckAllMethod · 0.95
blockMethod · 0.95
oxygenMethod · 0.95

Tested by

no test coverage detected