Skip to content

Allow hoes and Fortune tools for nether warts (#5243) #5247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public class ActiveModulesHud extends HudElement {
.build()
);

private final Setting<Boolean> showKeybind = sgGeneral.add(new BoolSetting.Builder()
.name("show-keybind")
.description("Shows the module's keybind next to its name.")
.defaultValue(false)
.build()
);

private final Setting<Boolean> shadow = sgGeneral.add(new BoolSetting.Builder()
.name("shadow")
.description("Renders shadow behind text.")
Expand Down Expand Up @@ -273,17 +280,23 @@ private void renderModule(HudRenderer renderer, int index, double x, double y) {
double textHeight = renderer.textHeight(shadow.get(), getScale());
double textLength = renderer.textWidth(module.title, shadow.get(), getScale());

double lineStartY = y;
double lineHeight = textHeight;
if (showKeybind.get() && module.keybind != null && module.keybind.isSet()) {
String keybindStr = " [" + module.keybind.toString() + "]";
renderer.text(keybindStr, x + textLength, y, moduleInfoColor.get(), shadow.get(), getScale());
textLength += renderer.textWidth(keybindStr, shadow.get(), getScale());
}

if (activeInfo.get()) {
String info = module.getInfoString();
if (info != null) {
renderer.text(info, x + emptySpace + textLength, y, moduleInfoColor.get(), shadow.get(), getScale());
renderer.text(info, x + textLength + emptySpace, y, moduleInfoColor.get(), shadow.get(), getScale());
textLength += emptySpace + renderer.textWidth(info, shadow.get(), getScale());
}
}

double lineStartY = y;
double lineHeight = textHeight;

if (outlines.get()) {
if (index == 0) { // Render top quad for first item in list
lineStartY -= 2;
Expand Down Expand Up @@ -330,6 +343,10 @@ private void renderModule(HudRenderer renderer, int index, double x, double y) {
private double getModuleWidth(HudRenderer renderer, Module module) {
double width = renderer.textWidth(module.title, shadow.get(), getScale());

if (showKeybind.get() && module.keybind != null && module.keybind.isSet()) {
width += renderer.textWidth(" [" + module.keybind.toString() + "]", shadow.get(), getScale());
}

if (activeInfo.get()) {
String info = module.getInfoString();
if (info != null) width += renderer.textWidth(" ", shadow.get(), getScale()) + renderer.textWidth(info, shadow.get(), getScale());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ private boolean shouldStopUsing(ItemStack itemStack) {

public static double getScore(ItemStack itemStack, BlockState state, boolean silkTouchEnderChest, boolean fortuneOre, EnchantPreference enchantPreference, Predicate<ItemStack> good) {
if (!good.test(itemStack) || !isTool(itemStack)) return -1;
if (!itemStack.isSuitableFor(state) && !(itemStack.getItem() instanceof SwordItem && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooShootBlock)) && !(itemStack.getItem() instanceof ShearsItem && state.getBlock() instanceof LeavesBlock || state.isIn(BlockTags.WOOL))) return -1;
if (!itemStack.isSuitableFor(state) &&
!(itemStack.getItem() instanceof SwordItem && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooShootBlock)) &&
!(itemStack.getItem() instanceof ShearsItem && state.getBlock() instanceof LeavesBlock || state.isIn(BlockTags.WOOL)) &&
!(itemStack.getItem() instanceof HoeItem && state.getBlock() == Blocks.NETHER_WART)) return -1;

if (silkTouchEnderChest
&& state.getBlock() == Blocks.ENDER_CHEST
Expand All @@ -218,11 +221,14 @@ && isFortunable(state.getBlock())
if (itemStack.getItem() instanceof SwordItem item && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooShootBlock))
score += 9000 + (item.getComponents().get(DataComponentTypes.TOOL).getSpeed(state) * 1000);

if (itemStack.getItem() instanceof HoeItem && state.getBlock() == Blocks.NETHER_WART)
score += 9000;

return score;
}

public static boolean isTool(Item item) {
return item instanceof MiningToolItem || item instanceof ShearsItem;
return item instanceof MiningToolItem || item instanceof ShearsItem || item instanceof HoeItem;
}
public static boolean isTool(ItemStack itemStack) {
return isTool(itemStack.getItem());
Expand All @@ -231,7 +237,7 @@ public static boolean isTool(ItemStack itemStack) {

private static boolean isFortunable(Block block) {
if (block == Blocks.ANCIENT_DEBRIS) return false;
return Xray.ORES.contains(block) || block instanceof CropBlock;
return Xray.ORES.contains(block) || block instanceof CropBlock || block == Blocks.NETHER_WART;
}

public enum EnchantPreference {
Expand Down