Skip to content

Commit

Permalink
Added config option to toggle quick crafting
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCrayfish committed Feb 9, 2021
1 parent f29bfce commit 905cec3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/mrcrayfish/controllable/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static class Options
public final ForgeConfigSpec.DoubleValue rotationSpeed;
public final ForgeConfigSpec.DoubleValue mouseSpeed;
public final ForgeConfigSpec.EnumValue<ActionVisibility> showActions;
public final ForgeConfigSpec.BooleanValue quickCraft;

public Options(ForgeConfigSpec.Builder builder)
{
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<ITextComponent> components = args.get(1);
components.add(new TranslationTextComponent("controllable.tooltip.craft").mergeStyle(TextFormatting.BOLD).mergeStyle(TextFormatting.BLUE));
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/controllable/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 905cec3

Please sign in to comment.