Skip to content

Commit 24d169b

Browse files
committed
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
1 parent c0af00f commit 24d169b

9 files changed

Lines changed: 50 additions & 32 deletions

File tree

common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies {
3737
// Compatibility mods
3838
modCompileOnlyApi "io.github.cottonmc:LibGui:${project.libgui_version}"
3939
modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0"
40-
modCompileOnly "maven.modrinth:sodium:${project.sodium_version}"
40+
modImplementation "maven.modrinth:sodium:${project.sodium_version}-fabric"
4141
modCompileOnlyApi "maven.modrinth:emi:${project.emi_version}"
4242
modCompileOnlyApi "maven.modrinth:emotecraft:${project.emotecraft_version}"
4343
modCompileOnlyApi "io.github.kosmx:bendy-lib:${project.bendylib_version}"

common/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightControlsClient.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static void initClient() {
8888
timer.scheduleAtFixedRate(new TimerTask() {
8989
public void run() { // TODO: Add a try/catch here after the alpha testing period
9090
if (lateInitDone && client.isRunning()) {
91-
input.tickJoysticks();
91+
input.tickCameraStick();
9292
input.updateCamera();
9393
}
9494
}
@@ -145,11 +145,11 @@ public static void initKeybindings() {
145145
if (!keyBinding.getTranslationKey().contains(MidnightControlsConstants.NAMESPACE)) {
146146
AtomicReference<ButtonCategory> category = new AtomicReference<>();
147147
InputManager.streamCategories().forEach(buttonCategory -> {
148-
if (buttonCategory.getIdentifier().equals(Identifier.ofVanilla(keyBinding.getCategory())))
148+
if (buttonCategory.getIdentifier().equals(validVanillaId(keyBinding.getCategory())))
149149
category.set(buttonCategory);
150150
});
151151
if (category.get() == null) {
152-
category.set(new ButtonCategory(Identifier.ofVanilla(keyBinding.getCategory())));
152+
category.set(new ButtonCategory(validVanillaId(keyBinding.getCategory())));
153153
InputManager.registerCategory(category.get());
154154
}
155155
ButtonBinding buttonBinding = new ButtonBinding.Builder(keyBinding.getTranslationKey()).category(category.get()).linkKeybind(keyBinding).register();
@@ -163,6 +163,14 @@ public static void initKeybindings() {
163163
InputManager.loadButtonBindings();
164164
lateInitDone = true;
165165
}
166+
private static Identifier validVanillaId(String path) {
167+
for(int i = 0; i < path.length(); ++i) {
168+
if (!Identifier.isPathCharacterValid(path.charAt(i))) {
169+
path = path.replace(path.charAt(i), '_');
170+
}
171+
}
172+
return Identifier.ofVanilla(path);
173+
}
166174

167175
/**
168176
* This method is called every Minecraft tick.

common/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightControlsConfig.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,10 @@ public class MidnightControlsConfig extends MidnightConfig {
112112
@Entry @Hidden public static Map<String, String> BINDING = new HashMap<>();
113113

114114
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
115-
@Deprecated @Hidden @Entry public static double[] maxAnalogValues = new double[]{1, 1, 1, 1};
116-
@Entry(category = CONTROLLER, name = "Max analog value: Left X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftX = maxAnalogValues[0];
117-
@Entry(category = CONTROLLER, name = "Max analog value: Left Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftY = maxAnalogValues[1];
118-
@Entry(category = CONTROLLER, name = "Max analog value: Right X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightX = maxAnalogValues[2];
119-
@Entry(category = CONTROLLER, name = "Max analog value: Right Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightY = maxAnalogValues[3];
115+
@Entry(category = CONTROLLER, name = "Max analog value: Left X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftX = 1;
116+
@Entry(category = CONTROLLER, name = "Max analog value: Left Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftY = 1;
117+
@Entry(category = CONTROLLER, name = "Max analog value: Right X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightX = 1;
118+
@Entry(category = CONTROLLER, name = "Max analog value: Right Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightY = 1;
120119
@Entry(category = CONTROLLER, name = "Trigger button fix") public static boolean triggerFix = true;
121120
@Entry(category = CONTROLLER, name = "Excluded Controllers (Name Regex)") public static List<String> excludedControllers = Lists.newArrayList(".*(Keyboard)$", ".*(Touchpad)$", ".*(Pen)$", ".*(Finger)$");
122121
@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",

common/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightInput.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,14 @@ public void tickController() {
144144
var state = controller.getState();
145145
this.fetchButtonInput(state, false);
146146
this.fetchTriggerInput(state, false);
147+
this.fetchJoystickInput(state, false, false);
147148
}
148149
MidnightControlsConfig.getSecondController().filter(Controller::isConnected)
149150
.ifPresent(joycon -> {
150151
var state = joycon.getState();
151152
this.fetchButtonInput(state, true);
152153
this.fetchTriggerInput(state, true);
154+
this.fetchJoystickInput(state, true, false);
153155
});
154156

155157
boolean allowInput = this.controlsInput == null || this.controlsInput.focusedBinding == null;
@@ -177,18 +179,16 @@ public void tickController() {
177179
this.inventoryInteractionCooldown--;
178180
}
179181
/**
180-
* This method is called 1000 times a second for smooth joystick input
182+
* This method is called 1000 times a second for smooth camera input
181183
*/
182-
public void tickJoysticks() {
184+
public void tickCameraStick() {
183185
var controller = MidnightControlsConfig.getController();
184186

185187
if (controller.isConnected()) {
186-
this.fetchJoystickInput(controller.getState(), false);
188+
this.fetchJoystickInput(controller.getState(), false, true);
187189
}
188190
MidnightControlsConfig.getSecondController().filter(Controller::isConnected)
189-
.ifPresent(joycon -> {
190-
this.fetchJoystickInput(joycon.getState(), true);
191-
});
191+
.ifPresent(joycon -> this.fetchJoystickInput(joycon.getState(), true, true));
192192
}
193193

194194
/**
@@ -278,7 +278,7 @@ private void fetchButtonInput(@NotNull GLFWGamepadState gamepadState, boolean le
278278
}
279279
final MathUtil.PolarUtil polarUtil = new MathUtil.PolarUtil();
280280

281-
private void fetchJoystickInput(@NotNull GLFWGamepadState gamepadState, boolean leftJoycon) {
281+
private void fetchJoystickInput(@NotNull GLFWGamepadState gamepadState, boolean leftJoycon, boolean cameraTick) {
282282
var buffer = gamepadState.axes();
283283

284284
polarUtil.calculate(buffer.get(GLFW_GAMEPAD_AXIS_LEFT_X), buffer.get(GLFW_GAMEPAD_AXIS_LEFT_Y), 1, MidnightControlsConfig.leftDeadZone);
@@ -291,7 +291,7 @@ private void fetchJoystickInput(@NotNull GLFWGamepadState gamepadState, boolean
291291
boolean isRadialMenu = client.currentScreen instanceof RingScreen || (PlatformFunctions.isModLoaded("emotecraft") && EmotecraftCompat.isEmotecraftScreen(client.currentScreen));
292292

293293
if (!isRadialMenu) {
294-
for (int i = 0; i < GLFW_GAMEPAD_AXIS_LEFT_TRIGGER; i++) {
294+
for (int i = cameraTick ? GLFW_GAMEPAD_AXIS_RIGHT_X : 0; i < (cameraTick ? GLFW_GAMEPAD_AXIS_LEFT_TRIGGER : GLFW_GAMEPAD_AXIS_RIGHT_X); i++) {
295295
int axis = leftJoycon ? ButtonBinding.controller2Button(i) : i;
296296
float value = buffer.get(i);
297297

@@ -503,21 +503,22 @@ private void handleJoystickMovement(AxisStorage storage) {
503503
axisValue /= (float) (1.0 - storage.deadZone);
504504
axisValue *= (float) storage.deadZone;
505505
}
506-
507506
axisValue = (float) Math.min(axisValue / MidnightControlsConfig.getAxisMaxValue(storage.axis), 1);
508507
if (AxisStorage.isLeftAxis(storage.axis)) MidnightControlsCompat.handleMovement(storage, axisValue);
509-
InputManager.BUTTON_VALUES.put(ButtonBinding.axisAsButton(storage.axis, true), storage.polarity == AxisStorage.Polarity.PLUS ? axisValue : 0.f);
510-
InputManager.BUTTON_VALUES.put(ButtonBinding.axisAsButton(storage.axis, false), storage.polarity == AxisStorage.Polarity.MINUS ? axisValue : 0.f);
508+
InputManager.BUTTON_VALUES.put(storage.getButtonId(true), storage.polarity == AxisStorage.Polarity.PLUS ? axisValue : 0.f);
509+
InputManager.BUTTON_VALUES.put(storage.getButtonId(false), storage.polarity == AxisStorage.Polarity.MINUS ? axisValue : 0.f);
510+
storage.absValue = axisValue;
511511
}
512512

513513
private boolean handleScreenScrolling(Screen screen, AxisStorage storage) {
514+
if (screen == null) return false;
514515
// @TODO allow rebinding to left stick
515516
int preferredAxis = true ? GLFW_GAMEPAD_AXIS_RIGHT_Y : GLFW_GAMEPAD_AXIS_LEFT_Y;
516517

517518
if (this.controlsInput != null && this.controlsInput.focusedBinding != null) {
518-
if (storage.buttonState != ButtonState.NONE && !this.controlsInput.currentButtons.contains(ButtonBinding.axisAsButton(storage.axis, storage.buttonState == ButtonState.PRESS))) {
519+
if (storage.buttonState != ButtonState.NONE && !this.controlsInput.currentButtons.contains(storage.getButtonId(storage.buttonState == ButtonState.PRESS))) {
519520

520-
this.controlsInput.currentButtons.add(ButtonBinding.axisAsButton(storage.axis, storage.buttonState == ButtonState.PRESS));
521+
this.controlsInput.currentButtons.add(storage.getButtonId(storage.buttonState == ButtonState.PRESS));
521522

522523
int[] buttons = new int[this.controlsInput.currentButtons.size()];
523524
for (int i = 0; i < this.controlsInput.currentButtons.size(); i++)

common/src/main/java/eu/midnightdust/midnightcontrols/client/compat/SodiumCompat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package eu.midnightdust.midnightcontrols.client.compat;
22

33
import eu.midnightdust.midnightcontrols.client.compat.mixin.sodium.SodiumOptionsGUIAccessor;
4-
import me.jellysquid.mods.sodium.client.gui.SodiumOptionsGUI;
4+
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
55
import net.minecraft.client.gui.screen.Screen;
66

77
public class SodiumCompat implements CompatHandler {

common/src/main/java/eu/midnightdust/midnightcontrols/client/compat/mixin/sodium/SodiumOptionsGUIAccessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package eu.midnightdust.midnightcontrols.client.compat.mixin.sodium;
22

3-
import me.jellysquid.mods.sodium.client.gui.SodiumOptionsGUI;
4-
import me.jellysquid.mods.sodium.client.gui.options.OptionPage;
5-
import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement;
3+
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
4+
import net.caffeinemc.mods.sodium.client.gui.options.OptionPage;
5+
import net.caffeinemc.mods.sodium.client.gui.options.control.ControlElement;
66
import org.spongepowered.asm.mixin.Mixin;
77
import org.spongepowered.asm.mixin.gen.Accessor;
88

common/src/main/java/eu/midnightdust/midnightcontrols/client/util/storage/AxisStorage.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,19 @@ else if (!MidnightControlsConfig.analogMovement && isLeftAxis(axis)) {
5858
}
5959
this.polarity = currentPlusState ? AxisStorage.Polarity.PLUS : currentMinusState ? AxisStorage.Polarity.MINUS : AxisStorage.Polarity.ZERO;
6060
}
61+
/**
62+
* Returns the specified axis as a button.
63+
*
64+
* @param positive true if the axis part is positive, else false
65+
* @return the axis as a button
66+
*/
67+
public int getButtonId(boolean positive) {
68+
return ButtonBinding.axisAsButton(axis, positive);
69+
}
6170

6271
public void setupButtonStates() {
63-
var posButton = ButtonBinding.axisAsButton(axis, true);
64-
var negButton = ButtonBinding.axisAsButton(axis, false);
72+
var posButton = getButtonId(true);
73+
var negButton = getButtonId(false);
6574
var previousPlusState = STATES.getOrDefault(posButton, ButtonState.NONE);
6675
var previousMinusState = STATES.getOrDefault(negButton, ButtonState.NONE);
6776

fabric/src/main/resources/fabric.mod.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
},
6262
"breaks": {
6363
"lambdacontrols": "*",
64-
"modmenu": "<1.12.2"
64+
"modmenu": "<1.12.2",
65+
"sodium": "<0.6.0"
6566
}
6667
}

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ yarn_mappings=1.21+build.2
77
enabled_platforms=fabric,neoforge
88

99
archives_base_name=midnightcontrols
10-
mod_version=1.10.0-alpha.1
10+
mod_version=1.10.0-beta.1
1111
maven_group=eu.midnightdust
1212
release_type=release
1313
modrinth_id = bXX9h73M
1414
curseforge_id = 621768
1515
# Configure the IDs here after creating the projects on the websites
1616

17-
midnightlib_version=1.5.7
17+
midnightlib_version=1.6.1
1818

1919
fabric_loader_version=0.15.11
2020
fabric_api_version=0.100.1+1.21
@@ -25,7 +25,7 @@ yarn_mappings_patch_neoforge_version = 1.21+build.4
2525
quilt_loader_version=0.19.0-beta.18
2626
quilt_fabric_api_version=7.0.1+0.83.0-1.20
2727

28-
sodium_version=mc1.21-0.5.11
28+
sodium_version=mc1.21-0.6.0-beta.1
2929
obsidianui_version=0.2.7+mc1.21
3030
modmenu_version=10.0.0-beta.1
3131
emotecraft_version=2.1.3-SNAPSHOT-build.29-MC1.19-fabric

0 commit comments

Comments
 (0)