diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index 2c10a11f38..bbfecd65db 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -30,8 +30,8 @@ import meteordevelopment.meteorclient.systems.modules.render.*; import meteordevelopment.meteorclient.systems.modules.render.blockesp.BlockESP; import meteordevelopment.meteorclient.systems.modules.render.marker.Marker; -import meteordevelopment.meteorclient.systems.modules.world.Timer; import meteordevelopment.meteorclient.systems.modules.world.*; +import meteordevelopment.meteorclient.systems.modules.world.Timer; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.misc.Keybind; import meteordevelopment.meteorclient.utils.misc.ValueComparableMap; @@ -449,6 +449,7 @@ private void initPlayer() { add(new Reach()); add(new Rotation()); add(new SpeedMine()); + add(new ToolSaver()); } private void initMovement() { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoWeapon.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoWeapon.java index 3285e112f1..8a7e55604f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoWeapon.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoWeapon.java @@ -9,6 +9,7 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.player.ToolSaver; import meteordevelopment.meteorclient.utils.entity.DamageUtils; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.orbit.EventHandler; @@ -34,13 +35,6 @@ public class AutoWeapon extends Module { .build() ); - private final Setting antiBreak = sgGeneral.add(new BoolSetting.Builder() - .name("anti-break") - .description("Prevents you from breaking your weapon.") - .defaultValue(false) - .build() - ); - public AutoWeapon() { super(Categories.Combat, "auto-weapon", "Finds the best weapon to use in your hotbar."); } @@ -62,14 +56,14 @@ private int getBestWeapon(LivingEntity target) { for (int i = 0; i < 9; i++) { ItemStack stack = mc.player.getInventory().getStack(i); if (stack.isIn(ItemTags.SWORDS) - && (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) { + && ToolSaver.canUse(stack)) { currentDamageS = DamageUtils.getAttackDamage(mc.player, target, stack); if (currentDamageS > damageS) { damageS = currentDamageS; slotS = i; } } else if (stack.getItem() instanceof AxeItem - && (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) { + && ToolSaver.canUse(stack)) { currentDamageA = DamageUtils.getAttackDamage(mc.player, target, stack); if (currentDamageA > damageA) { damageA = currentDamageA; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java index fdc6774c86..73245eded0 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java @@ -16,6 +16,7 @@ import meteordevelopment.meteorclient.systems.modules.world.InfinityMiner; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.InvUtils; +import meteordevelopment.meteorclient.utils.player.SlotUtils; import meteordevelopment.meteorclient.utils.world.BlockUtils; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; @@ -51,6 +52,13 @@ public class AutoTool extends Module { .build() ); + private final Setting silkTouchForGlass = sgGeneral.add(new BoolSetting.Builder() + .name("silk-touch-for-glass") + .description("Prefer to mine glass with silk touch") + .defaultValue(true) + .build() + ); + private final Setting fortuneForOresCrops = sgGeneral.add(new BoolSetting.Builder() .name("fortune-for-ores-and-crops") .description("Mines Ores and crops only with the Fortune enchantment.") @@ -58,30 +66,45 @@ public class AutoTool extends Module { .build() ); - private final Setting antiBreak = sgGeneral.add(new BoolSetting.Builder() - .name("anti-break") - .description("Stops you from breaking your tool.") + private final Setting switchBack = sgGeneral.add(new BoolSetting.Builder() + .name("switch-back") + .description("Switches your hand to whatever was selected when releasing your attack key.") .defaultValue(false) .build() ); - private final Setting breakDurability = sgGeneral.add(new IntSetting.Builder() - .name("anti-break-percentage") - .description("The durability percentage to stop using a tool.") - .defaultValue(10) - .range(1, 100) - .sliderRange(1, 100) - .visible(antiBreak::get) + private final Setting switchAway = sgGeneral.add(new BoolSetting.Builder() + .name("switch-away") + .description("Switch to hand when no correct tool is found") + .defaultValue(true) .build() ); - private final Setting switchBack = sgGeneral.add(new BoolSetting.Builder() - .name("switch-back") - .description("Switches your hand to whatever was selected when releasing your attack key.") + private final Setting invSwap = sgGeneral.add(new BoolSetting.Builder() + .name("swap-from-inventory") + .description("Search tools in the entire inventory") .defaultValue(false) .build() ); + private final Setting invSwapSlot = sgGeneral.add(new IntSetting.Builder() + .name("swap-slot") + .description("Slot to swap tools from inventory into") + .defaultValue(8) + .range(0, 8) + .noSlider() + .visible(invSwap::get) + .build() + ); + + private final Setting invSwapReturn = sgGeneral.add(new BoolSetting.Builder() + .name("return-swapped-tool-back") + .description("Swap the tool back into the inventory") + .defaultValue(false) + .visible(invSwap::get) + .build() + ); + private final Setting switchDelay = sgGeneral.add((new IntSetting.Builder() .name("switch-delay") .description("Delay in ticks before switching tools.") @@ -118,6 +141,7 @@ public class AutoTool extends Module { private boolean shouldSwitch; private int ticks; private int bestSlot; + private int toolWasIn; public AutoTool() { super(Categories.Player, "auto-tool", "Automatically switches to the most effective tool when performing an action."); @@ -127,6 +151,12 @@ public AutoTool() { private void onTick(TickEvent.Post event) { if (Modules.get().isActive(InfinityMiner.class)) return; + if (invSwapReturn.get() && !mc.options.attackKey.isPressed() && wasPressed && toolWasIn != -1) { + InvUtils.quickSwap().fromId(invSwapSlot.get()).to(toolWasIn); + toolWasIn = -1; + return; + } + if (switchBack.get() && !mc.options.attackKey.isPressed() && wasPressed && InvUtils.previousSlot != -1) { InvUtils.swapBack(); wasPressed = false; @@ -158,13 +188,17 @@ private void onStartBreakingBlock(StartBreakingBlockEvent event) { double bestScore = -1; bestSlot = -1; - for (int i = 0; i < 9; i++) { + int max = invSwap.get() ? SlotUtils.MAIN_END : 9; + + for (int i = 0; i < max; i++) { ItemStack itemStack = mc.player.getInventory().getStack(i); if (listMode.get() == ListMode.Whitelist && !whitelist.get().contains(itemStack.getItem())) continue; if (listMode.get() == ListMode.Blacklist && blacklist.get().contains(itemStack.getItem())) continue; - double score = getScore(itemStack, blockState, silkTouchForEnderChest.get(), fortuneForOresCrops.get(), prefer.get(), itemStack2 -> !shouldStopUsing(itemStack2)); + EnchantPreference pref = isGlass(blockState.getBlock()) && silkTouchForGlass.get() ? EnchantPreference.SilkTouch : prefer.get(); + + double score = getScore(itemStack, blockState, silkTouchForEnderChest.get(), fortuneForOresCrops.get(), pref, ToolSaver::canUse); if (score < 0) continue; if (score > bestScore) { @@ -173,31 +207,46 @@ private void onStartBreakingBlock(StartBreakingBlockEvent event) { } } - if ((bestSlot != -1 && (bestScore > getScore(currentStack, blockState, silkTouchForEnderChest.get(), fortuneForOresCrops.get(), prefer.get(), itemStack -> !shouldStopUsing(itemStack))) || shouldStopUsing(currentStack) || !isTool(currentStack))) { + if (bestSlot == -1 && ToolSaver.isTool(mc.player.getMainHandStack()) && switchAway.get()) { + for (int i = 0; i < 9; i++) { + if (!ToolSaver.isTool(mc.player.getInventory().getStack(i))) { + bestSlot = i; + bestScore = 0; + break; + } + } + } + + int returnToolTo = toolWasIn; + + if (bestSlot > 8) { + toolWasIn = bestSlot; + bestSlot = invSwapSlot.get(); + } + + if ((bestSlot != -1 && (bestScore > getScore(currentStack, blockState, silkTouchForEnderChest.get(), fortuneForOresCrops.get(), prefer.get(), itemStack -> ToolSaver.canUse(itemStack) || ToolSaver.canUse(currentStack) || !isTool(currentStack))))) { ticks = switchDelay.get(); + if (invSwapReturn.get() && returnToolTo > 8) InvUtils.quickSwap().fromId(invSwapSlot.get()).to(returnToolTo); + if (ticks == 0) InvUtils.swap(bestSlot, true); else shouldSwitch = true; - } - // Anti break - currentStack = mc.player.getMainHandStack(); - - if (shouldStopUsing(currentStack) && isTool(currentStack)) { - mc.options.attackKey.setPressed(false); - event.cancel(); + if (toolWasIn > 8) { + if (bestSlot == invSwapSlot.get()) InvUtils.quickSwap().fromId(invSwapSlot.get()).to(toolWasIn); + else toolWasIn = -1; + } } - } - private boolean shouldStopUsing(ItemStack itemStack) { - return antiBreak.get() && (itemStack.getMaxDamage() - itemStack.getDamage()) < (itemStack.getMaxDamage() * breakDurability.get() / 100); } public static double getScore(ItemStack itemStack, BlockState state, boolean silkTouchEnderChest, boolean fortuneOre, EnchantPreference enchantPreference, Predicate good) { if (!good.test(itemStack) || !isTool(itemStack)) return -1; + if (!itemStack.isSuitableFor(state) && !(itemStack.isIn(ItemTags.SWORDS) && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooShootBlock)) && - !(itemStack.getItem() instanceof ShearsItem && state.getBlock() instanceof LeavesBlock || state.isIn(BlockTags.WOOL))) + !(itemStack.getItem() instanceof ShearsItem && state.getBlock() instanceof LeavesBlock || state.isIn(BlockTags.WOOL)) && + !(isGlass(state.getBlock()) && enchantPreference == EnchantPreference.SilkTouch && Utils.getEnchantmentLevel(itemStack, Enchantments.SILK_TOUCH) > 0)) return -1; if (silkTouchEnderChest @@ -228,6 +277,10 @@ && isFortunable(state.getBlock()) return score; } + private static boolean isGlass(Block b) { + return b == Blocks.GLASS || b == Blocks.GLASS_PANE || b instanceof StainedGlassBlock || b instanceof StainedGlassPaneBlock || b instanceof TintedGlassBlock; + } + public static boolean isTool(Item item) { return isTool(item.getDefaultStack()); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ToolSaver.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ToolSaver.java new file mode 100644 index 0000000000..02aabf329f --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ToolSaver.java @@ -0,0 +1,268 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.systems.modules.player; + +import meteordevelopment.meteorclient.events.entity.player.*; +import meteordevelopment.meteorclient.settings.*; +import meteordevelopment.meteorclient.systems.modules.Categories; +import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.utils.Utils; +import meteordevelopment.orbit.EventHandler; +import meteordevelopment.orbit.EventPriority; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.PumpkinBlock; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.passive.SheepEntity; +import net.minecraft.entity.passive.SnowGolemEntity; +import net.minecraft.item.*; +import net.minecraft.registry.tag.BlockTags; +import net.minecraft.registry.tag.ItemTags; + +import java.util.List; +import java.util.Objects; + +public class ToolSaver extends Module { + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + + private final Setting durability = sgGeneral.add(new IntSetting.Builder() + .name("percentage") + .description("The durability percentage to stop using a tool at") + .defaultValue(10) + .range(1, 100) + .sliderRange(1, 100) + .build() + ); + + private final Setting onlyMending = sgGeneral.add(new BoolSetting.Builder() + .name("only-mending") + .description("Only avoid breaking tools which have mending") + .build() + ); + + private final Setting onlyUnique = sgGeneral.add(new BoolSetting.Builder() + .name("only-last-tool") + .description("Only avoid breaking the last tool of a type unless the other tools are all worse") + .build() + ); + + private final Setting allowAttack = sgGeneral.add(new BoolSetting.Builder() + .name("allow-manual-attack") + .description("Never prevent manual attacks") + .build() + ); + + private final Setting listMode = sgGeneral.add(new EnumSetting.Builder() + .name("list-mode") + .description("Selection mode") + .defaultValue(ListMode.Blacklist) + .build() + ); + + private final Setting> whitelist = sgGeneral.add(new ItemListSetting.Builder() + .name("whitelist") + .description("Do not allow breaking these tools") + .visible(() -> listMode.get() == ListMode.Whitelist) + .filter(ToolSaver::isTool) + .build() + ); + + private final Setting> blacklist = sgGeneral.add(new ItemListSetting.Builder() + .name("blacklist") + .description("Allow breaking these tools") + .visible(() -> listMode.get() == ListMode.Blacklist) + .filter(ToolSaver::isTool) + .build() + ); + + public ToolSaver() { + super(Categories.Player, "tool-saver", "Prevents breaking tools"); + } + + @EventHandler(priority = EventPriority.HIGH - 1) + private void onStartBreakingBlock(StartBreakingBlockEvent event) { + if (!_canUse(mc.player.getMainHandStack()) && mc.world.getBlockState(event.blockPos).getHardness(mc.world, event.blockPos) > 0) { + mc.options.attackKey.setPressed(false); + event.cancel(); + } + } + + @EventHandler(priority = EventPriority.HIGH) + private void onInteractBlock(InteractBlockEvent event) { + ItemStack s = mc.player.getStackInHand(event.hand); + BlockState bs = mc.world.getBlockState(event.result.getBlockPos()); + + switch (toolType(s)) { + case AXE: + if (!bs.isIn(BlockTags.LOGS) && !isWaxedCopperBlock(bs.getBlock())) return; + break; + case SHEAR: + if (!(bs.getBlock() instanceof PumpkinBlock)) return; + break; + case FLINT_AND_STEEL: + break; + default: + return; + } + + if (!_canUse(s)) { + mc.options.useKey.setPressed(false); + event.cancel(); + } + } + + @EventHandler(priority = EventPriority.HIGH) + private void onInteractEntity(InteractEntityEvent event) { + ItemStack s = mc.player.getStackInHand(event.hand); + + if (toolType(s) != ToolType.SHEAR) return; + if (!(event.entity instanceof SheepEntity || event.entity instanceof SnowGolemEntity)) return; + + if (!_canUse(s)) { + mc.options.useKey.setPressed(false); + event.cancel(); + } + } + + private static boolean isWaxedCopperBlock(Block b) { + // there is no block tag or other apparent way to find waxed blocks... + return b == Blocks.WAXED_WEATHERED_CHISELED_COPPER + || b == Blocks.WAXED_EXPOSED_CHISELED_COPPER + || b == Blocks.WAXED_CHISELED_COPPER + || b == Blocks.WAXED_COPPER_BLOCK + || b == Blocks.WAXED_WEATHERED_COPPER + || b == Blocks.WAXED_EXPOSED_COPPER + || b == Blocks.WAXED_OXIDIZED_COPPER + || b == Blocks.WAXED_OXIDIZED_CUT_COPPER + || b == Blocks.WAXED_WEATHERED_CUT_COPPER + || b == Blocks.WAXED_EXPOSED_CUT_COPPER + || b == Blocks.WAXED_CUT_COPPER + || b == Blocks.WAXED_OXIDIZED_CUT_COPPER_STAIRS + || b == Blocks.WAXED_WEATHERED_CUT_COPPER_STAIRS + || b == Blocks.WAXED_EXPOSED_CUT_COPPER_STAIRS + || b == Blocks.WAXED_CUT_COPPER_STAIRS + || b == Blocks.WAXED_OXIDIZED_CUT_COPPER_SLAB + || b == Blocks.WAXED_WEATHERED_CUT_COPPER_SLAB + || b == Blocks.WAXED_EXPOSED_CUT_COPPER_SLAB + || b == Blocks.WAXED_CUT_COPPER_SLAB + || b == Blocks.WAXED_COPPER_DOOR + || b == Blocks.WAXED_EXPOSED_COPPER_DOOR + || b == Blocks.WAXED_OXIDIZED_COPPER_DOOR + || b == Blocks.WAXED_WEATHERED_COPPER_DOOR + || b == Blocks.WAXED_COPPER_TRAPDOOR + || b == Blocks.WAXED_EXPOSED_COPPER_TRAPDOOR + || b == Blocks.WAXED_OXIDIZED_COPPER_TRAPDOOR + || b == Blocks.WAXED_WEATHERED_COPPER_TRAPDOOR + || b == Blocks.WAXED_COPPER_GRATE + || b == Blocks.WAXED_EXPOSED_COPPER_GRATE + || b == Blocks.WAXED_WEATHERED_COPPER_GRATE + || b == Blocks.WAXED_OXIDIZED_COPPER_GRATE + || b == Blocks.WAXED_COPPER_BULB + || b == Blocks.WAXED_EXPOSED_COPPER_BULB + || b == Blocks.WAXED_WEATHERED_COPPER_BULB + || b == Blocks.WAXED_OXIDIZED_COPPER_BULB; + } + + + @EventHandler(priority = EventPriority.HIGH) + private void onAttackEntity(AttackEntityEvent event) { + if (!allowAttack.get() && !_canUse(mc.player.getMainHandStack())) event.cancel(); + } + + private static ToolType toolType(ItemStack is) { + if (is.isIn(ItemTags.AXES)) return ToolType.AXE; + if (is.isIn(ItemTags.HOES)) return ToolType.HOE; + if (is.isIn(ItemTags.PICKAXES)) return ToolType.PICKAXE; + if (is.isIn(ItemTags.SHOVELS)) return ToolType.SHOVEL; + if (is.isIn(ItemTags.SWORDS)) return ToolType.SWORD; + if (is.getItem() instanceof ShearsItem) return ToolType.SHEAR; + if (is.getItem() instanceof MaceItem) return ToolType.MACE; + if (is.getItem() instanceof FlintAndSteelItem) return ToolType.FLINT_AND_STEEL; + return ToolType.NONE; + } + + public static boolean isTool(Item item) { + return isTool(item.getDefaultStack()); + } + + public static boolean isTool(ItemStack is) { + return toolType(is) != ToolType.NONE; + } + + private boolean isWorse(ItemStack a, ItemStack b) { + // lower material tier (no-one cares about gold) + if (a.getMaxDamage() < b.getMaxDamage()) return true; + + // non-mending tools can always be broken if only-mending is set + if (onlyMending.get() && Utils.getEnchantmentLevel(a, Enchantments.MENDING) < Utils.getEnchantmentLevel(b, Enchantments.MENDING)) + return true; + + // don't break the more enchanted tool + if (Utils.getEnchantmentLevel(a, Enchantments.FORTUNE) > 0 && Utils.getEnchantmentLevel(a, Enchantments.FORTUNE) < Utils.getEnchantmentLevel(b, Enchantments.FORTUNE)) + return true; + return Utils.getEnchantmentLevel(a, Enchantments.EFFICIENCY) < Utils.getEnchantmentLevel(b, Enchantments.EFFICIENCY); + } + + private boolean canBreak(ItemStack is) { + if (!isTool(is)) return true; + if (onlyMending.get() && Utils.getEnchantmentLevel(is, Enchantments.MENDING) == 0) return true; + if (!onlyUnique.get()) return false; + + ToolType tt = toolType(is); + + boolean silkTouch = Utils.getEnchantmentLevel(is, Enchantments.SILK_TOUCH) > 0; + + int counter = 0; + + for (int i = 0; i < 40; i++) { + ItemStack isi = mc.player.getInventory().getStack(i); + + if (tt != toolType(isi)) continue; + if (silkTouch != Utils.getEnchantmentLevel(isi, Enchantments.SILK_TOUCH) > 0) continue; + + if (!isWorse(isi, is)) counter++; + if (counter > 1) return true; + } + + return false; + } + + private boolean isBroken(ItemStack tool) { + return tool.getMaxDamage() - tool.getDamage() < tool.getMaxDamage() * durability.get() / 100; + } + + private boolean isIgnored(ItemStack tool) { + if (listMode.get() == ListMode.Whitelist) return !whitelist.get().contains(tool.getItem()); + return blacklist.get().contains(tool.getItem()); + } + + private boolean _canUse(ItemStack tool) { + return !isActive() || isIgnored(tool) || !isBroken(tool) || canBreak(tool); + } + + public static boolean canUse(ItemStack tool) { + return Modules.get().get(ToolSaver.class)._canUse(tool); + } + + public enum ListMode { + Whitelist, + Blacklist + } + + public enum ToolType { + NONE, + AXE, + HOE, + PICKAXE, + SHOVEL, + SWORD, + MACE, + SHEAR, + FLINT_AND_STEEL, + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoShearer.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoShearer.java index d8d008a8a0..f8f7287c49 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoShearer.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoShearer.java @@ -12,6 +12,7 @@ import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.player.ToolSaver; import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; @@ -33,13 +34,6 @@ public class AutoShearer extends Module { .build() ); - private final Setting antiBreak = sgGeneral.add(new BoolSetting.Builder() - .name("anti-break") - .description("Prevents shears from being broken.") - .defaultValue(false) - .build() - ); - private final Setting rotate = sgGeneral.add(new BoolSetting.Builder() .name("rotate") .description("Automatically faces towards the animal being sheared.") @@ -66,7 +60,7 @@ private void onTick(TickEvent.Pre event) { for (Entity entity : mc.world.getEntities()) { if (!(entity instanceof SheepEntity) || ((SheepEntity) entity).isSheared() || ((SheepEntity) entity).isBaby() || !PlayerUtils.isWithin(entity, distance.get())) continue; - FindItemResult findShear = InvUtils.findInHotbar(itemStack -> itemStack.getItem() == Items.SHEARS && (!antiBreak.get() || itemStack.getDamage() < itemStack.getMaxDamage() - 1)); + FindItemResult findShear = InvUtils.findInHotbar(itemStack -> itemStack.getItem() == Items.SHEARS && ToolSaver.canUse(itemStack)); if (!InvUtils.swap(findShear.slot(), true)) return; this.hand = findShear.getHand(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java index e8603f326b..af04ffca3f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java @@ -9,6 +9,7 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.player.ToolSaver; import meteordevelopment.meteorclient.utils.misc.HorizontalDirection; import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; @@ -39,13 +40,6 @@ public class Flamethrower extends Module { .build() ); - private final Setting antiBreak = sgGeneral.add(new BoolSetting.Builder() - .name("anti-break") - .description("Prevents flint and steel from being broken.") - .defaultValue(false) - .build() - ); - private final Setting putOutFire = sgGeneral.add(new BoolSetting.Builder() .name("put-out-fire") .description("Tries to put out the fire when animal is low health, so the items don't burn.") @@ -111,7 +105,7 @@ private void onTick(TickEvent.Pre event) { if (!targetBabies.get() && entity instanceof LivingEntity livingEntity && livingEntity.isBaby()) continue; FindItemResult item = InvUtils.findInHotbar(itemStack -> (itemStack.isOf(Items.FLINT_AND_STEEL) || itemStack.isOf(Items.FIRE_CHARGE)) && - (!itemStack.isDamageable() || !antiBreak.get() || itemStack.getDamage() < itemStack.getMaxDamage() - 1)); + ToolSaver.canUse(itemStack)); if (!InvUtils.swap(item.slot(), true)) return; this.hand = item.getHand();