mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-30 21:05:56 -05:00
Contains the following changes: - Explicitly add `remap=true` to fix mixin failing in prod (#172) - @Redirect workaround for closing #152 (#154) Co-authored-by: shedaniel <daniel@shedaniel.me> Co-authored-by: Mitchell Skaggs <skaggsm333@gmail.com> Signed-off-by: Max <maxh2709@gmail.com>
This commit is contained in:
@@ -35,15 +35,6 @@ public interface ScreenInputDelegate {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseDragged(double d, double e, int i, double f, double g) {
|
||||
if (ClientScreenInputEvent.MOUSE_DRAGGED_PRE.invoker().mouseDragged(Minecraft.getInstance(), parent, d, e, i, f, g).isPresent())
|
||||
return true;
|
||||
if (parent.mouseDragged(d, e, i, f, g))
|
||||
return true;
|
||||
return ClientScreenInputEvent.MOUSE_DRAGGED_POST.invoker().mouseDragged(Minecraft.getInstance(), parent, d, e, i, f, g).isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char c, int i) {
|
||||
if (ClientScreenInputEvent.CHAR_TYPED_PRE.invoker().charTyped(Minecraft.getInstance(), parent, c, i).isPresent())
|
||||
|
||||
@@ -21,7 +21,6 @@ package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import dev.architectury.event.events.client.ClientRawInputEvent;
|
||||
import dev.architectury.event.events.client.ClientScreenInputEvent;
|
||||
import dev.architectury.impl.fabric.ScreenInputDelegate;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
@@ -30,7 +29,7 @@ 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.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@@ -153,11 +152,19 @@ public class MixinMouseHandler {
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@ModifyVariable(method = {"method_1602", "lambda$onMove$11"}, at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private Screen wrapMouseDragged(Screen screen) {
|
||||
if (screen instanceof ScreenInputDelegate delegate) {
|
||||
return delegate.architectury_delegateInputs();
|
||||
@Inject(method = {"method_1602", "lambda$onMove$11"}, at = @At("HEAD"), cancellable = true, remap = false)
|
||||
private void onGuiMouseDraggedPre(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY, CallbackInfo ci) {
|
||||
if (ClientScreenInputEvent.MOUSE_DRAGGED_PRE.invoker().mouseDragged(Minecraft.getInstance(), screen, mouseX, mouseY, this.activeButton, deltaX, deltaY).isPresent()) {
|
||||
ci.cancel();
|
||||
}
|
||||
return screen;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnresolvedMixinReference", "DefaultAnnotationParam"})
|
||||
@Redirect(method = {"method_1602", "lambda$onMove$11"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;mouseDragged(DDIDD)Z", remap = true), remap = false)
|
||||
private boolean onGuiMouseDraggedPost(Screen screen, double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||
if (screen.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) {
|
||||
return true;
|
||||
}
|
||||
return ClientScreenInputEvent.MOUSE_DRAGGED_POST.invoker().mouseDragged(Minecraft.getInstance(), screen, mouseX, mouseY, button, deltaX, deltaY).isPresent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user