First Beta for 1.10.0!

- Separate movement and camera joysticks to fix boat movement (again)
- Fixed crashes with various mods
- Compatibility for Sodium 0.6.0
- Updated MidnightLib to 1.6.1
This commit is contained in:
Martin Prokoph
2024-08-30 12:07:23 +02:00
parent c0af00f2a3
commit 24d169b4c2
9 changed files with 50 additions and 32 deletions

View File

@@ -37,7 +37,7 @@ dependencies {
// Compatibility mods
modCompileOnlyApi "io.github.cottonmc:LibGui:${project.libgui_version}"
modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0"
modCompileOnly "maven.modrinth:sodium:${project.sodium_version}"
modImplementation "maven.modrinth:sodium:${project.sodium_version}-fabric"
modCompileOnlyApi "maven.modrinth:emi:${project.emi_version}"
modCompileOnlyApi "maven.modrinth:emotecraft:${project.emotecraft_version}"
modCompileOnlyApi "io.github.kosmx:bendy-lib:${project.bendylib_version}"

View File

@@ -88,7 +88,7 @@ public class MidnightControlsClient extends MidnightControls {
timer.scheduleAtFixedRate(new TimerTask() {
public void run() { // TODO: Add a try/catch here after the alpha testing period
if (lateInitDone && client.isRunning()) {
input.tickJoysticks();
input.tickCameraStick();
input.updateCamera();
}
}
@@ -145,11 +145,11 @@ public class MidnightControlsClient extends MidnightControls {
if (!keyBinding.getTranslationKey().contains(MidnightControlsConstants.NAMESPACE)) {
AtomicReference<ButtonCategory> category = new AtomicReference<>();
InputManager.streamCategories().forEach(buttonCategory -> {
if (buttonCategory.getIdentifier().equals(Identifier.ofVanilla(keyBinding.getCategory())))
if (buttonCategory.getIdentifier().equals(validVanillaId(keyBinding.getCategory())))
category.set(buttonCategory);
});
if (category.get() == null) {
category.set(new ButtonCategory(Identifier.ofVanilla(keyBinding.getCategory())));
category.set(new ButtonCategory(validVanillaId(keyBinding.getCategory())));
InputManager.registerCategory(category.get());
}
ButtonBinding buttonBinding = new ButtonBinding.Builder(keyBinding.getTranslationKey()).category(category.get()).linkKeybind(keyBinding).register();
@@ -163,6 +163,14 @@ public class MidnightControlsClient extends MidnightControls {
InputManager.loadButtonBindings();
lateInitDone = true;
}
private static Identifier validVanillaId(String path) {
for(int i = 0; i < path.length(); ++i) {
if (!Identifier.isPathCharacterValid(path.charAt(i))) {
path = path.replace(path.charAt(i), '_');
}
}
return Identifier.ofVanilla(path);
}
/**
* This method is called every Minecraft tick.

View File

@@ -112,11 +112,10 @@ public class MidnightControlsConfig extends MidnightConfig {
@Entry @Hidden public static Map<String, String> BINDING = new HashMap<>();
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
@Deprecated @Hidden @Entry public static double[] maxAnalogValues = new double[]{1, 1, 1, 1};
@Entry(category = CONTROLLER, name = "Max analog value: Left X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftX = maxAnalogValues[0];
@Entry(category = CONTROLLER, name = "Max analog value: Left Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftY = maxAnalogValues[1];
@Entry(category = CONTROLLER, name = "Max analog value: Right X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightX = maxAnalogValues[2];
@Entry(category = CONTROLLER, name = "Max analog value: Right Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightY = maxAnalogValues[3];
@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;
@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)$");
@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",

View File

@@ -144,12 +144,14 @@ public class MidnightInput {
var state = controller.getState();
this.fetchButtonInput(state, false);
this.fetchTriggerInput(state, false);
this.fetchJoystickInput(state, false, false);
}
MidnightControlsConfig.getSecondController().filter(Controller::isConnected)
.ifPresent(joycon -> {
var state = joycon.getState();
this.fetchButtonInput(state, true);
this.fetchTriggerInput(state, true);
this.fetchJoystickInput(state, true, false);
});
boolean allowInput = this.controlsInput == null || this.controlsInput.focusedBinding == null;
@@ -177,18 +179,16 @@ public class MidnightInput {
this.inventoryInteractionCooldown--;
}
/**
* This method is called 1000 times a second for smooth joystick input
* This method is called 1000 times a second for smooth camera input
*/
public void tickJoysticks() {
public void tickCameraStick() {
var controller = MidnightControlsConfig.getController();
if (controller.isConnected()) {
this.fetchJoystickInput(controller.getState(), false);
this.fetchJoystickInput(controller.getState(), false, true);
}
MidnightControlsConfig.getSecondController().filter(Controller::isConnected)
.ifPresent(joycon -> {
this.fetchJoystickInput(joycon.getState(), true);
});
.ifPresent(joycon -> this.fetchJoystickInput(joycon.getState(), true, true));
}
/**
@@ -278,7 +278,7 @@ public class MidnightInput {
}
final MathUtil.PolarUtil polarUtil = new MathUtil.PolarUtil();
private void fetchJoystickInput(@NotNull GLFWGamepadState gamepadState, boolean leftJoycon) {
private void fetchJoystickInput(@NotNull GLFWGamepadState gamepadState, boolean leftJoycon, boolean cameraTick) {
var buffer = gamepadState.axes();
polarUtil.calculate(buffer.get(GLFW_GAMEPAD_AXIS_LEFT_X), buffer.get(GLFW_GAMEPAD_AXIS_LEFT_Y), 1, MidnightControlsConfig.leftDeadZone);
@@ -291,7 +291,7 @@ public class MidnightInput {
boolean isRadialMenu = client.currentScreen instanceof RingScreen || (PlatformFunctions.isModLoaded("emotecraft") && EmotecraftCompat.isEmotecraftScreen(client.currentScreen));
if (!isRadialMenu) {
for (int i = 0; i < GLFW_GAMEPAD_AXIS_LEFT_TRIGGER; i++) {
for (int i = cameraTick ? GLFW_GAMEPAD_AXIS_RIGHT_X : 0; i < (cameraTick ? GLFW_GAMEPAD_AXIS_LEFT_TRIGGER : GLFW_GAMEPAD_AXIS_RIGHT_X); i++) {
int axis = leftJoycon ? ButtonBinding.controller2Button(i) : i;
float value = buffer.get(i);
@@ -503,21 +503,22 @@ public class MidnightInput {
axisValue /= (float) (1.0 - storage.deadZone);
axisValue *= (float) storage.deadZone;
}
axisValue = (float) Math.min(axisValue / MidnightControlsConfig.getAxisMaxValue(storage.axis), 1);
if (AxisStorage.isLeftAxis(storage.axis)) MidnightControlsCompat.handleMovement(storage, axisValue);
InputManager.BUTTON_VALUES.put(ButtonBinding.axisAsButton(storage.axis, true), storage.polarity == AxisStorage.Polarity.PLUS ? axisValue : 0.f);
InputManager.BUTTON_VALUES.put(ButtonBinding.axisAsButton(storage.axis, false), storage.polarity == AxisStorage.Polarity.MINUS ? axisValue : 0.f);
InputManager.BUTTON_VALUES.put(storage.getButtonId(true), storage.polarity == AxisStorage.Polarity.PLUS ? axisValue : 0.f);
InputManager.BUTTON_VALUES.put(storage.getButtonId(false), storage.polarity == AxisStorage.Polarity.MINUS ? axisValue : 0.f);
storage.absValue = axisValue;
}
private boolean handleScreenScrolling(Screen screen, AxisStorage storage) {
if (screen == null) return false;
// @TODO allow rebinding to left stick
int preferredAxis = true ? GLFW_GAMEPAD_AXIS_RIGHT_Y : GLFW_GAMEPAD_AXIS_LEFT_Y;
if (this.controlsInput != null && this.controlsInput.focusedBinding != null) {
if (storage.buttonState != ButtonState.NONE && !this.controlsInput.currentButtons.contains(ButtonBinding.axisAsButton(storage.axis, storage.buttonState == ButtonState.PRESS))) {
if (storage.buttonState != ButtonState.NONE && !this.controlsInput.currentButtons.contains(storage.getButtonId(storage.buttonState == ButtonState.PRESS))) {
this.controlsInput.currentButtons.add(ButtonBinding.axisAsButton(storage.axis, storage.buttonState == ButtonState.PRESS));
this.controlsInput.currentButtons.add(storage.getButtonId(storage.buttonState == ButtonState.PRESS));
int[] buttons = new int[this.controlsInput.currentButtons.size()];
for (int i = 0; i < this.controlsInput.currentButtons.size(); i++)

View File

@@ -1,7 +1,7 @@
package eu.midnightdust.midnightcontrols.client.compat;
import eu.midnightdust.midnightcontrols.client.compat.mixin.sodium.SodiumOptionsGUIAccessor;
import me.jellysquid.mods.sodium.client.gui.SodiumOptionsGUI;
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
import net.minecraft.client.gui.screen.Screen;
public class SodiumCompat implements CompatHandler {

View File

@@ -1,8 +1,8 @@
package eu.midnightdust.midnightcontrols.client.compat.mixin.sodium;
import me.jellysquid.mods.sodium.client.gui.SodiumOptionsGUI;
import me.jellysquid.mods.sodium.client.gui.options.OptionPage;
import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement;
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
import net.caffeinemc.mods.sodium.client.gui.options.OptionPage;
import net.caffeinemc.mods.sodium.client.gui.options.control.ControlElement;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

View File

@@ -58,10 +58,19 @@ public class AxisStorage {
}
this.polarity = currentPlusState ? AxisStorage.Polarity.PLUS : currentMinusState ? AxisStorage.Polarity.MINUS : AxisStorage.Polarity.ZERO;
}
/**
* Returns the specified axis as a button.
*
* @param positive true if the axis part is positive, else false
* @return the axis as a button
*/
public int getButtonId(boolean positive) {
return ButtonBinding.axisAsButton(axis, positive);
}
public void setupButtonStates() {
var posButton = ButtonBinding.axisAsButton(axis, true);
var negButton = ButtonBinding.axisAsButton(axis, false);
var posButton = getButtonId(true);
var negButton = getButtonId(false);
var previousPlusState = STATES.getOrDefault(posButton, ButtonState.NONE);
var previousMinusState = STATES.getOrDefault(negButton, ButtonState.NONE);