Compare commits

...

16 Commits

Author SHA1 Message Date
gab
759e8d4381 Merge 0ef59057af into 114a72cdde 2025-04-22 20:21:06 +02:00
cryy
0ef59057af Add missing row width calculation 2025-04-22 20:21:02 +02:00
cryy
9ebd1a9cea Increase displayed lines for newline support 2025-04-22 20:17:25 +02:00
cryy
bb5c6976c0 Replace KeyInfo with String
- KeyInfo was leftover code from toying around with various implementations. String is sufficient in current implementation.
2025-04-22 20:16:08 +02:00
cryy
041eeb29aa Make special key constant private 2025-04-22 19:39:56 +02:00
cryy
662bac3053 Finalize virtual keyboard screen
- Added backspace support
- Added space support
- Added new line support
- Added caps support
- Added symbol support
2025-04-22 19:36:26 +02:00
Martin Prokoph
114a72cdde chore: bump version 2025-03-29 00:59:43 +01:00
Martin Prokoph
25e9c9afe3 feat: improve advanced config screen
- Thanks to MidnightLib 1.7.0 :)
2025-03-29 00:58:41 +01:00
Martin Prokoph
d313115388 Merge pull request #327 from Kichura/ge_fun
Gradle 8.13, Change artifact path
2025-03-27 23:33:26 +01:00
Martin Prokoph
e46e855961 Merge branch 'architectury-1.21.5' into ge_fun 2025-03-27 21:22:50 +01:00
Martin Prokoph
38229bc827 port: Spring to Life (1.21.5)
- Still waiting for ObsidianUI to get the settings screen working. Guess I'm gonna have to port that myself again.
2025-03-27 16:10:03 +01:00
Kichura
1e2dd30e3a Gradle 8.13. 2025-02-25 18:56:00 +01:00
Kichura
f14387b6b4 Gradle 8.12.1. 2025-01-30 02:10:20 +01:00
Kichura
1344a949cd Do not persist credentials. 2025-01-07 22:57:18 +01:00
Kichura
65a0b1cf1f Gradle 8.12, Migrate to setup-gradle. 2025-01-06 23:43:22 +01:00
Kichura
23f7b2e199 Change artifacts path. 2025-01-06 21:16:18 +01:00
29 changed files with 578 additions and 274 deletions

View File

@@ -8,8 +8,10 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3
with:
persist-credentials: false
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
@@ -22,4 +24,6 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: MidnightControls-Artifacts
path: /build/libs/
path: |
fabric/build/libs/
neoforge/build/libs/

View File

@@ -11,8 +11,10 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3
with:
persist-credentials: false
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:

View File

@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
}
@@ -85,4 +85,4 @@ allprojects {
java {
withSourcesJar()
}
}
}

View File

