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 efdaa37381..8bf546c011 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java @@ -12,15 +12,13 @@ import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.render.Xray; import meteordevelopment.meteorclient.systems.modules.world.InfinityMiner; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.world.BlockUtils; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; -import net.minecraft.block.BambooBlock; -import net.minecraft.block.BambooSaplingBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.block.*; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.item.*; @@ -48,6 +46,13 @@ public class AutoTool extends Module { .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.") + .defaultValue(true) + .build() + ); + private final Setting antiBreak = sgGeneral.add(new BoolSetting.Builder() .name("anti-break") .description("Stops you from breaking your tool.") @@ -153,7 +158,7 @@ private void onStartBreakingBlock(StartBreakingBlockEvent event) { 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(), prefer.get(), itemStack2 -> !shouldStopUsing(itemStack2)); + double score = getScore(itemStack, blockState, silkTouchForEnderChest.get(), fortuneForOresCrops.get(), prefer.get(), itemStack2 -> !shouldStopUsing(itemStack2)); if (score < 0) continue; if (score > bestScore) { @@ -162,7 +167,7 @@ private void onStartBreakingBlock(StartBreakingBlockEvent event) { } } - if ((bestSlot != -1 && (bestScore > getScore(currentStack, blockState, silkTouchForEnderChest.get(), prefer.get(), itemStack -> !shouldStopUsing(itemStack))) || shouldStopUsing(currentStack) || !isTool(currentStack))) { + if ((bestSlot != -1 && (bestScore > getScore(currentStack, blockState, silkTouchForEnderChest.get(), fortuneForOresCrops.get(), prefer.get(), itemStack -> !shouldStopUsing(itemStack))) || shouldStopUsing(currentStack) || !isTool(currentStack))) { ticks = switchDelay.get(); if (ticks == 0) InvUtils.swap(bestSlot, true); @@ -182,7 +187,7 @@ 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, EnchantPreference enchantPreference, Predicate good) { + 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.getItem() instanceof SwordItem && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooSaplingBlock))) return -1; @@ -192,6 +197,12 @@ public static double getScore(ItemStack itemStack, BlockState state, boolean sil return -1; } + if (fortuneOre + && isFortunable(state.getBlock()) + && EnchantmentHelper.getLevel(Enchantments.FORTUNE, itemStack) == 0) { + return -1; + } + double score = 0; score += itemStack.getMiningSpeedMultiplier(state) * 1000; @@ -216,6 +227,11 @@ public static boolean isTool(ItemStack itemStack) { return isTool(itemStack.getItem()); } + private static boolean isFortunable(Block block) { + if (block == Blocks.ANCIENT_DEBRIS) return false; + return Xray.ORES.contains(block) || block instanceof CropBlock; + } + public enum EnchantPreference { None, Fortune, diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Xray.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Xray.java index 4a83972073..2ab23b7150 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Xray.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Xray.java @@ -31,30 +31,12 @@ public class Xray extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); + public static final List ORES = List.of(Blocks.COAL_ORE, Blocks.DEEPSLATE_COAL_ORE, Blocks.IRON_ORE, Blocks.DEEPSLATE_IRON_ORE, Blocks.GOLD_ORE, Blocks.DEEPSLATE_GOLD_ORE, Blocks.LAPIS_ORE, Blocks.DEEPSLATE_LAPIS_ORE, Blocks.REDSTONE_ORE, Blocks.REDSTONE_ORE, Blocks.DIAMOND_ORE, Blocks.DEEPSLATE_DIAMOND_ORE, Blocks.EMERALD_ORE, Blocks.DEEPSLATE_EMERALD_ORE, Blocks.COPPER_ORE, Blocks.DEEPSLATE_COPPER_ORE, Blocks.NETHER_GOLD_ORE, Blocks.NETHER_QUARTZ_ORE, Blocks.ANCIENT_DEBRIS); + private final Setting> blocks = sgGeneral.add(new BlockListSetting.Builder() .name("whitelist") .description("Which blocks to show x-rayed.") - .defaultValue( - Blocks.COAL_ORE, - Blocks.DEEPSLATE_COAL_ORE, - Blocks.IRON_ORE, - Blocks.DEEPSLATE_IRON_ORE, - Blocks.GOLD_ORE, - Blocks.DEEPSLATE_GOLD_ORE, - Blocks.LAPIS_ORE, - Blocks.DEEPSLATE_LAPIS_ORE, - Blocks.REDSTONE_ORE, - Blocks.DEEPSLATE_REDSTONE_ORE, - Blocks.DIAMOND_ORE, - Blocks.DEEPSLATE_DIAMOND_ORE, - Blocks.EMERALD_ORE, - Blocks.DEEPSLATE_EMERALD_ORE, - Blocks.COPPER_ORE, - Blocks.DEEPSLATE_COPPER_ORE, - Blocks.NETHER_GOLD_ORE, - Blocks.NETHER_QUARTZ_ORE, - Blocks.ANCIENT_DEBRIS - ) + .defaultValue(ORES) .onChanged(v -> { if (isActive()) mc.worldRenderer.reload(); }) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java index 1c8739104c..8908aac703 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java @@ -864,7 +864,7 @@ protected int findAndMoveBestToolToHotbar(HighwayBuilder b, BlockState blockStat int bestSlot = -1; for (int i = 0; i < b.mc.player.getInventory().main.size(); i++) { - double score = AutoTool.getScore(b.mc.player.getInventory().getStack(i), blockState, false, AutoTool.EnchantPreference.None, itemStack -> { + double score = AutoTool.getScore(b.mc.player.getInventory().getStack(i), blockState, false, false, AutoTool.EnchantPreference.None, itemStack -> { if (noSilkTouch && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, itemStack) != 0) return false; return !b.dontBreakTools.get() || itemStack.getMaxDamage() - itemStack.getDamage() > 1; });