-
Notifications
You must be signed in to change notification settings - Fork 80
Controlify Compatability fix #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c6e4df5
a74eaac
a7e5a04
0cdf05a
96b240d
148129a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
|---|---|---|
|
|
@@ -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) {} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()) { | ||
kaleidoscopikatt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (TMMClient.gameComponent.getFade() > 0) { | ||
| return; | ||
| } | ||
|
|
||
| if (this.player != null) { | ||
| this.setScreen(new LimitedInventoryScreen(this.player)); | ||
| info.cancel(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.