Skip to content

Commit c50139f

Browse files
committed
[feat] auto-tool silk-touch-for-glass
1 parent 378b66d commit c50139f

File tree

1 file changed

+9
-2
lines changed
  • src/main/java/meteordevelopment/meteorclient/systems/modules/player

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ private void onStartBreakingBlock(StartBreakingBlockEvent event) {
162162
if (listMode.get() == ListMode.Whitelist && !whitelist.get().contains(itemStack.getItem())) continue;
163163
if (listMode.get() == ListMode.Blacklist && blacklist.get().contains(itemStack.getItem())) continue;
164164

165-
double score = getScore(itemStack, blockState, silkTouchForEnderChest.get(), fortuneForOresCrops.get(), prefer.get(), ToolSaver::canUse);
165+
EnchantPreference pref = isGlass(blockState.getBlock()) && silkTouchForGlass.get() ? EnchantPreference.SilkTouch : prefer.get();
166+
167+
double score = getScore(itemStack, blockState, silkTouchForEnderChest.get(), fortuneForOresCrops.get(), pref, ToolSaver::canUse);
166168
if (score < 0) continue;
167169

168170
if (score > bestScore) {
@@ -195,7 +197,8 @@ public static double getScore(ItemStack itemStack, BlockState state, boolean sil
195197

196198
if (!itemStack.isSuitableFor(state) &&
197199
!(itemStack.isIn(ItemTags.SWORDS) && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooShootBlock)) &&
198-
!(itemStack.getItem() instanceof ShearsItem && state.getBlock() instanceof LeavesBlock || state.isIn(BlockTags.WOOL)))
200+
!(itemStack.getItem() instanceof ShearsItem && state.getBlock() instanceof LeavesBlock || state.isIn(BlockTags.WOOL)) &&
201+
!(isGlass(state.getBlock()) && enchantPreference == EnchantPreference.SilkTouch && Utils.getEnchantmentLevel(itemStack, Enchantments.SILK_TOUCH) > 0))
199202
return -1;
200203

201204
if (silkTouchEnderChest
@@ -226,6 +229,10 @@ && isFortunable(state.getBlock())
226229
return score;
227230
}
228231

232+
private static boolean isGlass(Block b) {
233+
return b == Blocks.GLASS || b == Blocks.GLASS_PANE || b instanceof StainedGlassBlock || b instanceof StainedGlassPaneBlock || b instanceof TintedGlassBlock;
234+
}
235+
229236
public static boolean isTool(Item item) {
230237
return isTool(item.getDefaultStack());
231238
}

0 commit comments

Comments
 (0)