Skip to content

Commit 2671b97

Browse files
committed
[fix] 6 squashed commits
1 parent d2e3364 commit 2671b97

File tree

3 files changed

+87
-8
lines changed

3 files changed

+87
-8
lines changed

src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import meteordevelopment.meteorclient.systems.modules.render.*;
3131
import meteordevelopment.meteorclient.systems.modules.render.blockesp.BlockESP;
3232
import meteordevelopment.meteorclient.systems.modules.render.marker.Marker;
33-
import meteordevelopment.meteorclient.systems.modules.world.Timer;
3433
import meteordevelopment.meteorclient.systems.modules.world.*;
34+
import meteordevelopment.meteorclient.systems.modules.world.Timer;
3535
import meteordevelopment.meteorclient.utils.Utils;
3636
import meteordevelopment.meteorclient.utils.misc.Keybind;
3737
import meteordevelopment.meteorclient.utils.misc.ValueComparableMap;

src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package meteordevelopment.meteorclient.systems.modules.player;
77

88

9-
import meteordevelopment.meteorclient.MeteorClient;
109
import meteordevelopment.meteorclient.events.entity.player.StartBreakingBlockEvent;
1110
import meteordevelopment.meteorclient.events.world.TickEvent;
1211
import meteordevelopment.meteorclient.settings.*;
@@ -155,7 +154,6 @@ private void onTick(TickEvent.Post event) {
155154
if (invSwapReturn.get() && !mc.options.attackKey.isPressed() && wasPressed && toolWasIn != -1) {
156155
InvUtils.quickSwap().fromId(invSwapSlot.get()).to(toolWasIn);
157156
toolWasIn = -1;
158-
wasPressed = false;
159157
return;
160158
}
161159

src/main/java/meteordevelopment/meteorclient/systems/modules/player/ToolSaver.java

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,27 @@
55

66
package meteordevelopment.meteorclient.systems.modules.player;
77

8-
import meteordevelopment.meteorclient.events.entity.player.AttackEntityEvent;
9-
import meteordevelopment.meteorclient.events.entity.player.StartBreakingBlockEvent;
8+
import meteordevelopment.meteorclient.events.entity.player.*;
109
import meteordevelopment.meteorclient.settings.*;
1110
import meteordevelopment.meteorclient.systems.modules.Categories;
1211
import meteordevelopment.meteorclient.systems.modules.Module;
1312
import meteordevelopment.meteorclient.systems.modules.Modules;
1413
import meteordevelopment.meteorclient.utils.Utils;
15-
import meteordevelopment.meteorclient.utils.world.BlockUtils;
1614
import meteordevelopment.orbit.EventHandler;
1715
import meteordevelopment.orbit.EventPriority;
16+
import net.minecraft.block.Block;
17+
import net.minecraft.block.BlockState;
18+
import net.minecraft.block.Blocks;
19+
import net.minecraft.block.PumpkinBlock;
1820
import net.minecraft.enchantment.Enchantments;
21+
import net.minecraft.entity.passive.SheepEntity;
22+
import net.minecraft.entity.passive.SnowGolemEntity;
1923
import net.minecraft.item.*;
24+
import net.minecraft.registry.tag.BlockTags;
2025
import net.minecraft.registry.tag.ItemTags;
2126

2227
import java.util.List;
28+
import java.util.Objects;
2329

2430
public class ToolSaver extends Module {
2531
private final SettingGroup sgGeneral = settings.getDefaultGroup();
@@ -86,6 +92,82 @@ private void onStartBreakingBlock(StartBreakingBlockEvent event) {
8692
}
8793
}
8894

95+
@EventHandler(priority = EventPriority.HIGH)
96+
private void onInteractBlock(InteractBlockEvent event) {
97+
ItemStack s = mc.player.getStackInHand(event.hand);
98+
BlockState bs = mc.world.getBlockState(event.result.getBlockPos());
99+
100+
switch (toolType(s)) {
101+
case AXE:
102+
if (!bs.isIn(BlockTags.LOGS) && !isWaxedCopperBlock(bs.getBlock())) return;
103+
break;
104+
case SHEAR:
105+
if (!(bs.getBlock() instanceof PumpkinBlock)) return;
106+
break;
107+
case FLINT_AND_STEEL:
108+
break;
109+
default:
110+
return;
111+
}
112+
113+
if (!_canUse(s)) {
114+
mc.options.useKey.setPressed(false);
115+
event.cancel();
116+
}
117+
}
118+
119+
@EventHandler(priority = EventPriority.HIGH)
120+
private void onInteractEntity(InteractEntityEvent event) {
121+
ItemStack s = mc.player.getStackInHand(event.hand);
122+
123+
if (toolType(s) != ToolType.SHEAR) return;
124+
if (!(event.entity instanceof SheepEntity || event.entity instanceof SnowGolemEntity)) return;
125+
126+
if (!_canUse(s)) {
127+
mc.options.useKey.setPressed(false);
128+
event.cancel();
129+
}
130+
}
131+
132+
private static boolean isWaxedCopperBlock(Block b) {
133+
// there is no block tag or other apparent way to find waxed blocks...
134+
return b == Blocks.WAXED_WEATHERED_CHISELED_COPPER
135+
|| b == Blocks.WAXED_EXPOSED_CHISELED_COPPER
136+
|| b == Blocks.WAXED_CHISELED_COPPER
137+
|| b == Blocks.WAXED_COPPER_BLOCK
138+
|| b == Blocks.WAXED_WEATHERED_COPPER
139+
|| b == Blocks.WAXED_EXPOSED_COPPER
140+
|| b == Blocks.WAXED_OXIDIZED_COPPER
141+
|| b == Blocks.WAXED_OXIDIZED_CUT_COPPER
142+
|| b == Blocks.WAXED_WEATHERED_CUT_COPPER
143+
|| b == Blocks.WAXED_EXPOSED_CUT_COPPER
144+
|| b == Blocks.WAXED_CUT_COPPER
145+
|| b == Blocks.WAXED_OXIDIZED_CUT_COPPER_STAIRS
146+
|| b == Blocks.WAXED_WEATHERED_CUT_COPPER_STAIRS
147+
|| b == Blocks.WAXED_EXPOSED_CUT_COPPER_STAIRS
148+
|| b == Blocks.WAXED_CUT_COPPER_STAIRS
149+
|| b == Blocks.WAXED_OXIDIZED_CUT_COPPER_SLAB
150+
|| b == Blocks.WAXED_WEATHERED_CUT_COPPER_SLAB
151+
|| b == Blocks.WAXED_EXPOSED_CUT_COPPER_SLAB
152+
|| b == Blocks.WAXED_CUT_COPPER_SLAB
153+
|| b == Blocks.WAXED_COPPER_DOOR
154+
|| b == Blocks.WAXED_EXPOSED_COPPER_DOOR
155+
|| b == Blocks.WAXED_OXIDIZED_COPPER_DOOR
156+
|| b == Blocks.WAXED_WEATHERED_COPPER_DOOR
157+
|| b == Blocks.WAXED_COPPER_TRAPDOOR
158+
|| b == Blocks.WAXED_EXPOSED_COPPER_TRAPDOOR
159+
|| b == Blocks.WAXED_OXIDIZED_COPPER_TRAPDOOR
160+
|| b == Blocks.WAXED_WEATHERED_COPPER_TRAPDOOR
161+
|| b == Blocks.WAXED_COPPER_GRATE
162+
|| b == Blocks.WAXED_EXPOSED_COPPER_GRATE
163+
|| b == Blocks.WAXED_WEATHERED_COPPER_GRATE
164+
|| b == Blocks.WAXED_OXIDIZED_COPPER_GRATE
165+
|| b == Blocks.WAXED_COPPER_BULB
166+
|| b == Blocks.WAXED_EXPOSED_COPPER_BULB
167+
|| b == Blocks.WAXED_WEATHERED_COPPER_BULB
168+
|| b == Blocks.WAXED_OXIDIZED_COPPER_BULB;
169+
}
170+
89171

90172
@EventHandler(priority = EventPriority.HIGH)
91173
private void onAttackEntity(AttackEntityEvent event) {
@@ -160,8 +242,7 @@ private boolean isIgnored(ItemStack tool) {
160242
}
161243

162244
private boolean _canUse(ItemStack tool) {
163-
ToolSaver ts = Modules.get().get(ToolSaver.class);
164-
return !ts.isActive() || ts.isIgnored(tool) || !ts.isBroken(tool) || ts.canBreak(tool);
245+
return !isActive() || isIgnored(tool) || !isBroken(tool) || canBreak(tool);
165246
}
166247

167248
public static boolean canUse(ItemStack tool) {

0 commit comments

Comments
 (0)