Compare commits

..

7 Commits

Author SHA1 Message Date
Martin Prokoph
f004f0a32d compat: improve/fix Emotecraft compat 2025-03-27 00:00:29 +01:00
Martin Prokoph
c07f3d94dd chore: bump version 2025-03-26 19:54:42 +01:00
Martin Prokoph
6007ef315d fix: controller options button not being clickable 2025-03-26 19:53:31 +01:00
Martin Prokoph
1c26eeed5e fix: catch errors in camera thread
- Solves camera movement breaking entirely when encountering an error
2025-02-15 22:20:29 +01:00
Martin Prokoph
e35850c5d5 Bump version 2024-12-11 18:10:57 +01:00
Martin Prokoph
78900ac83e Fix movement while riding boats and other entities 2024-12-11 18:08:40 +01:00
Martin Prokoph
7d791fac89 Port to 1.21.4
- For once, this has been easy :)
2024-12-06 21:11:39 +01:00
9 changed files with 72 additions and 44 deletions

View File

@@ -39,7 +39,7 @@ dependencies {
modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0"
modImplementation "maven.modrinth:sodium:${project.sodium_version}-fabric"
modCompileOnlyApi "maven.modrinth:emi:${project.emi_version}"
modCompileOnlyApi "maven.modrinth:emotecraft:${project.emotecraft_version}"
modImplementation "maven.modrinth:emotecraft:${project.emotecraft_version}"
modCompileOnlyApi "io.github.kosmx:bendy-lib:${project.bendylib_version}"
modCompileOnlyApi "dev.isxander:yet-another-config-lib:${project.yacl_version}"
modCompileOnlyApi "maven.modrinth:inventory-tabs-updated:${project.inventorytabs_version}"

View File

@@ -86,12 +86,16 @@ public class MidnightControlsClient extends MidnightControls {
int period = 1; // repeat every 0.001 sec. (1000 times a second)
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() { // TODO: Add a try/catch here after the alpha testing period
if (lateInitDone && client.isRunning()) {
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput)) {
input.tickCameraStick();
input.updateCamera();
public void run() {
try {
if (lateInitDone && client.isRunning()) {
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput)) {
input.tickCameraStick();
input.updateCamera();
}
}
} catch (Exception | Error e) {
MidnightControls.logger.error("Exception encountered in camera loop: ",e);
}
}
}, delay, period);

View File

