From 905cec3fddd86027914cf1d87590fd6c4baba344 Mon Sep 17 00:00:00 2001 From: MrCrayfish Date: Tue, 9 Feb 2021 19:36:49 +1030 Subject: [PATCH] Added config option to toggle quick crafting --- src/main/java/com/mrcrayfish/controllable/Config.java | 2 ++ .../mrcrayfish/controllable/client/ControllerInput.java | 6 +++++- .../mrcrayfish/controllable/client/gui/SettingsScreen.java | 2 +- .../controllable/client/settings/ControllerOptions.java | 7 +++++++ .../controllable/mixin/client/RecipeBookPageMixin.java | 3 ++- src/main/resources/assets/controllable/lang/en_us.json | 1 + 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/mrcrayfish/controllable/Config.java b/src/main/java/com/mrcrayfish/controllable/Config.java index 63437096..a18e069f 100644 --- a/src/main/java/com/mrcrayfish/controllable/Config.java +++ b/src/main/java/com/mrcrayfish/controllable/Config.java @@ -44,6 +44,7 @@ public static class Options public final ForgeConfigSpec.DoubleValue rotationSpeed; public final ForgeConfigSpec.DoubleValue mouseSpeed; public final ForgeConfigSpec.EnumValue showActions; + public final ForgeConfigSpec.BooleanValue quickCraft; public Options(ForgeConfigSpec.Builder builder) { @@ -61,6 +62,7 @@ public Options(ForgeConfigSpec.Builder builder) this.rotationSpeed = builder.comment("The speed which the camera turns in game").defineInRange("rotationSpeed", 25.0, 0.0, 50.0); this.mouseSpeed = builder.comment("The speed which the cursor or virtual mouse moves around the screen").defineInRange("mouseSpeed", 15.0, 0.0, 50.0); this.showActions = builder.comment("If true, shows common actions when displaying available on the screen").defineEnum("showActions", ActionVisibility.MINIMAL); + this.quickCraft = builder.comment("If true, allows you to craft quickly when clicking an item in the recipe book").define("quickCraft", true); } builder.pop(); } diff --git a/src/main/java/com/mrcrayfish/controllable/client/ControllerInput.java b/src/main/java/com/mrcrayfish/controllable/client/ControllerInput.java index be3f3e62..b26c57e1 100644 --- a/src/main/java/com/mrcrayfish/controllable/client/ControllerInput.java +++ b/src/main/java/com/mrcrayfish/controllable/client/ControllerInput.java @@ -761,7 +761,11 @@ else if(ButtonBindings.NAVIGATE_RIGHT.isButtonPressed()) else if(button == ButtonBindings.PICKUP_ITEM.getButton()) { invokeMouseClick(mc.currentScreen, 0); - this.craftRecipeBookItem(); + + if(Config.CLIENT.options.quickCraft.get()) + { + this.craftRecipeBookItem(); + } } else if(button == ButtonBindings.SPLIT_STACK.getButton()) { diff --git a/src/main/java/com/mrcrayfish/controllable/client/gui/SettingsScreen.java b/src/main/java/com/mrcrayfish/controllable/client/gui/SettingsScreen.java index 0a82c7c2..46679ccb 100644 --- a/src/main/java/com/mrcrayfish/controllable/client/gui/SettingsScreen.java +++ b/src/main/java/com/mrcrayfish/controllable/client/gui/SettingsScreen.java @@ -14,7 +14,7 @@ */ public class SettingsScreen extends Screen { - private static final AbstractOption[] OPTIONS = new AbstractOption[]{ControllerOptions.AUTO_SELECT, ControllerOptions.RENDER_MINI_PLAYER, ControllerOptions.VIRTUAL_MOUSE, ControllerOptions.CONSOLE_HOTBAR, ControllerOptions.CONTROLLER_ICONS, ControllerOptions.CURSOR_TYPE, ControllerOptions.INVERT_LOOK, ControllerOptions.DEAD_ZONE, ControllerOptions.ROTATION_SPEED, ControllerOptions.MOUSE_SPEED, ControllerOptions.SHOW_ACTIONS}; + private static final AbstractOption[] OPTIONS = new AbstractOption[]{ControllerOptions.AUTO_SELECT, ControllerOptions.RENDER_MINI_PLAYER, ControllerOptions.VIRTUAL_MOUSE, ControllerOptions.CONSOLE_HOTBAR, ControllerOptions.CONTROLLER_ICONS, ControllerOptions.CURSOR_TYPE, ControllerOptions.INVERT_LOOK, ControllerOptions.DEAD_ZONE, ControllerOptions.ROTATION_SPEED, ControllerOptions.MOUSE_SPEED, ControllerOptions.SHOW_ACTIONS, ControllerOptions.QUICK_CRAFT}; private final Screen parentScreen; protected SettingsScreen(Screen parentScreen) diff --git a/src/main/java/com/mrcrayfish/controllable/client/settings/ControllerOptions.java b/src/main/java/com/mrcrayfish/controllable/client/settings/ControllerOptions.java index 6c346a98..64fb6991 100644 --- a/src/main/java/com/mrcrayfish/controllable/client/settings/ControllerOptions.java +++ b/src/main/java/com/mrcrayfish/controllable/client/settings/ControllerOptions.java @@ -119,4 +119,11 @@ public class ControllerOptions ActionVisibility visibility = option.get(gameSettings); return new TranslationTextComponent("controllable.options.showActions.format", new TranslationTextComponent("controllable.actionVisibility." + visibility.getString())); }); + + public static final BooleanOption QUICK_CRAFT = new ControllableBooleanOption("controllable.options.quickCraft", gameSettings -> { + return Config.CLIENT.options.quickCraft.get(); + }, (gameSettings, value) -> { + Config.CLIENT.options.quickCraft.set(value); + Config.save(); + }); } diff --git a/src/main/java/com/mrcrayfish/controllable/mixin/client/RecipeBookPageMixin.java b/src/main/java/com/mrcrayfish/controllable/mixin/client/RecipeBookPageMixin.java index e3d07176..db4472df 100644 --- a/src/main/java/com/mrcrayfish/controllable/mixin/client/RecipeBookPageMixin.java +++ b/src/main/java/com/mrcrayfish/controllable/mixin/client/RecipeBookPageMixin.java @@ -1,5 +1,6 @@ package com.mrcrayfish.controllable.mixin.client; +import com.mrcrayfish.controllable.Config; import com.mrcrayfish.controllable.Controllable; import net.minecraft.client.gui.recipebook.RecipeBookPage; import net.minecraft.util.text.ITextComponent; @@ -21,7 +22,7 @@ public class RecipeBookPageMixin @ModifyArgs(method = "func_238926_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;func_243308_b(Lcom/mojang/blaze3d/matrix/MatrixStack;Ljava/util/List;II)V")) private void modifyRenderToolTip(Args args) { - if(Controllable.getInput().isControllerInUse()) + if(Controllable.getInput().isControllerInUse() && Config.CLIENT.options.quickCraft.get()) { List components = args.get(1); components.add(new TranslationTextComponent("controllable.tooltip.craft").mergeStyle(TextFormatting.BOLD).mergeStyle(TextFormatting.BLUE)); diff --git a/src/main/resources/assets/controllable/lang/en_us.json b/src/main/resources/assets/controllable/lang/en_us.json index d74fa621..54af5a18 100644 --- a/src/main/resources/assets/controllable/lang/en_us.json +++ b/src/main/resources/assets/controllable/lang/en_us.json @@ -65,6 +65,7 @@ "controllable.options.flipLeftThumbstickY": "Flip Left Y-Axis", "controllable.options.flipRightThumbstickX": "Flip Right X-Axis", "controllable.options.flipRightThumbstickY": "Flip Right Y-Axis", + "controllable.options.quickCraft": "Quick Craft", "controllable.controller.default": "Default", "controllable.controller.playstation": "Playstation", "controllable.controller.xbox": "Xbox",