mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 23:25:10 +01:00
Compare commits
7 Commits
architectu
...
architectu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f004f0a32d | ||
|
|
c07f3d94dd | ||
|
|
6007ef315d | ||
|
|
1c26eeed5e | ||
|
|
e35850c5d5 | ||
|
|
78900ac83e | ||
|
|
7d791fac89 |
@@ -39,7 +39,7 @@ dependencies {
|
|||||||
modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0"
|
modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0"
|
||||||
modImplementation "maven.modrinth:sodium:${project.sodium_version}-fabric"
|
modImplementation "maven.modrinth:sodium:${project.sodium_version}-fabric"
|
||||||
modCompileOnlyApi "maven.modrinth:emi:${project.emi_version}"
|
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 "io.github.kosmx:bendy-lib:${project.bendylib_version}"
|
||||||
modCompileOnlyApi "dev.isxander:yet-another-config-lib:${project.yacl_version}"
|
modCompileOnlyApi "dev.isxander:yet-another-config-lib:${project.yacl_version}"
|
||||||
modCompileOnlyApi "maven.modrinth:inventory-tabs-updated:${project.inventorytabs_version}"
|
modCompileOnlyApi "maven.modrinth:inventory-tabs-updated:${project.inventorytabs_version}"
|
||||||
|
|||||||
@@ -86,13 +86,17 @@ public class MidnightControlsClient extends MidnightControls {
|
|||||||
int period = 1; // repeat every 0.001 sec. (1000 times a second)
|
int period = 1; // repeat every 0.001 sec. (1000 times a second)
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
timer.scheduleAtFixedRate(new TimerTask() {
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
public void run() { // TODO: Add a try/catch here after the alpha testing period
|
public void run() {
|
||||||
|
try {
|
||||||
if (lateInitDone && client.isRunning()) {
|
if (lateInitDone && client.isRunning()) {
|
||||||
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput)) {
|
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput)) {
|
||||||
input.tickCameraStick();
|
input.tickCameraStick();
|
||||||
input.updateCamera();
|
input.updateCamera();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception | Error e) {
|
||||||
|
MidnightControls.logger.error("Exception encountered in camera loop: ",e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, delay, period);
|
}, delay, period);
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +1,51 @@
|
|||||||
package eu.midnightdust.midnightcontrols.client.compat;
|
package eu.midnightdust.midnightcontrols.client.compat;
|
||||||
|
|
||||||
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
|
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
|
||||||
import io.github.kosmx.emotes.arch.gui.EmoteMenuImpl;
|
import eu.midnightdust.midnightcontrols.client.mixin.MouseAccessor;
|
||||||
import io.github.kosmx.emotes.arch.gui.screen.ingame.FastChosseScreen;
|
import io.github.kosmx.emotes.arch.screen.ingame.FastMenuScreen;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import org.joml.Vector2i;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public class EmotecraftCompat {
|
public class EmotecraftCompat {
|
||||||
private static final MinecraftClient client = MinecraftClient.getInstance();
|
private static final MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
public static void openEmotecraftScreen(Screen parent) {
|
public static void openEmotecraftScreen(Screen parent) {
|
||||||
client.setScreen(new EmoteMenuImpl(parent));
|
client.setScreen(new FastMenuScreen(parent));
|
||||||
}
|
}
|
||||||
public static boolean isEmotecraftScreen(Screen screen) {
|
public static boolean isEmotecraftScreen(Screen screen) {
|
||||||
return screen instanceof FastChosseScreen;
|
return screen instanceof FastMenuScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int prevIndex = -1;
|
||||||
public static void handleEmoteSelector(int index) {
|
public static void handleEmoteSelector(int index) {
|
||||||
if (client.currentScreen instanceof FastChosseScreen) {
|
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);
|
||||||
|
|
||||||
|
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 x = client.getWindow().getWidth() / 2;
|
||||||
int y = client.getWindow().getHeight() / 2;
|
int y = client.getWindow().getHeight() / 2;
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0, 3, 5 -> x -= 200;
|
case 0, 3, 5 -> x -= 275;
|
||||||
case 2, 4, 7 -> x += 200;
|
case 2, 4, 7 -> x += 275;
|
||||||
}
|
}
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0, 1, 2 -> y -= 200;
|
case 0, 1, 2 -> y -= 275;
|
||||||
case 5, 6, 7 -> y += 200;
|
case 5, 6, 7 -> y += 275;
|
||||||
}
|
|
||||||
InputManager.queueMousePosition(x, y);
|
|
||||||
|
|
||||||
InputManager.INPUT_MANAGER.updateMousePosition(client);
|
|
||||||
}
|
}
|
||||||
|
return new Vector2i(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import eu.midnightdust.midnightcontrols.client.util.MathUtil;
|
|||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
import net.minecraft.entity.attribute.EntityAttributes;
|
import net.minecraft.entity.attribute.EntityAttributes;
|
||||||
|
import net.minecraft.util.PlayerInput;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -48,11 +49,8 @@ public final class MovementHandler implements PressAction {
|
|||||||
public void applyMovement(@NotNull ClientPlayerEntity player) {
|
public void applyMovement(@NotNull ClientPlayerEntity player) {
|
||||||
if (!this.shouldOverrideMovement)
|
if (!this.shouldOverrideMovement)
|
||||||
return;
|
return;
|
||||||
// TODO
|
player.input.playerInput = new PlayerInput(this.pressingForward, this.pressingBack, this.pressingLeft, this.pressingRight,
|
||||||
// player.input.playerInput.pressingForward = this.pressingForward;
|
player.input.playerInput.jump(), player.input.playerInput.sneak(), player.input.playerInput.sprint());
|
||||||
// player.input.pressingBack = this.pressingBack;
|
|
||||||
// player.input.pressingLeft = this.pressingLeft;
|
|
||||||
// player.input.pressingRight = this.pressingRight;
|
|
||||||
|
|
||||||
polarUtil.calculate(this.movementSideways, this.movementForward, this.slowdownFactor);
|
polarUtil.calculate(this.movementSideways, this.movementForward, this.slowdownFactor);
|
||||||
player.input.movementForward = polarUtil.polarY;
|
player.input.movementForward = polarUtil.polarY;
|
||||||
|
|||||||
@@ -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) {
|
public void onInputUpdate(CallbackInfo ci) {
|
||||||
MovementHandler.HANDLER.applyMovement((ClientPlayerEntity) (Object) this);
|
MovementHandler.HANDLER.applyMovement((ClientPlayerEntity) (Object) this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,17 +33,24 @@ import static eu.midnightdust.midnightcontrols.MidnightControls.id;
|
|||||||
@Mixin(GameOptionsScreen.class)
|
@Mixin(GameOptionsScreen.class)
|
||||||
public abstract class GameOptionsScreenMixin extends Screen {
|
public abstract class GameOptionsScreenMixin extends Screen {
|
||||||
@Shadow @Nullable protected OptionListWidget body;
|
@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();
|
.dimension(20,20).texture(id("icon/controller"), 20, 20).build();
|
||||||
|
|
||||||
protected GameOptionsScreenMixin(Text title) {
|
protected GameOptionsScreenMixin(Text title) {
|
||||||
super(title);
|
super(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "init", at = @At("TAIL"))
|
@Inject(method = "initBody", at = @At("TAIL"))
|
||||||
public void midnightcontrols$addMCButton(CallbackInfo ci) {
|
public void midnightcontrols$addMCButton(CallbackInfo ci) {
|
||||||
if (this.getClass().toString().equals(ControlsOptionsScreen.class.toString())) {
|
if (this.getClass().toString().equals(ControlsOptionsScreen.class.toString())) {
|
||||||
this.midnightcontrols$setButtonPos();
|
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);
|
this.addDrawableChild(midnightcontrols$button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ unifiedPublishing {
|
|||||||
curseforge {
|
curseforge {
|
||||||
token = CURSEFORGE_TOKEN
|
token = CURSEFORGE_TOKEN
|
||||||
id = rootProject.curseforge_id
|
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
|
token = MODRINTH_TOKEN
|
||||||
id = rootProject.modrinth_id
|
id = rootProject.modrinth_id
|
||||||
version = "$project.version-$project.name"
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,25 +2,25 @@
|
|||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
org.gradle.jvmargs=-Xmx2048M
|
org.gradle.jvmargs=-Xmx2048M
|
||||||
|
|
||||||
minecraft_version=1.21.3
|
minecraft_version=1.21.4
|
||||||
supported_versions=1.21.2
|
supported_versions=
|
||||||
yarn_mappings=1.21.3+build.2
|
yarn_mappings=1.21.4+build.1
|
||||||
enabled_platforms=fabric,neoforge
|
enabled_platforms=fabric,neoforge
|
||||||
|
|
||||||
archives_base_name=midnightcontrols
|
archives_base_name=midnightcontrols
|
||||||
mod_version=1.10.1
|
mod_version=1.10.5
|
||||||
maven_group=eu.midnightdust
|
maven_group=eu.midnightdust
|
||||||
release_type=beta
|
release_type=release
|
||||||
modrinth_id = bXX9h73M
|
modrinth_id = bXX9h73M
|
||||||
curseforge_id = 621768
|
curseforge_id = 621768
|
||||||
# Configure the IDs here after creating the projects on the websites
|
# 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_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
|
yarn_mappings_patch_neoforge_version = 1.21+build.4
|
||||||
|
|
||||||
quilt_loader_version=0.19.0-beta.18
|
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
|
sodium_version=mc1.21-0.6.0-beta.1
|
||||||
obsidianui_version=0.2.10+mc1.21.3
|
obsidianui_version=0.2.10+mc1.21.3
|
||||||
modmenu_version=10.0.0-beta.1
|
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.+
|
bendylib_version=2.0.+
|
||||||
emi_version=1.1.10+1.21+fabric
|
emi_version=1.1.10+1.21+fabric
|
||||||
libgui_version=6.0.0+1.19
|
libgui_version=6.0.0+1.19
|
||||||
|
|||||||
@@ -104,7 +104,8 @@ unifiedPublishing {
|
|||||||
curseforge {
|
curseforge {
|
||||||
token = CURSEFORGE_TOKEN
|
token = CURSEFORGE_TOKEN
|
||||||
id = rootProject.curseforge_id
|
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
|
token = MODRINTH_TOKEN
|
||||||
id = rootProject.modrinth_id
|
id = rootProject.modrinth_id
|
||||||
version = "$project.version-$project.name"
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user