Skip to content

Commit

Permalink
Merge branch 'llama' into quilt-support
Browse files Browse the repository at this point in the history
  • Loading branch information
XXMA16 authored Aug 13, 2023
2 parents b6e4f7c + 559a166 commit f33aa93
Show file tree
Hide file tree
Showing 25 changed files with 488 additions and 28 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ compileJava {
method 'net/minecraft/client/render/WorldRenderer', '(Lnet/minecraft/client/util/math/MatrixStack;FJZLnet/minecraft/client/render/Camera;' +
'Lnet/minecraft/client/render/GameRenderer;Lnet/minecraft/client/render/LightmapTextureManager;Lorg/joml/Matrix4f;)V', 'render', 'method_22710'
method 'net/minecraft/client/gui/screen/Screen', '(Lnet/minecraft/client/util/math/MatrixStack;IIF)V', 'renderWithTooltip', 'method_47413'
classes += ['net/minecraft/class_5944': 'net/minecraft/class_5944']
method 'net/minecraft/class_5944', '(Lnet/minecraft/class_5912;Lnet/minecraft/util/Identifier;Lnet/minecraft/client/render/VertexFormat;)V', '<init>', '<init>'
method 'net/minecraft/client/gui/screen/Screen', '(Lnet/minecraft/class_332;IIF)V', 'renderWithTooltip', 'method_47413'
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ loader_version=0.12.5
fabric_version=0.42.0+1.16
fabric_asm_version=v2.3

mod_version = 1.13.21
mod_version = 1.13.25
maven_group = me.modmuss50
archives_base_name = optifabric
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package me.modmuss50.optifabric.compat.architectury.mixin;

import me.modmuss50.optifabric.compat.InterceptingMixin;
import me.modmuss50.optifabric.compat.PlacatingSurrogate;
import me.modmuss50.optifabric.compat.Shim;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.Window;
import net.minecraft.client.util.math.MatrixStack;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(GameRenderer.class)
@InterceptingMixin("dev/architectury/mixin/fabric/client/MixinGameRenderer")
abstract class GameRendererNew4erMixin {
@Shim
private native void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, Matrix4f matrix, MatrixStack matrices, DrawableHelper drawContext);

@PlacatingSurrogate
private void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f matrix, MatrixStack matrices) {
}

@Inject(method = "render(FJZ)V", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true,
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/class_332;IIF)V", ordinal = 0))
private void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f matrix, MatrixStack matrices, float idk, DrawableHelper drawContext) {
renderScreenPre(tickDelta, startTime, tick, ci, mouseX, mouseY, window, matrix, matrices, drawContext);
}

@Shim
private native void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, Matrix4f matrix, MatrixStack matrices, DrawableHelper drawContext);

@PlacatingSurrogate
private void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f matrix, MatrixStack matrices) {
}

@Inject(method = "render(FJZ)V", locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/class_332;IIF)V", shift = Shift.AFTER, ordinal = 0))
private void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f matrix, MatrixStack matrices, float idk, DrawableHelper drawContext) {
renderScreenPost(tickDelta, startTime, tick, ci, mouseX, mouseY, window, matrix, matrices, drawContext);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package me.modmuss50.optifabric.compat.architectury.mixin;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.Window;
import net.minecraft.client.util.math.MatrixStack;
import org.joml.Matrix4f;

import me.modmuss50.optifabric.compat.InterceptingMixin;
import me.modmuss50.optifabric.compat.PlacatingSurrogate;
import me.modmuss50.optifabric.compat.Shim;

@Mixin(GameRenderer.class)
@InterceptingMixin("dev/architectury/mixin/fabric/client/MixinGameRenderer")
abstract class GameRendererNewerererMixin {
@Shim
private native void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, Matrix4f matrix, MatrixStack matrices, MatrixStack matrices2);

@PlacatingSurrogate
private void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f matrix, MatrixStack matrices) {
}

@Inject(method = "render(FJZ)V", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true,
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", ordinal = 0))
private void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f matrix, MatrixStack matrices, MatrixStack matrices2) {
renderScreenPre(tickDelta, startTime, tick, ci, mouseX, mouseY, window, matrix, matrices, matrices2);
}

@Shim
private native void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, Matrix4f matrix, MatrixStack matrices, MatrixStack matrices2);

@PlacatingSurrogate
private void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f matrix, MatrixStack matrices) {
}

