Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ repositories {
url "https://maven.ladysnake.org/releases"
}

// QuiltMC Parsers
maven { url "https://maven.quiltmc.org/repository/release" }

// IsXander Libraries
maven { url "https://maven.isxander.dev/releases" }

// Datasync
maven {
url "https://maven.uuid.gg/releases"
name "Datasync"
Expand Down Expand Up @@ -92,6 +99,17 @@ dependencies {
modImplementation "maven.modrinth:iris:${iris_version}-fabric"
modRuntimeOnly("org.anarres:jcpp:${jcpp_version}")
modImplementation("io.github.douira:glsl-transformer:${glslTransformer_version}")

// Controlify Compat
modRuntimeOnly "dev.isxander:libsdl4j:${sdl13Target}-${sdl134jBuild}"
modRuntimeOnly "dev.isxander:steamdeck4j:${steamdeck4j_version}"

modRuntimeOnly "maven.modrinth:cloth-config:${cloth_config_version}"
modRuntimeOnly "org.hid4java:hid4java:0.8.0"
modRuntimeOnly "org.quiltmc.parsers:gson:0.3.1"

modImplementation "maven.modrinth:yacl:${yet_another_config_lib_version}-fabric"
modImplementation "maven.modrinth:controlify:${controlify_version}-fabric,1.21.1"
}

processResources {
Expand Down
8 changes: 7 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ midnightlib_version = 1.5.7-fabric
voicechat_api_version=2.6.0
voicechat_version=1.21.1-2.6.4
sodium_version=mc1.21.1-0.6.13
sdl13Target=3.2.18.release-3.2.18
sdl134jBuild=79
steamdeck4j_version=1.1.7
cloth_config_version=15.0.140+fabric
yet_another_config_lib_version=3.8.0+1.21.1
controlify_version=2.4.3
iris_version=1.8.8+1.21.1
jcpp_version= 1.4.14
jcpp_version=1.4.14
glslTransformer_version= 3.0.0-pre3
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dev.doctor4t.trainmurdermystery.client.compat;

import dev.doctor4t.trainmurdermystery.client.gui.screen.ingame.LimitedInventoryScreen;
import dev.isxander.controlify.screenop.ScreenProcessor;
import dev.isxander.controlify.virtualmouse.VirtualMouseBehaviour;

public class LimitedInventoryScreenProcessor extends ScreenProcessor<LimitedInventoryScreen> {
public LimitedInventoryScreenProcessor(LimitedInventoryScreen screen) {
super(screen);
}

@Override
public VirtualMouseBehaviour virtualMouseBehaviour() {
return VirtualMouseBehaviour.ENABLED;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dev.doctor4t.trainmurdermystery.compat.controlify;

import dev.doctor4t.trainmurdermystery.client.compat.LimitedInventoryScreenProcessor;
import dev.doctor4t.trainmurdermystery.client.gui.screen.ingame.LimitedInventoryScreen;
import dev.isxander.controlify.api.ControlifyApi;
import dev.isxander.controlify.api.entrypoint.ControlifyEntrypoint;
import dev.isxander.controlify.api.entrypoint.InitContext;
import dev.isxander.controlify.api.entrypoint.PreInitContext;
import dev.isxander.controlify.screenop.ScreenProcessorProvider;

public class ControlifyCompat implements ControlifyEntrypoint {
@Override
public void onControllersDiscovered(ControlifyApi controlifyApi) {

}

@Override
public void onControlifyInit(InitContext initContext) {

}

@Override
public void onControlifyPreInit(PreInitContext preInitContext) {
ScreenProcessorProvider.registerProvider(
LimitedInventoryScreen.class,
LimitedInventoryScreenProcessor::new
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,35 @@
import dev.doctor4t.trainmurdermystery.client.gui.screen.ingame.LimitedInventoryScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.network.ClientPlayerEntity;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(MinecraftClient.class)
public abstract class MinecraftClientMixin {
@Shadow
@Nullable
public ClientPlayerEntity player;

@WrapOperation(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;setScreen(Lnet/minecraft/client/gui/screen/Screen;)V", ordinal = 1))
private void tmm$replaceInventoryScreenWithLimitedInventoryScreen(MinecraftClient instance, Screen screen, Operation<Void> original) {
if (TMMClient.gameComponent.getFade() > 0) {
return;
}
@Shadow
public void setScreen(Screen screen) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abstract

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we need this? I know it used to be needed for older versions of Mixin but I don't know why we need it now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shadowed method should be abstract to avoid the need to add a method body.


original.call(instance, TMMClient.isPlayerAliveAndInSurvival() ? new LimitedInventoryScreen(this.player) : screen);
@Inject(method = "setScreen(Lnet/minecraft/client/gui/screen/Screen;)V", at = @At("HEAD"), cancellable = true)
private void tmm$redirectInventorySetScreen(Screen screen, CallbackInfo info) {
if (screen instanceof InventoryScreen && TMMClient.isPlayerAliveAndInSurvival()) {
if (TMMClient.gameComponent.getFade() > 0) {
return;
}

if (this.player != null) {
this.setScreen(new LimitedInventoryScreen(this.player));
info.cancel();
}
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
],
"voicechat": [
"dev.doctor4t.trainmurdermystery.compat.TrainVoicePlugin"
],
"controlify": [
"dev.doctor4t.trainmurdermystery.compat.controlify.ControlifyCompat"
]
},
"mixins": [
Expand Down