Move Mixins which exist specifically for jGui from RM to jGui repo

This commit is contained in:
Jonas Herzig
2019-05-20 17:09:53 +02:00
parent 1ef4f605d7
commit 3a45147974
9 changed files with 10 additions and 171 deletions

View File

@@ -3,8 +3,6 @@ package com.replaymod.core.mixin;
import com.replaymod.core.events.PostRenderWorldCallback;
import com.replaymod.core.events.PreRenderHandCallback;
import de.johni0702.minecraft.gui.versions.callbacks.PostRenderHudCallback;
import de.johni0702.minecraft.gui.versions.callbacks.PostRenderScreenCallback;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import org.spongepowered.asm.mixin.Mixin;
@@ -14,30 +12,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GameRenderer.class)
public class MixinGameRenderer {
@Inject(
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/hud/InGameHud;draw(F)V",
shift = At.Shift.AFTER
)
)
private void postRenderOverlay(float partialTicks, long nanoTime, boolean renderWorld, CallbackInfo ci) {
PostRenderHudCallback.EVENT.invoker().postRenderHud(partialTicks);
}
@Inject(
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/screen/Screen;render(IIF)V",
shift = At.Shift.AFTER
)
)
private void postRenderScreen(float partialTicks, long nanoTime, boolean renderWorld, CallbackInfo ci) {
PostRenderScreenCallback.EVENT.invoker().postRenderScreen(partialTicks);
}
@Inject(
method = "renderCenter",
at = @At(

View File

@@ -16,46 +16,5 @@ public class MixinKeyboardListener {
KeyBindingEventCallback.EVENT.invoker().onKeybindingEvent();
KeyEventCallback.EVENT.invoker().onKeyEvent(key, scanCode, action, modifiers);
}
//#if MC>=11400
/* FIXME we currently don't use these but they also don't work since their target is wrapped in a lambda,
see MixinMouseListener for working examples
@Redirect(
method = "onKey",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyPressed(III)Z")
)
private boolean keyPressed(ParentElement element, int keyCode, int modifiers, int scanCode) {
if (KeyboardCallback.EVENT.invoker().keyPressed(keyCode, modifiers, scanCode)) {
return true;
} else {
return element.keyPressed(keyCode, modifiers, scanCode);
}
}
@Redirect(
method = "onKey",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyReleased(III)Z")
)
private boolean keyReleased(ParentElement element, int keyCode, int modifiers, int scanCode) {
if (KeyboardCallback.EVENT.invoker().keyReleased(keyCode, modifiers, scanCode)) {
return true;
} else {
return element.keyReleased(keyCode, modifiers, scanCode);
}
}
@Redirect(
method = "onKey",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;charTyped(CI)Z")
)
private boolean charTyped(ParentElement element, char keyChar, int modifiers) {
if (KeyboardCallback.EVENT.invoker().charTyped(keyChar, modifiers)) {
return true;
} else {
return element.charTyped(keyChar, modifiers);
}
}
*/
//#endif
}
//#endif

View File

@@ -9,9 +9,6 @@ import org.spongepowered.asm.mixin.injection.At;
//#if MC>=11300
import com.replaymod.core.events.PostRenderCallback;
import com.replaymod.core.events.PreRenderCallback;
import de.johni0702.minecraft.gui.versions.callbacks.OpenGuiScreenCallback;
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//#else
@@ -65,16 +62,6 @@ public abstract class MixinMinecraft
private void postRender(boolean unused, CallbackInfo ci) {
PostRenderCallback.EVENT.invoker().postRender();
}
@Inject(method = "tick", at = @At("HEAD"))
private void preTick(CallbackInfo ci) {
PreTickCallback.EVENT.invoker().preTick();
}
@Inject(method = "openScreen", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
private void openGuiScreen(Screen newGuiScreen, CallbackInfo ci) {
OpenGuiScreenCallback.EVENT.invoker().openGuiScreen(newGuiScreen);
}
//#else
//#if MC>=10904
//$$ @Shadow protected abstract void runTickKeyboard() throws IOException;

View File

@@ -1,60 +0,0 @@
//#if MC>=11400
package com.replaymod.core.mixin;
import com.replaymod.core.events.KeyBindingEventCallback;
import de.johni0702.minecraft.gui.versions.callbacks.MouseCallback;
import net.minecraft.client.Mouse;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Mouse.class)
public class MixinMouseListener {
@Shadow private int activeButton;
@Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/options/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$KeyCode;)V", shift = At.Shift.AFTER))
private void afterKeyBindingTick(CallbackInfo ci) {
KeyBindingEventCallback.EVENT.invoker().onKeybindingEvent();
}
@Inject(method = "method_1611", at = @At("HEAD"), cancellable = true)
private void mouseDown(boolean[] result, double x, double y, int button, CallbackInfo ci) {
if (MouseCallback.EVENT.invoker().mouseDown(x, y, button)) {
result[0] = true;
ci.cancel();
}
}
@Inject(method = "method_1605", at = @At("HEAD"), cancellable = true)
private void mouseUp(boolean[] result, double x, double y, int button, CallbackInfo ci) {
if (MouseCallback.EVENT.invoker().mouseUp(x, y, button)) {
result[0] = true;
ci.cancel();
}
}
@Inject(method = "method_1602", at = @At("HEAD"), cancellable = true)
private void mouseDrag(Element element, double x, double y, double dx, double dy, CallbackInfo ci) {
if (MouseCallback.EVENT.invoker().mouseDrag(x, y, this.activeButton, dx, dy)) {
ci.cancel();
}
}
@Redirect(
method = "onMouseScroll",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseScrolled(DDD)Z")
)
private boolean mouseScroll(Screen element, double x, double y, double scroll) {
if (MouseCallback.EVENT.invoker().mouseScroll(x, y, scroll)) {
return true;
} else {
return element.mouseScrolled(x, y, scroll);
}
}
}
//#endif

View File

@@ -1,27 +0,0 @@
//#if MC>=11400
package com.replaymod.core.mixin;
import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import org.spongepowered.asm.mixin.Final;
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;
import java.util.List;
@Mixin(Screen.class)
public class MixinScreen {
@Shadow
protected @Final List<AbstractButtonWidget> buttons;
@Inject(method = "init(Lnet/minecraft/client/MinecraftClient;II)V", at = @At("RETURN"))
private void init(MinecraftClient minecraftClient_1, int int_1, int int_2, CallbackInfo ci) {
InitScreenCallback.EVENT.invoker().initScreen((Screen) (Object) this, buttons);
}
}
//#endif

View File

@@ -24,6 +24,7 @@
]
},
"mixins": [
"mixins.jgui.json",
"mixins.core.replaymod.json",
"mixins.extras.playeroverview.replaymod.json",
"mixins.recording.replaymod.json",

View File

@@ -7,9 +7,7 @@
//#if MC>=11400
"AbstractButtonWidgetAccessor",
"MixinGameRenderer",
"MixinScreen",
"MixinModResourcePackUtil",
"MixinMouseListener",
//#endif
//#if MC>=11300
"MixinKeyboardListener",