@@ -1,36 +1,51 @@
package eu.midnightdust.midnightcontrols.client.compat;
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
import io.github.kosmx.emotes.arch.gui.EmoteMenuImpl;
import io.github.kosmx.emotes.arch.gui.screen.ingame.FastChosseScreen;
import eu.midnightdust.midnightcontrols.client.mixin.MouseAccessor;
import io.github.kosmx.emotes.arch.screen.ingame.FastMenuScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import org.joml.Vector2i;
import org.lwjgl.glfw.GLFW;
public class EmotecraftCompat {
private static final MinecraftClient client = MinecraftClient.getInstance();
public static void openEmotecraftScreen(Screen parent) {
client.setScreen(new EmoteMenuImpl(parent));
client.setScreen(new FastMenuScreen(parent));
}
public static boolean isEmotecraftScreen(Screen screen) {
return screen instanceof FastChosseScreen;
return screen instanceof FastMenuScreen;
}
static int prevIndex = -1;
public static void handleEmoteSelector(int index) {
if (client.currentScreen instanceof FastChosseScreen) {
int x = client.getWindow().getWidth() / 2;
int y = client.getWindow().getHeight() / 2;
switch (index) {
case 0, 3, 5 -> x -= 200;
case 2, 4, 7 -> x += 200;
}
switch (index) {
case 0, 1, 2 -> y -= 200;
case 5, 6, 7 -> y += 200;
}
InputManager.queueMousePosition(x, y);
try {
if (client.currentScreen instanceof FastMenuScreen) {
boolean stickReleased = index == -1 && prevIndex != -1;
var pos = calcMousePos(stickReleased ? prevIndex : index);
InputManager.queueMousePosition(pos.x, pos.y);
InputManager.INPUT_MANAGER.updateMousePosition(client);
InputManager.INPUT_MANAGER.updateMousePosition(client);
if (stickReleased) {
((MouseAccessor) client.mouse).midnightcontrols$onMouseButton(client.getWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT, GLFW.GLFW_PRESS, 0);
prevIndex = -1;
}
else prevIndex = index;
} else prevIndex = -1;
} catch (Exception ignored) {}
}
public static Vector2i calcMousePos(int index) {
int x = client.getWindow().getWidth() / 2;
int y = client.getWindow().getHeight() / 2;
switch (index) {
case 0, 3, 5 -> x -= 275;
case 2, 4, 7 -> x += 275;
}
switch (index) {
case 0, 1, 2 -> y -= 275;
case 5, 6, 7 -> y += 275;
}
return new Vector2i(x, y);
}
}

View File

@@ -15,6 +15,7 @@ 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 org.jetbrains.annotations.NotNull;
@@ -48,11 +49,8 @@ public final class MovementHandler implements PressAction {
public void applyMovement(@NotNull ClientPlayerEntity player) {
if (!this.shouldOverrideMovement)
return;
// TODO
// player.input.playerInput.pressingForward = this.pressingForward;
// player.input.pressingBack = this.pressingBack;
// player.input.pressingLeft = this.pressingLeft;
// player.input.pressingRight = this.pressingRight;
player.input.playerInput = new PlayerInput(this.pressingForward, this.pressingBack, this.pressingLeft, this.pressingRight,
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;

View File

@@ -77,7 +77,7 @@ public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
}
}
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick(ZF)V", shift = At.Shift.AFTER))
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick()V", shift = At.Shift.AFTER))
public void onInputUpdate(CallbackInfo ci) {
MovementHandler.HANDLER.applyMovement((ClientPlayerEntity) (Object) this);
}

View File

@@ -33,17 +33,24 @@ import static eu.midnightdust.midnightcontrols.MidnightControls.id;
@Mixin(GameOptionsScreen.class)
public abstract class GameOptionsScreenMixin extends Screen {
@Shadow @Nullable protected OptionListWidget body;
@Unique TextIconButtonWidget midnightcontrols$button = TextIconButtonWidget.builder(Text.translatable("midnightcontrols.menu.title.controller"), (button -> this.client.setScreen(new MidnightControlsSettingsScreen(this, false))), true)
@Unique TextIconButtonWidget midnightcontrols$button = TextIconButtonWidget.builder(Text.translatable("midnightcontrols.menu.title.controller"),
(button -> this.client.setScreen(new MidnightControlsSettingsScreen(this, false))), true)
.dimension(20,20).texture(id("icon/controller"), 20, 20).build();
protected GameOptionsScreenMixin(Text title) {
super(title);
}
@Inject(method = "init", at = @At("TAIL"))
@Inject(method = "initBody", at = @At("TAIL"))
public void midnightcontrols$addMCButton(CallbackInfo ci) {
if (this.getClass().toString().equals(ControlsOptionsScreen.class.toString())) {
this.midnightcontrols$setButtonPos();
this.addSelectableChild(midnightcontrols$button);
}
}
@Inject(method = "init", at = @At("TAIL"))
public void midnightcontrols$drawMCButton(CallbackInfo ci) {
if (this.getClass().toString().equals(ControlsOptionsScreen.class.toString())) {
this.addDrawableChild(midnightcontrols$button);
}
}

View File

@@ -92,7 +92,8 @@ unifiedPublishing {
curseforge {
token = CURSEFORGE_TOKEN
id = rootProject.curseforge_id
gameVersions.addAll "Java 21", project.minecraft_version, project.supported_versions
gameVersions.addAll "Java 21", project.minecraft_version
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
}
}
@@ -102,7 +103,8 @@ unifiedPublishing {
token = MODRINTH_TOKEN
id = rootProject.modrinth_id
version = "$project.version-$project.name"
gameVersions.addAll project.minecraft_version, project.supported_versions
gameVersions.addAll project.minecraft_version
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
}
}
}

View File

@@ -2,25 +2,25 @@
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048M
minecraft_version=1.21.3
supported_versions=1.21.2
yarn_mappings=1.21.3+build.2
minecraft_version=1.21.4
supported_versions=
yarn_mappings=1.21.4+build.1
enabled_platforms=fabric,neoforge
archives_base_name=midnightcontrols
mod_version=1.10.1
mod_version=1.10.5
maven_group=eu.midnightdust
release_type=beta
release_type=release
modrinth_id = bXX9h73M
curseforge_id = 621768
# Configure the IDs here after creating the projects on the websites
midnightlib_version=1.6.4
midnightlib_version=1.6.8+1.21.4
fabric_loader_version=0.16.9
fabric_api_version=0.107.3+1.21.3
fabric_api_version=0.110.5+1.21.4
neoforge_version=21.3.28-beta
neoforge_version=21.4.9-beta
yarn_mappings_patch_neoforge_version = 1.21+build.4
quilt_loader_version=0.19.0-beta.18
@@ -29,7 +29,7 @@ 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
modmenu_version=10.0.0-beta.1
emotecraft_version=2.1.3-SNAPSHOT-build.29-MC1.19-fabric
emotecraft_version=2.5.5+1.21.4-fabric
bendylib_version=2.0.+
emi_version=1.1.10+1.21+fabric
libgui_version=6.0.0+1.19

View File

@@ -104,7 +104,8 @@ unifiedPublishing {
curseforge {
token = CURSEFORGE_TOKEN
id = rootProject.curseforge_id
gameVersions.addAll "Java 21", project.minecraft_version, project.supported_versions
gameVersions.addAll "Java 21", project.minecraft_version
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
}
}
@@ -114,7 +115,8 @@ unifiedPublishing {
token = MODRINTH_TOKEN
id = rootProject.modrinth_id
version = "$project.version-$project.name"
gameVersions.addAll project.minecraft_version, project.supported_versions
gameVersions.addAll project.minecraft_version
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
}
}
}