@Inject(method = "render(FJZ)V", locals = LocalCapture.CAPTURE_FAILHARD,
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", shift = Shift.AFTER, ordinal = 0))
private void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f matrix, MatrixStack matrices, MatrixStack matrices2) {
renderScreenPost(tickDelta, startTime, tick, ci, mouseX, mouseY, window, matrix, matrices, matrices2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void preApply(String targetClassName, ClassNode targetClass, String mixin

for (MethodNode method : targetClass.methods) {
if (init.equals(method.name) && "()V".equals(method.desc)) {
Member createSimpleOption = RemappingUtils.mapMethod("class_7172", "<init>", "(Ljava/lang/String;Lnet/minecraft/class_7172$class_7307;Lnet/minecraft/class_7172$class_7303;Lnet/minecraft/class_7172$class_7178;Ljava/lang/Object;Ljava/util/function/Consumer;)V");
Member createSimpleOption = RemappingUtils.mapMethod("class_7172", "<init>", getCreateSimpleOptionInitDescriptor());
InsnList extra = new InsnList();
LabelNode skip = new LabelNode();

Expand All @@ -39,4 +39,8 @@ public void preApply(String targetClassName, ClassNode targetClass, String mixin

super.preApply(targetClassName, targetClass, mixinClassName, mixinInfo);
}

protected String getCreateSimpleOptionInitDescriptor() {
return "(Ljava/lang/String;Lnet/minecraft/class_7172$class_7307;Lnet/minecraft/class_7172$class_7303;Lnet/minecraft/class_7172$class_7178;Ljava/lang/Object;Ljava/util/function/Consumer;)V";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package me.modmuss50.optifabric.compat.borderlessmining;

public class BorderlessMiningNewMixinPlugin extends BorderlessMiningMixinPlugin {
@Override
protected String getCreateSimpleOptionInitDescriptor() {
return "(Ljava/lang/String;Lnet/minecraft/class_7172$class_7277;Lnet/minecraft/class_7172$class_7303;Lnet/minecraft/class_7172$class_7178;Ljava/lang/Object;Ljava/util/function/Consumer;)V";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package me.modmuss50.optifabric.compat.borderlessmining.mixin;

import me.modmuss50.optifabric.compat.borderlessmining.MagicMixinBridge;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.VideoOptionsScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;

@Pseudo
@Mixin(targets = "net.optifine.gui.OptionFullscreenResolution", remap = false)
abstract class OptionFullscreenResolutionNewMixin {
@ModifyArgs(method = "make",
at = @At(value = "INVOKE", target = "Lnet/minecraft/class_7172;<init>(Ljava/lang/String;Lnet/minecraft/class_7172$class_7307;Lnet/minecraft/class_7172$class_7277;Lnet/minecraft/class_7172$class_7178;Ljava/lang/Object;Ljava/util/function/Consumer;)V", remap = true))
private static void modifyOption(Args args) {
Screen screen = MinecraftClient.getInstance().currentScreen;
((MagicMixinBridge) (screen instanceof MagicMixinBridge ? screen : new VideoOptionsScreen(screen, MinecraftClient.getInstance().options))).optifabric£modifyFullscreenButton(args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package me.modmuss50.optifabric.compat.fabricrendering;

import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;

import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import me.modmuss50.optifabric.compat.InterceptingMixinPlugin;
import me.modmuss50.optifabric.util.RemappingUtils;

public class RenderingExtraMixinPlugin extends InterceptingMixinPlugin {
private static final String FAKE_IDENTIFIER = "me/modmuss50/optifabric/fake/Identifier";

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
if ("ShaderProgramMixin".equals(mixinInfo.getName())) {//(ResourceFactory, VertexFormat)
String desc = RemappingUtils.mapMethodDescriptor("(Lnet/minecraft/class_5912;Ljava/lang/String;Lnet/minecraft/class_293;)V");

for (MethodNode method : targetClass.methods) {
if ("<init>".equals(method.name) && desc.equals(method.desc)) {
String identifier = RemappingUtils.getClassName("class_2960");

for (AbstractInsnNode insn : method.instructions) {
if (insn.getType() == AbstractInsnNode.METHOD_INSN && insn.getOpcode() == Opcodes.INVOKESPECIAL) {
MethodInsnNode minsn = (MethodInsnNode) insn;

if (identifier.equals(minsn.owner) && "<init>".equals(minsn.name) && "(Ljava/lang/String;)V".equals(minsn.desc)) {
minsn.owner = FAKE_IDENTIFIER;
}
}
}

InsnList extra = new InsnList();
LabelNode skip = new LabelNode();
extra.add(new JumpInsnNode(Opcodes.GOTO, skip));
extra.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, identifier, "<init>", "(Ljava/lang/String;)V", false));
extra.add(skip);
method.instructions.insertBefore(method.instructions.getLast(), extra);
break;
}
}
}

super.preApply(targetClassName, targetClass, mixinClassName, mixinInfo);
}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
if ("ShaderProgramMixin".equals(mixinInfo.getName())) {//(ResourceFactory, VertexFormat)
String desc = RemappingUtils.mapMethodDescriptor("(Lnet/minecraft/class_5912;Ljava/lang/String;Lnet/minecraft/class_293;)V");

for (MethodNode method : targetClass.methods) {
if ("<init>".equals(method.name) && desc.equals(method.desc)) {
String identifier = RemappingUtils.getClassName("class_2960");

for (AbstractInsnNode insn : method.instructions) {
if (insn.getType() == AbstractInsnNode.METHOD_INSN && FAKE_IDENTIFIER.equals(((MethodInsnNode) insn).owner)) {
((MethodInsnNode) insn).owner = identifier;
}
}
break;
}
}
}

super.postApply(targetClassName, targetClass, mixinClassName, mixinInfo);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package me.modmuss50.optifabric.compat.fabricrendering.mixin;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

import net.minecraft.class_5944;
import net.minecraft.util.Identifier;

import me.modmuss50.optifabric.compat.InterceptingMixin;
import me.modmuss50.optifabric.compat.Shim;

@Mixin(class_5944.class)
@InterceptingMixin("net/fabricmc/fabric/mixin/client/rendering/shader/ShaderProgramMixin")
abstract class ShaderProgramMixin {
@Shim
private native String modifyProgramId(String id);

@ModifyVariable(method = "<init>(Lnet/minecraft/class_5912;Lnet/minecraft/util/Identifier;Lnet/minecraft/client/render/VertexFormat;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;getNamespace()Ljava/lang/String;", ordinal = 0), argsOnly = true, allow = 1)
private Identifier modifyProgramID(Identifier id) {
String in = id.toString();
String out = modifyProgramId(in);
return in != out ? new Identifier(out) : id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package me.modmuss50.optifabric.compat.fabricscreenapi.mixin;

import me.modmuss50.optifabric.compat.InterceptingMixin;
import me.modmuss50.optifabric.compat.PlacatingSurrogate;
import me.modmuss50.optifabric.compat.Shim;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.Window;
import net.minecraft.client.util.math.MatrixStack;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(GameRenderer.class)
@InterceptingMixin("net/fabricmc/fabric/mixin/screen/GameRendererMixin")
abstract class GameRendererNew3erMixin {
@Shim
private native void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrixstack, MatrixStack drawContext);

@PlacatingSurrogate
private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float guiFarPlane) {
}

@Inject(method = "render(FJZ)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", ordinal = 0),
locals = LocalCapture.CAPTURE_FAILHARD,
cancellable = true)
private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f projection, MatrixStack matrixstack, MatrixStack drawContext) {
onBeforeRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrixstack, drawContext);
}

@Shim
private native void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrixstack, MatrixStack drawContext);

@PlacatingSurrogate
private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float guiFarPlane) {
}

@Inject(method = "render(FJZ)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", shift = Shift.AFTER, ordinal = 0),
locals = LocalCapture.CAPTURE_FAILHARD)
private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f projection, MatrixStack matrixstack, MatrixStack drawContext) {
onAfterRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrixstack, drawContext);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package me.modmuss50.optifabric.compat.fabricscreenapi.mixin;

import me.modmuss50.optifabric.compat.InterceptingMixin;
import me.modmuss50.optifabric.compat.PlacatingSurrogate;
import me.modmuss50.optifabric.compat.Shim;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.Window;
import net.minecraft.client.util.math.MatrixStack;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(GameRenderer.class)
@InterceptingMixin("net/fabricmc/fabric/mixin/screen/GameRendererMixin")
abstract class GameRendererNew4erMixin {
@Shim
private native void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrixstack, DrawableHelper drawContext);

@PlacatingSurrogate
private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float idk) {
}

@Inject(method = "render(FJZ)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/class_332;IIF)V", ordinal = 0),
locals = LocalCapture.CAPTURE_FAILHARD,
cancellable = true)
private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f projection, MatrixStack matrixstack, float idk, DrawableHelper drawContext) {
onBeforeRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrixstack, drawContext);
}

@Shim
private native void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrixstack, DrawableHelper drawContext);

@PlacatingSurrogate
private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float idk) {
}

@Inject(method = "render(FJZ)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/class_332;IIF)V", shift = Shift.AFTER, ordinal = 0),
locals = LocalCapture.CAPTURE_FAILHARD)
private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f projection, MatrixStack matrixstack, float idk, DrawableHelper drawContext) {
onAfterRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrixstack, drawContext);
}
}
Loading

0 comments on commit f33aa93

Please sign in to comment.