forked from Clones/Controlify
reduce bow sensitivity option
This commit is contained in:
@ -1,5 +1,8 @@
|
|||||||
package dev.isxander.controlify.compatibility.yacl;
|
package dev.isxander.controlify.compatibility.yacl;
|
||||||
|
|
||||||
|
import dev.isxander.controlify.api.buttonguide.ButtonGuideApi;
|
||||||
|
import dev.isxander.controlify.api.buttonguide.ButtonGuidePredicate;
|
||||||
|
import dev.isxander.controlify.api.buttonguide.ButtonRenderPosition;
|
||||||
import dev.isxander.controlify.controller.Controller;
|
import dev.isxander.controlify.controller.Controller;
|
||||||
import dev.isxander.controlify.screenop.ScreenProcessor;
|
import dev.isxander.controlify.screenop.ScreenProcessor;
|
||||||
import dev.isxander.yacl.gui.YACLScreen;
|
import dev.isxander.yacl.gui.YACLScreen;
|
||||||
@ -11,6 +14,12 @@ public class YACLScreenProcessor extends ScreenProcessor<YACLScreen> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleComponentNavigation(Controller<?, ?> controller) {
|
protected void handleComponentNavigation(Controller<?, ?> controller) {
|
||||||
|
if (controller.bindings().GUI_ABSTRACT_ACTION_1.justPressed()) {
|
||||||
|
this.playClackSound();
|
||||||
|
screen.finishedSaveButton.onPress();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (controller.bindings().GUI_NEXT_TAB.justPressed()) {
|
if (controller.bindings().GUI_NEXT_TAB.justPressed()) {
|
||||||
var idx = screen.getCurrentCategoryIdx() + 1;
|
var idx = screen.getCurrentCategoryIdx() + 1;
|
||||||
if (idx >= screen.config.categories().size()) idx = 0;
|
if (idx >= screen.config.categories().size()) idx = 0;
|
||||||
@ -25,6 +34,12 @@ public class YACLScreenProcessor extends ScreenProcessor<YACLScreen> {
|
|||||||
super.handleComponentNavigation(controller);
|
super.handleComponentNavigation(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWidgetRebuild() {
|
||||||
|
// currently doesn't work because TextScaledButtonWidget overrides renderString
|
||||||
|
ButtonGuideApi.addGuideToButton(screen.finishedSaveButton, bindings -> bindings.GUI_ABSTRACT_ACTION_1, ButtonRenderPosition.TEXT, ButtonGuidePredicate.ALWAYS);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setInitialFocus() {
|
protected void setInitialFocus() {
|
||||||
screen.setFocused(screen.optionList);
|
screen.setFocused(screen.optionList);
|
||||||
|
@ -153,6 +153,12 @@ public class YACLHelper {
|
|||||||
.tooltip(Component.translatable("controlify.gui.chat_screen_offset.tooltip"))
|
.tooltip(Component.translatable("controlify.gui.chat_screen_offset.tooltip"))
|
||||||
.binding(def.chatKeyboardHeight, () -> config.chatKeyboardHeight, v -> config.chatKeyboardHeight = v)
|
.binding(def.chatKeyboardHeight, () -> config.chatKeyboardHeight, v -> config.chatKeyboardHeight = v)
|
||||||
.controller(opt -> new FloatSliderController(opt, 0f, 0.8f, 0.1f, percentFormatter))
|
.controller(opt -> new FloatSliderController(opt, 0f, 0.8f, 0.1f, percentFormatter))
|
||||||
|
.build())
|
||||||
|
.option(Option.createBuilder(boolean.class)
|
||||||
|
.name(Component.translatable("controlify.gui.reduce_bow_sensitivity"))
|
||||||
|
.tooltip(Component.translatable("controlify.gui.reduce_bow_sensitivity.tooltip"))
|
||||||
|
.binding(def.reduceBowSensitivity, () -> config.reduceBowSensitivity, v -> config.reduceBowSensitivity = v)
|
||||||
|
.controller(TickBoxController::new)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
if (controller instanceof GamepadController gamepad) {
|
if (controller instanceof GamepadController gamepad) {
|
||||||
|
@ -21,6 +21,8 @@ public abstract class ControllerConfig {
|
|||||||
|
|
||||||
public float chatKeyboardHeight = 0f;
|
public float chatKeyboardHeight = 0f;
|
||||||
|
|
||||||
|
public boolean reduceBowSensitivity = true;
|
||||||
|
|
||||||
public boolean calibrated = false;
|
public boolean calibrated = false;
|
||||||
|
|
||||||
public abstract void setDeadzone(int axis, float deadzone);
|
public abstract void setDeadzone(int axis, float deadzone);
|
||||||
|
@ -6,6 +6,8 @@ import dev.isxander.controlify.api.event.ControlifyEvents;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.KeyboardInput;
|
import net.minecraft.client.player.KeyboardInput;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.item.ProjectileWeaponItem;
|
||||||
|
|
||||||
public class InGameInputHandler {
|
public class InGameInputHandler {
|
||||||
private final Controller<?, ?> controller;
|
private final Controller<?, ?> controller;
|
||||||
@ -63,9 +65,14 @@ public class InGameInputHandler {
|
|||||||
var impulseY = controller.bindings().LOOK_DOWN.state() - controller.bindings().LOOK_UP.state();
|
var impulseY = controller.bindings().LOOK_DOWN.state() - controller.bindings().LOOK_UP.state();
|
||||||
var impulseX = controller.bindings().LOOK_RIGHT.state() - controller.bindings().LOOK_LEFT.state();
|
var impulseX = controller.bindings().LOOK_RIGHT.state() - controller.bindings().LOOK_LEFT.state();
|
||||||
|
|
||||||
if (minecraft.mouseHandler.isMouseGrabbed() && minecraft.isWindowActive()) {
|
if (minecraft.mouseHandler.isMouseGrabbed() && minecraft.isWindowActive() && minecraft.player != null) {
|
||||||
lookInputX = impulseX * Math.abs(impulseX) * controller.config().horizontalLookSensitivity;
|
lookInputX = impulseX * Math.abs(impulseX) * controller.config().horizontalLookSensitivity;
|
||||||
lookInputY = impulseY * Math.abs(impulseY) * controller.config().verticalLookSensitivity;
|
lookInputY = impulseY * Math.abs(impulseY) * controller.config().verticalLookSensitivity;
|
||||||
|
|
||||||
|
if (controller.config().reduceBowSensitivity && minecraft.player.getUseItem().getItem() instanceof ProjectileWeaponItem) {
|
||||||
|
lookInputX *= Math.abs(impulseX) * 0.6;
|
||||||
|
lookInputY *= Math.abs(impulseY) * 0.6;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
lookInputX = lookInputY = 0;
|
lookInputX = lookInputY = 0;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
"controlify.gui.chat_screen_offset.tooltip": "How far up the system on-screen keyboard is. This shifts up the chat box so you can see the chat whilst typing.\nThis is extremely useful on the steamdeck.",
|
"controlify.gui.chat_screen_offset.tooltip": "How far up the system on-screen keyboard is. This shifts up the chat box so you can see the chat whilst typing.\nThis is extremely useful on the steamdeck.",
|
||||||
"controlify.gui.controller_theme": "Controller Theme",
|
"controlify.gui.controller_theme": "Controller Theme",
|
||||||
"controlify.gui.controller_theme.tooltip": "The theme to use for rendering controller buttons.",
|
"controlify.gui.controller_theme.tooltip": "The theme to use for rendering controller buttons.",
|
||||||
|
"controlify.gui.reduce_bow_sensitivity": "Reduce Bow Sensitivity",
|
||||||
|
"controlify.gui.reduce_bow_sensitivity.tooltip": "Reduce the sensitivity of bow-like items when aiming.",
|
||||||
"controlify.gui.custom_name": "Display Name",
|
"controlify.gui.custom_name": "Display Name",
|
||||||
"controlify.gui.custom_name.tooltip": "Name to display for this controller throughout Minecraft.",
|
"controlify.gui.custom_name.tooltip": "Name to display for this controller throughout Minecraft.",
|
||||||
"controlify.gui.group.advanced": "Advanced",
|
"controlify.gui.group.advanced": "Advanced",
|
||||||
|
Reference in New Issue
Block a user