mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-14 07:35:10 +01:00
✨ Add touchscreen support but still WIP.
This commit is contained in:
@@ -11,8 +11,13 @@ package me.lambdaurora.lambdacontrols.mixin;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.ControlsMode;
|
||||
import me.lambdaurora.lambdacontrols.LambdaControls;
|
||||
import me.lambdaurora.lambdacontrols.gui.TouchscreenOverlay;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.Window;
|
||||
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;
|
||||
@@ -20,6 +25,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(MinecraftClient.class)
|
||||
public abstract class MinecraftClientMixin
|
||||
{
|
||||
@Shadow
|
||||
public Window window;
|
||||
|
||||
@Shadow
|
||||
public boolean skipGameRender;
|
||||
|
||||
@Shadow public Screen currentScreen;
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
private void on_init(CallbackInfo ci)
|
||||
{
|
||||
@@ -32,4 +45,16 @@ public abstract class MinecraftClientMixin
|
||||
if (LambdaControls.get().config.get_controls_mode() == ControlsMode.CONTROLLER)
|
||||
LambdaControls.get().on_tick((MinecraftClient) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "openScreen", at = @At("RETURN"))
|
||||
private void on_open_screen(@Nullable Screen screen, CallbackInfo ci)
|
||||
{
|
||||
LambdaControls mod = LambdaControls.get();
|
||||
if (screen == null && mod.config.get_controls_mode() == ControlsMode.TOUCHSCREEN) {
|
||||
screen = new TouchscreenOverlay(mod);
|
||||
screen.init(((MinecraftClient) (Object) this), this.window.getScaledWidth(), this.window.getScaledHeight());
|
||||
this.skipGameRender = false;
|
||||
this.currentScreen = screen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user