@@ -11,7 +11,7 @@ package eu.midnightdust.midnightcontrols.client;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.platform.GlDebugInfo;
import com.mojang.blaze3d.platform.GLX;
import eu.midnightdust.lib.config.MidnightConfig;
import eu.midnightdust.midnightcontrols.ControlsMode;
import eu.midnightdust.midnightcontrols.MidnightControls;
@@ -52,78 +52,106 @@ public class MidnightControlsConfig extends MidnightConfig {
public static boolean isEditing = false;
@Hidden @Entry public static int configVersion = 2;
// General
@Comment(category = CONTROLLER, centered = true, name="\uD83C\uDFAE General") public static Comment _general;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.controls_mode") public static ControlsMode controlsMode = ControlsMode.DEFAULT;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.auto_switch_mode") public static boolean autoSwitchMode = true;
@Entry(category = MISC, name = "Debug") public static boolean debug = false;
// HUD
@Comment(category = VISUAL, centered = true, name="\uD83D\uDDB9 Hud") public static Comment _hud;
@Entry(category = VISUAL, name = "midnightcontrols.menu.hud_enable") public static boolean hudEnable = true;
@Entry(category = VISUAL, name = "midnightcontrols.menu.hud_side") public static HudSide hudSide = HudSide.LEFT;
@Entry(category = SCREENS, name = "midnightcontrols.menu.move_chat") public static boolean moveChat = false;
@Entry(category = VISUAL, name = "midnightcontrols.menu.controller_type") public static ControllerType controllerType = ControllerType.DEFAULT;
// Gameplay
@Comment(category = GAMEPLAY, centered = true, name="\uD83D\uDECB Comfort") public static Comment _comfort;
@Entry(category = GAMEPLAY, name = "Enable Hints") public static boolean enableHints = true;
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.analog_movement") public static boolean analogMovement = true;
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.double_tap_to_sprint") public static boolean doubleTapToSprint = true;
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.controller_toggle_sneak") public static boolean controllerToggleSneak = MinecraftClient.getInstance().options.getSneakToggled().getValue();
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.controller_toggle_sprint") public static boolean controllerToggleSprint = MinecraftClient.getInstance().options.getSprintToggled().getValue();
@Condition(requiredModId = "midnightcontrols-extra")
@Comment(category = GAMEPLAY, centered = true, name="✨ Extras") public static Comment _extras;
@Condition(requiredModId = "midnightcontrols-extra")
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.fast_block_placing") public static boolean fastBlockPlacing = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
@Condition(requiredModId = "midnightcontrols-extra")
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.fly_drifting") public static boolean flyDrifting = true; // Enabled by default as disabling this behaviour can be considered cheating on multiplayer servers. It can also conflict with some other mods.
@Condition(requiredModId = "midnightcontrols-extra")
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.fly_drifting_vertical") public static boolean verticalFlyDrifting = true; // Enabled by default as disabling this behaviour can be considered cheating on multiplayer servers.
@Condition(requiredModId = "midnightcontrols-extra")
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.reacharound.horizontal") public static boolean horizontalReacharound = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
@Condition(requiredModId = "midnightcontrols-extra")
@Entry(category = GAMEPLAY, name = "midnightcontrols.menu.reacharound.vertical") public static boolean verticalReacharound = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
@Condition(requiredModId = "midnightcontrols-extra")
@Comment(category = VISUAL, centered = true, name="⊽ Reacharound") public static Comment _reacharoundOutline;
@Condition(requiredModId = "midnightcontrols-extra")
@Entry(category = VISUAL, name = "Reacharound Outline") public static boolean shouldRenderReacharoundOutline = true;
@Condition(requiredModId = "midnightcontrols-extra", requiredOption = "shouldRenderReacharoundOutline")
@Entry(category = VISUAL, name = "Reacharound Outline Color", isColor = true) public static String reacharoundOutlineColorHex = "#ffffff";
@Condition(requiredModId = "midnightcontrols-extra", requiredOption = "shouldRenderReacharoundOutline")
@Entry(category = VISUAL, name = "Reacharound Outline Alpha", isSlider = true, min = 0, max = 255) public static int reacharoundOutlineColorAlpha = 102;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.right_dead_zone", isSlider = true, min = 0.05, max = 1) public static double rightDeadZone = 0.25;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.left_dead_zone", isSlider = true, min = 0.05, max = 1) public static double leftDeadZone = 0.25;
@Entry(category = CONTROLLER, name = "Trigger Dead-Zone", isSlider = true, min = 0.05, max = 1) public static double triggerDeadZone = 0.1;
@Comment(category = CONTROLLER, centered = true, name="\uD83D\uDCF7 Camera Settings") public static Comment _cameraSettings;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.invert_right_y_axis") public static boolean invertRightYAxis = false;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.invert_right_x_axis") public static boolean invertRightXAxis = false;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.rotation_speed", isSlider = true, min = 0, max = 100, precision = 10) public static double rotationSpeed = 35.0; //used for x-axis, name kept for compatibility
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.y_axis_rotation_speed", isSlider = true, min = 0, max = 100, precision = 10) public static double yAxisRotationSpeed = rotationSpeed;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.camera_mode") public static CameraMode cameraMode = CameraMode.FLAT;
@Comment(category = SCREENS, centered = true, name="\uD83D\uDDB1 Mouse Behaviour") public static Comment _mouseBehaviour;
@Entry(category = SCREENS, name = "midnightcontrols.menu.mouse_speed", isSlider = true, min = 0, max = 150, precision = 10) public static double mouseSpeed = 25.0;
@Entry(category = SCREENS, name = "midnightcontrols.menu.joystick_as_mouse") public static boolean joystickAsMouse = false;
@Entry(category = SCREENS, name = "midnightcontrols.menu.eye_tracker_as_mouse") public static boolean eyeTrackerAsMouse = false;
@Entry(category = SCREENS, name = "midnightcontrols.menu.eye_tracker_deadzone", isSlider = true, min = 0, max = 0.4) public static double eyeTrackerDeadzone = 0.05;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.unfocused_input") public static boolean unfocusedInput = false;
@Entry(category = SCREENS, name = "midnightcontrols.menu.virtual_mouse") public static boolean virtualMouse = false;
@Entry(category = SCREENS, name = "midnightcontrols.menu.virtual_mouse.skin") public static VirtualMouseSkin virtualMouseSkin = VirtualMouseSkin.DEFAULT_LIGHT;
@Entry(category = SCREENS, name = "midnightcontrols.menu.hide_cursor") public static boolean hideNormalMouse = false;
@Entry(category = CONTROLLER, name = "Controller ID") @Hidden public static Object controllerID = 0;
@Entry(category = CONTROLLER, name = "2nd Controller ID") @Hidden public static Object secondControllerID = -1;
@Entry(category = VISUAL, name = "midnightcontrols.menu.controller_type") public static ControllerType controllerType = ControllerType.DEFAULT;
@Entry(category = SCREENS, name = "Mouse screens") public static List<String> mouseScreens = Lists.newArrayList("net.minecraft.client.gui.screen.advancement",
"net.minecraft.class_457", "net.minecraft.class_408", "net.minecraft.class_3872", "me.flashyreese.mods.reeses_sodium_options.client.gui", "dev.emi.emi.screen",
"hardcorequesting.client.interfaces.GuiQuestBook", "hardcorequesting.client.interfaces.GuiReward", "hardcorequesting.client.interfaces.EditTrackerScreen",
"me.shedaniel.clothconfig2.gui.ClothConfigScreen", "com.mamiyaotaru.voxelmap.gui.GuiWaypoints", "com.mamiyaotaru.voxelmap.gui.GuiPersistentMap");
@Entry(category = SCREENS, name = "Arrow screens") public static List<String> arrowScreens = Lists.newArrayList(ChatScreen.class.getCanonicalName());
@Entry(category = SCREENS, name = "WASD screens") public static List<String> wasdScreens = Lists.newArrayList("com.ultreon.devices.core.Laptop");
@Entry(category = TOUCH, name = "Screens with close button") public static List<String> closeButtonScreens = Lists.newArrayList(ChatScreen.class.getCanonicalName(), AdvancementsScreen.class.getCanonicalName(), RingScreen.class.getCanonicalName());
@Comment(category = CONTROLLER, centered = true, name="\uD83D\uDC40 Eye Tracking") public static Comment _eyeTracker;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.eye_tracker_as_mouse") public static boolean eyeTrackerAsMouse = false;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.eye_tracker_deadzone", isSlider = true, min = 0, max = 0.4) public static double eyeTrackerDeadzone = 0.05;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.unfocused_input") public static boolean unfocusedInput = false;
@Comment(category = SCREENS, centered = true, name="\uD83D\uDC46 Virtual Mouse") public static Comment _virtualMouse;
@Entry(category = SCREENS, name = "midnightcontrols.menu.virtual_mouse") public static boolean virtualMouse = false;
@Condition(requiredOption = "virtualMouse", visibleButLocked = true)
@Entry(category = SCREENS, name = "midnightcontrols.menu.virtual_mouse.skin") public static VirtualMouseSkin virtualMouseSkin = VirtualMouseSkin.DEFAULT_LIGHT;
@Entry(category = SCREENS, name = "midnightcontrols.menu.hide_cursor") public static boolean hideNormalMouse = false;
@Entry(category = CONTROLLER, name = "Controller ID") @Hidden public static Object controllerID = 0;
@Entry(category = CONTROLLER, name = "2nd Controller ID") @Hidden public static Object secondControllerID = -1;
@Comment(category = TOUCH, centered = true, name="\uD83E\uDE84 Behaviour") public static Comment _touchBehaviour;
@Entry(category = TOUCH, name = "midnightcontrols.menu.touch_with_controller") public static boolean touchInControllerMode = false;
@Entry(category = TOUCH, name = "midnightcontrols.menu.touch_speed", isSlider = true, min = 0, max = 150, precision = 10) public static double touchSpeed = 50.0;
@Entry(category = TOUCH, name = "midnightcontrols.menu.invert_touch") public static boolean invertTouch = false;
@Entry(category = TOUCH, name = "midnightcontrols.menu.touch_mode") public static TouchMode touchMode = TouchMode.CROSSHAIR;
@Entry(category = TOUCH, name = "midnightcontrols.menu.touch_break_delay", isSlider = true, min = 50, max = 500) public static int touchBreakDelay = 120;
@Comment(category = TOUCH, centered = true, name="\uD83D\uDCA1 Visuals") public static Comment _visuals;
@Entry(category = TOUCH, name = "midnightcontrols.menu.touch_transparency", isSlider = true, min = 0, max = 100) public static int touchTransparency = 75;
@Entry(category = TOUCH, name = "Touch Outline Color", isColor = true) public static String touchOutlineColorHex = "#ffffff";
@Entry(category = TOUCH, name = "Touch Outline Alpha", isSlider = true, min = 0, max = 255) public static int touchOutlineColorAlpha = 150;
@Comment(category = TOUCH, centered = true, name="\uD83E\uDDEA Advanced") public static Comment _advanced;
@Entry(category = TOUCH, name = "Screens with close button") public static List<String> closeButtonScreens = Lists.newArrayList(ChatScreen.class.getCanonicalName(), AdvancementsScreen.class.getCanonicalName(), RingScreen.class.getCanonicalName());
@Entry(category = TOUCH, name = "Left Touch button bindings") public static List<String> leftTouchBinds = Lists.newArrayList("debug_screen", "screenshot","toggle_perspective");
@Entry(category = TOUCH, name = "Right Touch button bindings") public static List<String> rightTouchBinds = Lists.newArrayList("screenshot","toggle_perspective", "use");
@Entry @Hidden public static Map<String, String> BINDING = new HashMap<>();
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
@Comment(category = CONTROLLER, centered = true, name="\uD83D\uDD79 Max Analog Stick Values") public static Comment _maxAnalogValues;
@Entry(category = CONTROLLER, name = "Max analog value: Left X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftX = 1;
@Entry(category = CONTROLLER, name = "Max analog value: Left Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftY = 1;
@Entry(category = CONTROLLER, name = "Max analog value: Right X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightX = 1;
@Entry(category = CONTROLLER, name = "Max analog value: Right Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightY = 1;
@Comment(category = CONTROLLER, centered = true, name="☠ Dead Zones") public static Comment _deadZones;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.right_dead_zone", isSlider = true, min = 0.05, max = 1) public static double rightDeadZone = 0.25;
@Entry(category = CONTROLLER, name = "midnightcontrols.menu.left_dead_zone", isSlider = true, min = 0.05, max = 1) public static double leftDeadZone = 0.25;
@Entry(category = CONTROLLER, name = "Trigger Dead-Zone", isSlider = true, min = 0.05, max = 1) public static double triggerDeadZone = 0.1;
@Comment(category = CONTROLLER, centered = true, name="☆ Other Options") public static Comment _otherOptions;
@Entry(category = CONTROLLER, name = "Trigger button fix") public static boolean triggerFix = true;
@Entry(category = CONTROLLER, name = "Excluded Controllers (Name Regex)") public static List<String> excludedControllers = Lists.newArrayList(".*(Keyboard)$", ".*(Touchpad)$", ".*(Pen)$", ".*(Finger)$");
@Comment(category = SCREENS, centered = true, name="\uD83D\uDD27 UI Modifications") public static Comment _uiMods;
@Entry(category = SCREENS, name = "midnightcontrols.menu.move_chat") public static boolean moveChat = false;
@Entry(category = SCREENS, name = "Enable Shortcut in Controls Options") public static boolean shortcutInControls = true;
@Entry(category = MISC, name = "Debug") public static boolean debug = false;
@Entry(category = MISC, name = "Excluded Keybindings") public static List<String> excludedKeybindings = Lists.newArrayList("key.forward", "key.left", "key.back", "key.right", "key.jump", "key.sneak", "key.sprint", "key.inventory",
"key.swapOffhand", "key.drop", "key.use", "key.attack", "key.chat", "key.playerlist", "key.screenshot", "key.togglePerspective", "key.smoothCamera", "key.fullscreen", "key.saveToolbarActivator", "key.loadToolbarActivator",
"key.pickItem", "key.hotbar.1", "key.hotbar.2", "key.hotbar.3", "key.hotbar.4", "key.hotbar.5", "key.hotbar.6", "key.hotbar.7", "key.hotbar.8", "key.hotbar.9");
@Entry(category = GAMEPLAY, name = "Enable Hints") public static boolean enableHints = true;
@Entry(category = SCREENS, name = "Enable Shortcut in Controls Options") public static boolean shortcutInControls = true;
@Entry(category = MISC, name = "Ring Bindings (WIP)") public static List<String> ringBindings = new ArrayList<>();
@Entry(category = MISC, name = "Ring Bindings (WIP)") @Hidden public static List<String> ringBindings = new ArrayList<>();
@Entry(category = MISC, name = "Ignored Unbound Keys") public static List<String> ignoredUnboundKeys = Lists.newArrayList("inventorytabs.key.next_tab");
@Entry @Hidden public static Map<String, Map<String, String>> controllerBindingProfiles = new HashMap<>();
private static Map<String, String> currentBindingProfile = new HashMap<>();
@@ -400,7 +428,7 @@ public class MidnightControlsConfig extends MidnightConfig {
String controller = getController().getName().toLowerCase();
if (controller.contains("xbox 360")) return ControllerType.XBOX_360;
else if (controller.contains("xbox") || controller.contains("afterglow")) return ControllerType.XBOX;
else if (controller.contains("steam") && GlDebugInfo.getCpuInfo().contains("AMD Custom APU")) return ControllerType.STEAM_DECK;
else if (controller.contains("steam") && GLX._getCpuInfo().contains("AMD Custom APU")) return ControllerType.STEAM_DECK;
else if (controller.contains("steam")) return ControllerType.STEAM_CONTROLLER;
else if (controller.contains("dualsense") || controller.contains("ps5")) return ControllerType.DUALSENSE;
else if (controller.contains("dualshock") || controller.contains("ps4") || controller.contains("sony")) return ControllerType.DUALSHOCK;

View File

@@ -214,10 +214,10 @@ public class MidnightInput {
return;
if (this.targetYaw != 0.f || this.targetPitch != 0.f) {
float rotationYaw = (float) (client.player.prevYaw + (this.targetYaw * 0.175));
float rotationPitch = (float) (client.player.prevPitch + (this.targetPitch * 0.175));
client.player.prevYaw = rotationYaw;
client.player.prevPitch = MathHelper.clamp(rotationPitch, -90.f, 90.f);
float rotationYaw = (float) (client.player.lastYaw + (this.targetYaw * 0.175));
float rotationPitch = (float) (client.player.lastPitch + (this.targetPitch * 0.175));
client.player.lastYaw = rotationYaw;
client.player.lastPitch = MathHelper.clamp(rotationPitch, -90.f, 90.f);
client.player.setYaw(rotationYaw);
client.player.setPitch(MathHelper.clamp(rotationPitch, -90.f, 90.f));
if (client.player.isRiding() && client.player.getVehicle() != null) {

View File

@@ -62,9 +62,9 @@ public class InputHandlers {
if (!client.player.isSpectator()) {
var inv = client.player.getInventory();
if (next)
inv.setSelectedSlot(inv.selectedSlot < 8 ? inv.selectedSlot + 1 : inv.selectedSlot - 8);
inv.setSelectedSlot(inv.getSelectedSlot() < 8 ? inv.getSelectedSlot() + 1 : inv.getSelectedSlot() - 8);
else
inv.setSelectedSlot(inv.selectedSlot > 0 ? inv.selectedSlot - 1 : inv.selectedSlot + 8);
inv.setSelectedSlot(inv.getSelectedSlot() > 0 ? inv.getSelectedSlot() - 1 : inv.getSelectedSlot() + 8);
}
else {
if (client.inGameHud.getSpectatorHud().isOpen()) {

View File

@@ -76,8 +76,8 @@ public class InputManager {
public void updateMousePosition(@NotNull MinecraftClient client) {
Objects.requireNonNull(client, "Client instance cannot be null.");
if (this.prevTargetMouseX != this.targetMouseX || this.prevTargetMouseY != this.targetMouseY) {
double mouseX = this.prevTargetMouseX + (this.targetMouseX - this.prevTargetMouseX) * client.getRenderTickCounter().getTickDelta(true) + 0.5;
double mouseY = this.prevTargetMouseY + (this.targetMouseY - this.prevTargetMouseY) * client.getRenderTickCounter().getTickDelta(true) + 0.5;
double mouseX = this.prevTargetMouseX + (this.targetMouseX - this.prevTargetMouseX) * client.getRenderTickCounter().getTickProgress(true) + 0.5;
double mouseY = this.prevTargetMouseY + (this.targetMouseY - this.prevTargetMouseY) * client.getRenderTickCounter().getTickProgress(true) + 0.5;
if (!MidnightControlsConfig.virtualMouse)
GLFW.glfwSetCursorPos(client.getWindow().getHandle(), mouseX, mouseY);
((MouseAccessor) client.mouse).midnightcontrols$onCursorPos(client.getWindow().getHandle(), mouseX, mouseY);

View File

@@ -11,12 +11,14 @@ package eu.midnightdust.midnightcontrols.client.controller;
import eu.midnightdust.midnightcontrols.client.enums.ButtonState;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import eu.midnightdust.midnightcontrols.client.mixin.InputAccessor;
import eu.midnightdust.midnightcontrols.client.util.MathUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.util.PlayerInput;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec2f;
import org.jetbrains.annotations.NotNull;
/**
@@ -53,8 +55,8 @@ public final class MovementHandler implements PressAction {
player.input.playerInput.jump(), player.input.playerInput.sneak(), player.input.playerInput.sprint());
polarUtil.calculate(this.movementSideways, this.movementForward, this.slowdownFactor);
player.input.movementForward = polarUtil.polarY;
player.input.movementSideways = polarUtil.polarX;
Vec2f inputVector = new Vec2f(polarUtil.polarX, polarUtil.polarY);
((InputAccessor)player.input).setMovementVector(inputVector);
this.shouldOverrideMovement = false;
}

View File

@@ -98,7 +98,7 @@ public class MidnightControlsHud extends Hud {
var window = this.client.getWindow();
var text = "[ ]";
float scale = Math.min(5, this.ticksDisplayedCrosshair + tickCounter.getTickDelta(true)) / 5F;
float scale = Math.min(5, this.ticksDisplayedCrosshair + tickCounter.getTickProgress(true)) / 5F;
scale *= scale;
int opacity = ((int) (255 * scale)) << 24;

View File

@@ -9,6 +9,8 @@
package eu.midnightdust.midnightcontrols.client.gui;
import com.mojang.blaze3d.opengl.GlStateManager;
import com.mojang.blaze3d.platform.GLX;
import com.mojang.blaze3d.systems.RenderSystem;
import eu.midnightdust.midnightcontrols.ControlsMode;
import eu.midnightdust.midnightcontrols.client.enums.ControllerType;
@@ -169,7 +171,7 @@ public class MidnightControlsRenderer {
case GLFW.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER + 100, GLFW.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER + 200 -> buttonOffset = 10 * 15;
}
RenderSystem.disableDepthTest();
GlStateManager._disableDepthTest();
int assetSize = axis || (button >= 15 && button <= 18) ? AXIS_SIZE : BUTTON_SIZE;
@@ -179,7 +181,7 @@ public class MidnightControlsRenderer {
(float) buttonOffset, (float) (controllerType * assetSize),
assetSize, assetSize,
256, 256);
RenderSystem.enableDepthTest();
GlStateManager._enableDepthTest();
return ICON_SIZE;
}

View File

@@ -9,6 +9,7 @@
package eu.midnightdust.midnightcontrols.client.gui;
import com.mojang.blaze3d.opengl.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import eu.midnightdust.midnightcontrols.MidnightControlsConstants;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
@@ -512,13 +513,13 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
float g = (float)(color.getGreen()) / 255.0F;
float b = (float)(color.getBlue()) / 255.0F;
float t = (float)(transparency) / 255.0F;
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
GlStateManager._enableBlend();
//GlStateManager._defaultBlendFunc();
vertexConsumer.vertex((float)x1, (float)y2, 0.0F).color(r, g, b, t);
vertexConsumer.vertex((float)x2, (float)y2, 0.0F).color(r, g, b, t);
vertexConsumer.vertex((float)x2, (float)y1, 0.0F).color(r, g, b, t);
vertexConsumer.vertex((float)x1, (float)y1, 0.0F).color(r, g, b, t);
RenderSystem.disableBlend();
GlStateManager._disableBlend();
context.draw();
}
}

View File

@@ -1,108 +0,0 @@
package eu.midnightdust.midnightcontrols.client.gui;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.Text;
import org.thinkingstudio.obsidianui.Position;
import org.thinkingstudio.obsidianui.SpruceTexts;
import org.thinkingstudio.obsidianui.screen.SpruceScreen;
import org.thinkingstudio.obsidianui.widget.SpruceButtonWidget;
import org.thinkingstudio.obsidianui.widget.container.SpruceContainerWidget;
public class VirtualKeyboardScreen extends SpruceScreen {
private SpruceContainerWidget container;
private TextFieldWidget bufferDisplay;
private final StringBuilder buffer;
private final CloseCallback closeCallback;
@FunctionalInterface
public interface CloseCallback {
void onClose(String text);
}
public VirtualKeyboardScreen(String initialText, CloseCallback closeCallback) {
super(Text.literal("Virtual Keyboard"));
this.buffer = new StringBuilder(initialText);
this.closeCallback = closeCallback;
}
@Override
protected void init() {
super.init();
this.bufferDisplay = new TextFieldWidget(this.textRenderer, this.width / 2 - 100, this.height / 4 - 40, 200, 20, Text.literal(""));
this.bufferDisplay.setEditable(false);
this.bufferDisplay.setMaxLength(1024);
this.bufferDisplay.setText(buffer.toString());
this.addDrawableChild(this.bufferDisplay);
rebuildKeyboard();
this.addDrawableChild(container);
this.addDrawableChild(new SpruceButtonWidget(Position.of(this, this.width / 2 - 50, this.height - 30), 100, 20, SpruceTexts.GUI_DONE, btn -> this.close()));
}
@Override
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
super.render(drawContext, mouseX, mouseY, delta);
drawContext.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 10, 0xFFFFFF);
}
private void rebuildKeyboard() {
this.container = new SpruceContainerWidget(Position.of(0, this.height / 4 - 10), this.width, this.height / 2);
var row1 = new String[]{"q", "w", "e", "r", "t", "y", "u", "i", "o", "p"};
var row2 = new String[]{"a", "s", "d", "f", "g", "h", "j", "k", "l"};
var row3 = new String[]{"z", "x", "c", "v", "b", "n", "m"};
addKeyRow(0, row1);
addKeyRow(1, row2);
addKeyRow(2, row3);
}
private void addKeyRow(int rowOffset, String... keys) {
int keyWidth = 20;
int spacing = 2;
int totalWidth = (keyWidth + spacing) * keys.length - spacing;
int startX = (this.width - totalWidth) / 2;
int y = this.height / 4 + rowOffset * 24;
for (int i = 0; i < keys.length; i++) {
String key = keys[i];
this.container.addChild(new SpruceButtonWidget(Position.of(startX + i * (keyWidth + spacing), y), keyWidth, 20, Text.literal(key), btn -> handleKeyPress(key)));
}
}
private void handleKeyPress(String key) {
if (this.client == null) return;
// TODO
if (key.equals("\b")) {
if (!buffer.isEmpty()) {
buffer.deleteCharAt(buffer.length() - 1);
}
} else {
buffer.append(key);
}
if (this.bufferDisplay != null) {
this.bufferDisplay.setText(buffer.toString());
}
}
@Override
public boolean shouldPause() {
return false;
}
@Override
public void close() {
super.close();
if (closeCallback != null) {
closeCallback.onClose(buffer.toString());
}
}
}

View File

@@ -0,0 +1,60 @@
package eu.midnightdust.midnightcontrols.client.gui.virtualkeyboard;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class KeyboardLayout {
public static KeyboardLayout QWERTY = new KeyboardLayout(createQwertyLetterLayout(), createSymbolLayout());
private final List<List<String>> letters;
private final List<List<String>> symbols;
private KeyboardLayout(List<List<String>> letters, List<List<String>> symbols) {
this.letters = letters;
this.symbols = symbols;
}
public List<List<String>> getLetters() {
return letters;
}
public List<List<String>> getSymbols() {
return symbols;
}
private static List<List<String>> createQwertyLetterLayout() {
List<List<String>> letters = new ArrayList<>();
letters.add(Arrays.asList(
"q", "w", "e", "r", "t",
"y", "u", "i", "o", "p"
));
letters.add(Arrays.asList(
"a", "s", "d", "f", "g",
"h", "j", "k", "l"
));
letters.add(Arrays.asList(
"z", "x", "c", "v",
"b", "n", "m"
));
return letters;
}
private static List<List<String>> createSymbolLayout() {
List<List<String>> symbols = new ArrayList<>();
symbols.add(Arrays.asList(
"1", "2", "3", "4", "5",
"6", "7", "8", "9", "0"
));
symbols.add(Arrays.asList(
"@", "#", "$", "%", "&",
"*", "-", "+", "(", ")"
));
symbols.add(Arrays.asList(
"!", "\"", "'", ":", ";",
",", ".", "?", "/"
));
return symbols;
}
}

View File

@@ -0,0 +1,299 @@
package eu.midnightdust.midnightcontrols.client.gui.virtualkeyboard;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
import org.thinkingstudio.obsidianui.Position;
import org.thinkingstudio.obsidianui.SpruceTexts;
import org.thinkingstudio.obsidianui.screen.SpruceScreen;
import org.thinkingstudio.obsidianui.widget.SpruceButtonWidget;
import org.thinkingstudio.obsidianui.widget.container.SpruceContainerWidget;
import org.thinkingstudio.obsidianui.widget.text.SpruceTextAreaWidget;
import java.util.List;
public class VirtualKeyboardScreen extends SpruceScreen {
@FunctionalInterface
public interface CloseCallback {
void onClose(String text);
}
private static final int STANDARD_KEY_WIDTH = 20;
private static final int SPECIAL_KEY_WIDTH = (int) (STANDARD_KEY_WIDTH * 1.5);
private static final int KEY_HEIGHT = 20;
private static final int HORIZONTAL_SPACING = 2;
private static final int VERTICAL_SPACING = 4;
private static final int CONTAINER_PADDING = 10;
// Key symbols
private static final String BACKSPACE_SYMBOL = "\b";
private static final String NEWLINE_SYMBOL = "\n";
private static final String SPACE_SYMBOL = " ";
private final StringBuilder buffer;
private final CloseCallback closeCallback;
private final KeyboardLayout layout;
private final boolean newLineSupport;
private boolean capsMode;
private boolean symbolMode;
private SpruceTextAreaWidget bufferDisplayArea;
private SpruceContainerWidget keyboardContainer;
public VirtualKeyboardScreen(String initialText, CloseCallback closeCallback, boolean newLineSupport) {
super(Text.literal("Virtual Keyboard"));
this.buffer = new StringBuilder(initialText);
this.closeCallback = closeCallback;
this.layout = KeyboardLayout.QWERTY;
this.capsMode = false;
this.symbolMode = false;
this.newLineSupport = newLineSupport;
}
@Override
protected void init() {
super.init();
this.bufferDisplayArea = createBufferDisplayArea();
this.addDrawableChild(this.bufferDisplayArea);
rebuildKeyboard();
int doneButtonY = this.keyboardContainer.getY() + this.keyboardContainer.getHeight() + VERTICAL_SPACING * 2;
this.addDrawableChild(
new SpruceButtonWidget(
Position.of(this, this.width / 2 - 50, doneButtonY),
100,
20,
SpruceTexts.GUI_DONE,
btn -> this.close()
)
);
}
@Override
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
this.renderBackground(drawContext, mouseX, mouseY, delta);
super.render(drawContext, mouseX, mouseY, delta);
}
@Override
public boolean shouldPause() {
return false;
}
@Override
public void close() {
super.close();
if (this.closeCallback != null) {
this.closeCallback.onClose(this.buffer.toString());
}
}
private void rebuildKeyboard() {
if (this.keyboardContainer != null) {
this.remove(this.keyboardContainer);
}
var layoutKeys = getActiveKeyLayout();
var keyboardContainer = createKeyboardContainer(layoutKeys);
addLayoutRows(keyboardContainer, layoutKeys);
addFunctionKeys(keyboardContainer);
addBottomRow(keyboardContainer);
this.keyboardContainer = keyboardContainer;
this.addDrawableChild(this.keyboardContainer);
}
private SpruceContainerWidget createKeyboardContainer(List<List<String>> layoutKeys) {
int containerWidth = this.width;
int totalKeyboardHeight = calculateKeyboardHeight(layoutKeys);
int keyboardY = this.bufferDisplayArea.getY() + this.bufferDisplayArea.getHeight() + VERTICAL_SPACING * 2;
return new SpruceContainerWidget(
Position.of(0, keyboardY),
containerWidth,
totalKeyboardHeight
);
}
private SpruceTextAreaWidget createBufferDisplayArea() {
int lineCount = this.newLineSupport ? 4 : 1;
int bufferX = this.width / 2 - 100;
int bufferY = this.height / 4 - VERTICAL_SPACING * 5 - 5;
int bufferWidth = 200;
int desiredHeight = (this.textRenderer.fontHeight + 2) * lineCount + 6;
var bufferDisplay = new SpruceTextAreaWidget(
Position.of(bufferX, bufferY),
bufferWidth,
desiredHeight,
Text.literal("Buffer Display")
);
bufferDisplay.setText(this.buffer.toString());
bufferDisplay.setEditable(false);
bufferDisplay.setUneditableColor(0xFFFFFFFF);
bufferDisplay.setDisplayedLines(lineCount);
bufferDisplay.setCursorToEnd();
return bufferDisplay;
}
private int calculateKeyboardHeight(List<List<String>> keyRows) {
return keyRows.size() * (KEY_HEIGHT + VERTICAL_SPACING) +
(KEY_HEIGHT + VERTICAL_SPACING) + // space for bottom row
CONTAINER_PADDING * 2; // top and bottom padding
}
private void addLayoutRows(SpruceContainerWidget container, List<List<String>> keyLayoutRows) {
int currentY = CONTAINER_PADDING;
for (List<String> row : keyLayoutRows) {
int rowWidth = calculateRowWidth(row);
// center row
int currentX = (container.getWidth() - rowWidth) / 2;
for (String key : row) {
String displayText = (this.capsMode && !this.symbolMode) ? key.toUpperCase() : key;
container.addChild(
new SpruceButtonWidget(
Position.of(currentX, currentY),
STANDARD_KEY_WIDTH,
KEY_HEIGHT,
Text.literal(displayText),
btn -> handleKeyPress(displayText)
)
);
currentX += STANDARD_KEY_WIDTH + HORIZONTAL_SPACING;
}
currentY += KEY_HEIGHT + VERTICAL_SPACING;
}
}
private int calculateRowWidth(List<String> row) {
int rowWidth = 0;
for (int i = 0; i < row.size(); i++) {
rowWidth += STANDARD_KEY_WIDTH;
// padding
if (i < row.size() - 1) {
rowWidth += HORIZONTAL_SPACING;
}
}
return rowWidth;
}
private void addFunctionKeys(SpruceContainerWidget container) {
List<String> firstRow = getActiveKeyLayout().get(0);
int firstRowWidth = calculateRowWidth(firstRow);
// position backspace at the right of the first row
int backspaceWidth = (int) (STANDARD_KEY_WIDTH * 1.5);
int backspaceX = (container.getWidth() + firstRowWidth) / 2 + HORIZONTAL_SPACING;
container.addChild(
new SpruceButtonWidget(
Position.of(backspaceX, CONTAINER_PADDING),
backspaceWidth,
KEY_HEIGHT,
Text.literal(""),
btn -> handleKeyPress(BACKSPACE_SYMBOL)
)
);
if (this.newLineSupport) {
// position newline at the right of the second row
List<String> secondRow = getActiveKeyLayout().get(1);
int newlineWidth = (int) (STANDARD_KEY_WIDTH * 1.5);
int secondRowWidth = calculateRowWidth(secondRow);
int newlineX = (container.getWidth() + secondRowWidth) / 2 + HORIZONTAL_SPACING;
int newlineY = CONTAINER_PADDING + (KEY_HEIGHT + VERTICAL_SPACING);
container.addChild(
new SpruceButtonWidget(
Position.of(newlineX, newlineY),
newlineWidth,
KEY_HEIGHT,
Text.literal(""),
btn -> handleKeyPress(NEWLINE_SYMBOL)
)
);
}
}
private void addBottomRow(SpruceContainerWidget container) {
// calculate positions for bottom row
int rowY = CONTAINER_PADDING + getActiveKeyLayout().size() * (KEY_HEIGHT + VERTICAL_SPACING);
// space bar - wide key in the middle
double spaceWidthFactor = 5.0;
int spaceKeyWidth = (int) (STANDARD_KEY_WIDTH * spaceWidthFactor);
int spaceX = (container.getWidth() - spaceKeyWidth) / 2;
container.addChild(
new SpruceButtonWidget(
Position.of(spaceX, rowY),
spaceKeyWidth,
KEY_HEIGHT,
Text.literal("Space"),
btn -> handleKeyPress(SPACE_SYMBOL)
)
);
// caps key - left of space
if (!this.symbolMode) {
int capsX = spaceX - SPECIAL_KEY_WIDTH - HORIZONTAL_SPACING * 2;
var capsModeButton = new SpruceButtonWidget(
Position.of(capsX, rowY),
SPECIAL_KEY_WIDTH,
KEY_HEIGHT,
Text.literal(this.capsMode ? "caps" : "CAPS"),
btn -> toggleCapsMode());
container.addChild(capsModeButton);
}
// symbols key - right of space
int symbolsX = spaceX + spaceKeyWidth + HORIZONTAL_SPACING * 2;
var symbolModeButton = new SpruceButtonWidget(
Position.of(symbolsX, rowY),
SPECIAL_KEY_WIDTH,
KEY_HEIGHT,
Text.literal(this.symbolMode ? "ABC" : "123?!"),
btn -> toggleSymbolMode()
);
container.addChild(symbolModeButton);
}
private void handleKeyPress(String key) {
if (key.equals(BACKSPACE_SYMBOL)) {
if (!this.buffer.isEmpty()) {
this.buffer.deleteCharAt(buffer.length() - 1);
}
} else {
this.buffer.append(key);
}
if (this.bufferDisplayArea != null) {
this.bufferDisplayArea.setText(this.buffer.toString());
this.bufferDisplayArea.setCursorToEnd();
}
}
private List<List<String>> getActiveKeyLayout() {
return this.symbolMode ? this.layout.getSymbols() : this.layout.getLetters();
}
private void toggleCapsMode() {
this.capsMode = !this.capsMode;
rebuildKeyboard();
}
private void toggleSymbolMode() {
this.symbolMode = !this.symbolMode;
rebuildKeyboard();
}
}

View File

@@ -30,9 +30,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GameRenderer.class)
public abstract class GameRendererMixin {
@Shadow @Final MinecraftClient client;
@Shadow @Final private MinecraftClient client;
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Mouse;getX()D", shift = At.Shift.BEFORE))
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Mouse;getScaledX(Lnet/minecraft/client/util/Window;)D", shift = At.Shift.BEFORE))
private void midnightcontrols$onRender(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci) {
if (this.client.currentScreen != null && MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER)
MidnightControlsClient.input.onPreRenderScreen(this.client.currentScreen);

View File

@@ -0,0 +1,12 @@
package eu.midnightdust.midnightcontrols.client.mixin;
import net.minecraft.client.input.Input;
import net.minecraft.util.math.Vec2f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(Input.class)
public interface InputAccessor {
@Accessor
void setMovementVector(Vec2f input);
}

View File

@@ -81,7 +81,7 @@ public abstract class MinecraftClientMixin {
var side = hitResult.getSide();
boolean sidewaysBlockPlacing = this.midnightcontrols$lastTargetPos == null || !targetPos.equals(this.midnightcontrols$lastTargetPos.offset(this.midnightcontrols$lastTargetSide));
boolean backwardsBlockPlacing = this.player.input.movementForward < 0.0f && (this.midnightcontrols$lastTargetPos == null || targetPos.equals(this.midnightcontrols$lastTargetPos.offset(this.midnightcontrols$lastTargetSide)));
boolean backwardsBlockPlacing = this.player.input.getMovementInput().y < 0.0f && (this.midnightcontrols$lastTargetPos == null || targetPos.equals(this.midnightcontrols$lastTargetPos.offset(this.midnightcontrols$lastTargetSide)));
if (cooldown > 1
&& !targetPos.equals(this.midnightcontrols$lastTargetPos)
@@ -129,7 +129,7 @@ public abstract class MinecraftClientMixin {
if (result.isAccepted()) {
//if (result.shouldSwingHand()) {
this.player.swingHand(hand);
if (!stackInHand.isEmpty() && (stackInHand.getCount() != previousStackCount || this.interactionManager.hasCreativeInventory())) {
if (!stackInHand.isEmpty() && (stackInHand.getCount() != previousStackCount || this.player.isInCreativeMode())) {
this.gameRenderer.firstPersonRenderer.resetEquipProgress(hand);
}
//}

View File

@@ -77,7 +77,7 @@ public abstract class MouseMixin implements MouseAccessor {
for (int slot = 0; slot < 9; ++slot) {
int slotX = centerX - 90 + slot * 20 + 2;
if (mouseX >= (double) slotX && mouseX <= (double) (slotX + 20)) {
client.player.getInventory().selectedSlot = slot;
client.player.getInventory().setSelectedSlot(slot);
ci.cancel();
return;
}

View File

@@ -87,7 +87,7 @@ public class TouchInput {
if (interaction.isAccepted()) {
//if (interaction.shouldSwingHand()) {
client.player.swingHand(client.player.preferredHand);
if (!stackInHand.isEmpty() && (stackInHand.getCount() != previousStackCount || client.interactionManager.hasCreativeInventory())) {
if (!stackInHand.isEmpty() && (stackInHand.getCount() != previousStackCount || client.player.isInCreativeMode())) {
client.gameRenderer.firstPersonRenderer.resetEquipProgress(client.player.preferredHand);
}
//}

View File

@@ -1,11 +1,11 @@
package eu.midnightdust.midnightcontrols.client.touch.gui;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.consume.UseAction;
import org.thinkingstudio.obsidianui.Position;
import org.thinkingstudio.obsidianui.widget.SpruceButtonWidget;
import eu.midnightdust.midnightcontrols.MidnightControlsConstants;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import net.minecraft.item.ArmorItem;
import net.minecraft.text.Text;
public class ItemUseButtonWidget extends SpruceButtonWidget {
@@ -30,7 +30,7 @@ public class ItemUseButtonWidget extends SpruceButtonWidget {
this.setMessage(Text.translatable(MidnightControlsConstants.NAMESPACE+".action.eat"));
} else if (action == UseAction.DRINK) {
this.setMessage(Text.translatable(MidnightControlsConstants.NAMESPACE+".action.drink"));
} else if (client.player.getMainHandStack().getItem() instanceof ArmorItem) {
} else if (client.player.getMainHandStack().getComponents().contains(DataComponentTypes.EQUIPPABLE)) {
this.setMessage(Text.translatable(MidnightControlsConstants.NAMESPACE+".action.equip"));
} else if (!action.equals(UseAction.NONE)) {
this.setMessage(Text.translatable(MidnightControlsConstants.NAMESPACE+".action.use"));

View File

@@ -14,7 +14,7 @@ import eu.midnightdust.midnightcontrols.client.util.storage.AxisStorage;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.item.ArmorItem;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.consume.UseAction;
import net.minecraft.util.Arm;
import net.minecraft.util.Hand;
@@ -340,7 +340,7 @@ public class TouchscreenOverlay extends Screen {
this.forwardLeftButton.setVisible(false);
this.forwardRightButton.setVisible(false);
}
this.useButton.setVisible(client.player.getMainHandStack() != null && (client.player.getMainHandStack().getUseAction() != UseAction.NONE || client.player.getMainHandStack().getItem() instanceof ArmorItem) && !TouchUtils.hasInWorldUseAction(client.player.getMainHandStack()));
this.useButton.setVisible(client.player.getMainHandStack() != null && (client.player.getMainHandStack().getUseAction() != UseAction.NONE || client.player.getMainHandStack().getComponents().contains(DataComponentTypes.EQUIPPABLE)) && !TouchUtils.hasInWorldUseAction(client.player.getMainHandStack()));
this.updateJumpButtons();
}

View File

@@ -91,7 +91,7 @@ public class InventoryUtil {
if (closestSlot.isPresent() && client.player != null) {
var slot = closestSlot.get().getLeft();
if (slot.hasStack() || !client.player.getInventory().getMainHandStack().isEmpty()) {
if (slot.hasStack() || !client.player.getInventory().getSelectedStack().isEmpty()) {
int slotCenterXScaled = guiLeft + slot.x + 8;
int slotCenterYScaled = guiTop + slot.y + 8;
int slotCenterX = (int) (slotCenterXScaled / ((double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth()));

View File

@@ -13,6 +13,7 @@
"GameOptionsScreenMixin",
"GameRendererMixin",
"HandledScreenMixin",
"InputAccessor",
"InputUtilMixin",
"KeyBindingIDAccessor",
"KeyBindingMixin",

View File

@@ -1,10 +1,9 @@
package eu.midnightdust.midnightcontrols.fabric.event;
import eu.midnightdust.midnightcontrols.client.gui.VirtualKeyboardScreen;
import eu.midnightdust.midnightcontrols.client.gui.virtualkeyboard.VirtualKeyboardScreen;
import eu.midnightdust.midnightcontrols.client.mixin.AbstractSignEditScreenAccessor;
import eu.midnightdust.midnightcontrols.client.mixin.BookEditScreenAccessor;
import eu.midnightdust.midnightcontrols.client.mixin.CreativeInventoryScreenAccessor;
import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents;
import net.minecraft.block.entity.SignText;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.ParentElement;
import net.minecraft.client.gui.screen.ChatScreen;
@@ -18,7 +17,6 @@ import org.lwjgl.glfw.GLFW;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static eu.midnightdust.midnightcontrols.MidnightControls.logger;
import static eu.midnightdust.midnightcontrols.client.MidnightControlsClient.client;
@@ -89,14 +87,14 @@ public class MouseClickListener implements ScreenMouseEvents.AllowMouseClick {
virtualKeyboardScreen = new VirtualKeyboardScreen(accessor.midnightcontrols$getTitle(), (text) -> {
client.setScreen(bookEditScreen);
accessor.midnightcontrols$setTitle(text);
});
}, true);
}
else {
virtualKeyboardScreen = new VirtualKeyboardScreen(accessor.midnightcontrols$getCurrentPageContent(), (text) -> {
client.setScreen(bookEditScreen);
accessor.midnightcontrols$setPageContent(text);
accessor.midnightcontrols$getCurrentPageSelectionManager().putCursorAtEnd();
});
}, true);
}
client.setScreen(virtualKeyboardScreen);
@@ -109,7 +107,7 @@ public class MouseClickListener implements ScreenMouseEvents.AllowMouseClick {
private void handleTextFieldClick(TextFieldWidget textField) {
this.link = new ScreenLink(screen, calculatePathToElement(screen, textField));
var virtualKeyboardScreen = new VirtualKeyboardScreen(textField.getText(), this::handleKeyboardClose);
var virtualKeyboardScreen = new VirtualKeyboardScreen(textField.getText(), this::handleKeyboardClose, false);
client.setScreen(virtualKeyboardScreen);
}
@@ -126,7 +124,6 @@ public class MouseClickListener implements ScreenMouseEvents.AllowMouseClick {
txtField.setText(newText);
switch (this.link.screen()) {
case CreativeInventoryScreen creativeInventoryScreen -> {
var accessor = (CreativeInventoryScreenAccessor) creativeInventoryScreen;

View File

@@ -2,32 +2,32 @@
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048M
minecraft_version=1.21.4
minecraft_version=1.21.5
supported_versions=
yarn_mappings=1.21.4+build.1
yarn_mappings=1.21.5+build.1
enabled_platforms=fabric,neoforge
archives_base_name=midnightcontrols
mod_version=1.10.5
mod_version=1.10.6
maven_group=eu.midnightdust
release_type=release
modrinth_id = bXX9h73M
curseforge_id = 621768
# Configure the IDs here after creating the projects on the websites
midnightlib_version=1.6.8+1.21.4
midnightlib_version=1.7.0+1.21.4
fabric_loader_version=0.16.9
fabric_api_version=0.110.5+1.21.4
fabric_loader_version=0.16.10
fabric_api_version=0.119.5+1.21.5
neoforge_version=21.4.9-beta
neoforge_version=21.5.2-beta
yarn_mappings_patch_neoforge_version = 1.21+build.4
quilt_loader_version=0.19.0-beta.18
quilt_fabric_api_version=7.0.1+0.83.0-1.20
sodium_version=mc1.21-0.6.0-beta.1
obsidianui_version=0.2.10+mc1.21.3
obsidianui_version=0.2.11+mc1.21.5
modmenu_version=10.0.0-beta.1
emotecraft_version=2.5.5+1.21.4-fabric
bendylib_version=2.0.+

Binary file not shown.

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

10
gradlew vendored
View File

@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -200,10 +202,10 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

186
gradlew.bat vendored
View File

@@ -1,92 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega