diff --git a/src/main/java/me/modmuss50/optifabric/compat/MixinFixerExtension.java b/src/main/java/me/modmuss50/optifabric/compat/MixinFixerExtension.java new file mode 100644 index 00000000..3e99a8c9 --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/MixinFixerExtension.java @@ -0,0 +1,108 @@ +package me.modmuss50.optifabric.compat; + +import me.modmuss50.optifabric.compat.fix.ModMixinFixer; +import me.modmuss50.optifabric.mod.OptifabricError; +import me.modmuss50.optifabric.mod.OptifabricSetup; +import me.modmuss50.optifabric.util.MixinInternals; +import me.modmuss50.optifabric.util.MixinUtils; +import org.apache.commons.lang3.tuple.Pair; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.*; +import org.spongepowered.asm.mixin.MixinEnvironment; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import org.spongepowered.asm.mixin.injection.throwables.InjectionError; +import org.spongepowered.asm.mixin.transformer.ClassInfo; +import org.spongepowered.asm.mixin.transformer.ext.IExtension; +import org.spongepowered.asm.mixin.transformer.ext.ITargetClassContext; + +import java.util.*; +import java.util.stream.Collectors; + +public class MixinFixerExtension implements IExtension { + private static final Set PRE_MIXINS = Collections.newSetFromMap(new WeakHashMap<>()); + private static final Set POST_MIXINS = Collections.newSetFromMap(new WeakHashMap<>()); + private static final HashMap CLASS_INFO_UPDATES = new HashMap<>(); + + @Override + public boolean checkActive(MixinEnvironment environment) { + return true; + } + + @Override + public void preApply(ITargetClassContext context) { + if (OptifabricError.hasError()) return; + for (Pair pair : MixinInternals.getMixinsFor(context)) { + prepareMixin(pair.getLeft(), pair.getRight()); + } + updateClassInfo(context.getClassInfo(), context.getClassNode()); + } + + @Override + public void postApply(ITargetClassContext context) { + for (Pair pair : MixinInternals.getMixinsFor(context)) { + handleErrorInjectors(pair.getLeft(), pair.getRight(), context); + } + } + + @Override + public void export(MixinEnvironment env, String name, boolean force, ClassNode classNode) { + + } + + private static void prepareMixin(IMixinInfo mixinInfo, ClassNode mixinNode) { + if (PRE_MIXINS.contains(mixinNode)) { + // Don't scan the whole class again. + return; + } + MixinNodeTransformer transformer = new MixinNodeTransformer(mixinInfo, mixinNode); + ModMixinFixer.INSTANCE.getFixers(mixinInfo).forEach(fixer -> fixer.fix(transformer)); + if (transformer.shouldUpdateClassInfo()) { + mixinInfo.getTargetClasses().forEach(target -> CLASS_INFO_UPDATES.put(target, false)); + } + PRE_MIXINS.add(mixinNode); + } + + public void updateClassInfo(ClassInfo info, ClassNode node) { + if (!CLASS_INFO_UPDATES.getOrDefault(info.getName(), true)) { + MixinUtils.completeClassInfo(info, node.methods); + CLASS_INFO_UPDATES.put(info.getName(), true); + } + } + + //this could use some refactoring + private static void handleErrorInjectors(IMixinInfo mixinInfo, ClassNode mixinNode, ITargetClassContext context) { + if (POST_MIXINS.contains(mixinNode)) { + return; + } + ClassNode classNode = context.getClassNode(); + + List methods = classNode.methods.stream().map(method -> method.name).collect(Collectors.toList()); + //check for error methods + for (MethodNode method : classNode.methods) { + if (method.name.endsWith("$missing") && methods.stream().anyMatch(name -> (name + "$missing").equals(method.name))) { + for (AbstractInsnNode insn : method.instructions) { + if (insn instanceof LdcInsnNode) { + String error = (String) ((LdcInsnNode) insn).cst; + if (!OptifabricError.hasError()) { + OptifabricError.setError(new InjectionError(error), getError(mixinInfo, method)); + OptifabricError.modError = true; + } + break; + } + } + OptifabricSetup.LOGGER.warn("Removed InjectionException from Error Injector method " + method.name); + method.instructions.clear(); + method.instructions.add(new InsnNode(Opcodes.RETURN)); + } + } + POST_MIXINS.add(mixinNode); + } + + private static String getError(IMixinInfo mixinInfo, MethodNode method) { + boolean compat = !ModMixinFixer.INSTANCE.getFixers(mixinInfo).isEmpty(); + return String.format("Injector method %s in %s couldn't apply due to " + + (compat ? "outdated compatibility patch" : "missing compatibility patch!") + + " Please report this issue.", + method.name, mixinInfo); + } +} diff --git a/src/main/java/me/modmuss50/optifabric/compat/MixinNodeTransformer.java b/src/main/java/me/modmuss50/optifabric/compat/MixinNodeTransformer.java new file mode 100644 index 00000000..e50a2677 --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/MixinNodeTransformer.java @@ -0,0 +1,410 @@ +package me.modmuss50.optifabric.compat; + +import com.google.common.collect.Lists; +import me.modmuss50.optifabric.compat.fix.IMixinFixer; +import me.modmuss50.optifabric.patcher.fixes.ClassFixer; +import me.modmuss50.optifabric.util.MixinInternals; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; +import org.objectweb.asm.tree.*; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Slice; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.struct.InjectionInfo; +import org.spongepowered.asm.mixin.transformer.ClassInfo; +import org.spongepowered.asm.util.Annotations; + +import java.lang.reflect.Modifier; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntSupplier; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +/** + * An abstraction over raw ASM that aids in patching the mixins of + * other mods to work with OptiFine. Rather than allowing mixin fixers + * direct access to the mixin's {@link ClassNode}, a {@link Consumer} of + * this type is passed to {@link IMixinFixer#fix} in order to provide + * a standardized way of patching Injectors and to avoid repetitive or + * "bad" code. + */ +public class MixinNodeTransformer { + final IMixinInfo mixinInfo; + private final ClassNode mixinNode; + private final ClassInfo mixinClassInfo; + private final Set methods; + private boolean updateClassInfo = false; + + public MixinNodeTransformer(IMixinInfo mixinInfo, ClassNode mixinNode) { + this.mixinInfo = mixinInfo; + this.mixinNode = mixinNode; + mixinClassInfo = MixinInternals.getClassInfoFor(mixinInfo); + methods = MixinInternals.getClassInfoMethods(mixinClassInfo); + } + + /** + * Transforms all methods with the given name. + * @param name name of the methods to be transformed + * @param transformer transformation to be performed + */ + public void transformMethods(String name, Consumer transformer) { + transformMethods(method -> name.equals(method.name), transformer); + } + + /** + * Transforms all methods with the given names. + * @param names names of the methods to be transformed + * @param transformer transformation to be performed + */ + public void transformMethods(List names, Consumer transformer) { + transformMethods(method -> names.contains(method.name), transformer); + } + + /** + * Transforms all methods matching the filter. + * @param filter name of the methods to be transformed + * @param transformer predicate which returns true for + * methods to be transformed + */ + public void transformMethods(Predicate filter, Consumer transformer) { + mixinNode.methods.stream().filter(filter).forEach(method -> { + MethodTransformer methodTransformer = new MethodTransformer(method); + transformer.accept(methodTransformer); + if (methodTransformer.requiresUpdate) { + methods.removeIf(meth -> method.name.equals(meth.getOriginalName()) && method.desc.equals(meth.getOriginalDesc())); + methods.add(mixinClassInfo.new Method(method, true)); + } + }); + } + + /** + * An abstraction over raw ASM that aids in patching + * methods from another mod's mixin. + */ + public class MethodTransformer { + final MethodNode method; + boolean requiresUpdate = false; + + public MethodTransformer(MethodNode method) { + this.method = method; + } + + /** + * Transforms an Injector annotation. May only be used + * when the method being transformed is an Injector. + * @param transformer transformation to be performed + */ + public void transformInjector(Consumer transformer) { + transformer.accept(new InjectorTransformer(InjectionInfo.getInjectorAnnotation(mixinInfo, method))); + } + + /** + * An abstraction over raw ASM that aids in patching + * the injector annotation of methods from another mod's mixin. + */ + public class InjectorTransformer { + private final AnnotationNode injector; + + public InjectorTransformer(AnnotationNode injector) { + this.injector = injector; + } + + /** + * Sets the {@code method} key of the injector. The new target selector + * should be added by OptiFine, as this is the only + * legitimate use case of this method. As such, the {@link ClassInfo} + * of this mixin is marked for updating. + * @param method the names of the new method(s). The + * descriptor should also be appended to the name + * in order to avoid ambiguity, especially in a + * development environment. + */ + public void setMethod(String... method) { + Annotations.setValue(injector, "method", Arrays.asList(method)); + Annotations.setValue(injector, "remap", false); + updateClassInfo = true; + } + + /** + * Sets the {@code at} key of the injector. If the + * injector takes an array of {@link At}s the array + * will be replaced with one that contains only the + * given {@code at}. Use only if a {@link ClassFixer} + * can't (or shouldn't) be used. + * @param atNode {@link AtNode} that constructs an {@link At} + * annotation from the given {@code value} and {@code target} + */ + public void setAt(AtNode atNode) { + Object at = Annotations.getValue(injector, "at"); + if (at instanceof AnnotationNode) { + Annotations.setValue(injector, "at", atNode.at); + } else if (at instanceof Collection) { + Annotations.setValue(injector, "at", Collections.singletonList(atNode.at)); + } + } + + /** + * Sets the {@code ordinal} key of the injector's {@code at}. Preferably + * used in conjunction with {@link #setSlice} in order to minimize the + * number of fixes needed for different versions. Note that this + * does not work with {@link Inject#at} since it's an array, + * instead of a single {@link At}. + * @param ordinal the new ordinal + */ + public void setAtOrdinal(int ordinal) { + AnnotationNode at = Annotations.getValue(injector, "at"); + Annotations.setValue(at, "ordinal", ordinal); + } + + /** + * Sets the {@code slice} key of the injector. Only takes + * the {@code from} argument. + * @param from {@link AtNode} that constructs an {@link At} + * annotation from the given {@code value} and {@code target} + */ + public void setSlice(AtNode from) { + AnnotationNode slice = new AnnotationNode(Slice.class.getName()); + Annotations.setValue(slice, "from", from.at); + Annotations.setValue(injector, "slice", slice); + } + + /** + * Same as {@link #setSlice(AtNode)}, but also takes + * the {@code to} argument. + * @param from the {@code from} of the {@link Slice} + * @param to the {@code to} of the {@link Slice} + * @see #setSlice + */ + public void setSlice(AtNode from, AtNode to) { + AnnotationNode slice = new AnnotationNode(Slice.class.getName()); + Annotations.setValue(slice, "from", from.at); + Annotations.setValue(slice, "to", to.at); + Annotations.setValue(injector, "slice", slice); + } + } + + /** + * Lazily gets the index of the first sequence matching the specified + * one in the method parameters. If the is not found, the supplied + * value will be {@code -1}, causing an {@link IndexOutOfBoundsException} + * when used as the index argument of {@link #addParams} or + * {@link #removeParam}, which in turn will crash the game. + * @param afterSequence whether to return the index of the parameter + * right after the sequence. The absence of such + * a parameter does not cause issues when adding + * parameters, as they will be added at the tail. + * Setting this to {@code false} will return the + * index of the first element in the sequence. + * @param sequence the sequence of parameters to look for. Must be the + * internal names of the types. + * @return an {@link IntSupplier} that retrieves the index when needed. + * If no matching sequence is found, the supplied value will be {@code -1}. + */ + public IntSupplier getIndex(boolean afterSequence, String... sequence) { + return getIndex(false, afterSequence, toTypeList(sequence)); + } + + /** + * Lazily gets the index of the first sequence matching the specified + * one in the method parameters, but only looks for the sequence + * after the first (and preferably only) parameter of type {@link CallbackInfo} or + * {@link CallbackInfoReturnable}. + * @param afterSequence whether to get the index after the + * sequence or where the sequence itself is found + * @param sequence the sequence of parameters to look for + * @return an {@link IntSupplier} that retrieves the index + * @see #getIndex + */ + public IntSupplier getIndexCI(boolean afterSequence, String... sequence) { + return getIndex(true, afterSequence, toTypeList(sequence)); + } + + /** + * Lazily gets the index of the first sequence matching the specified + * one in the method parameters. + * @param afterCallback whether to use the behaviour of + * {@link #getIndexCI} or {@link #getIndex} + * @param afterSequence whether to get the index after the + * sequence or where the sequence itself is found + * @param sequence the sequence of parameters to look for in + * the form of a {@link Type} list + * @return an {@link IntSupplier} that retrieves the index + * @see #getIndex + */ + private IntSupplier getIndex(boolean afterCallback, boolean afterSequence, List sequence) { + return () -> { + Type[] desc = Type.getArgumentTypes(method.desc); + int offset = 0; + if (afterCallback) { + for (Type type : desc) { + offset++; + if (type.toString().startsWith("Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo")) { + break; + } + } + } + on: for(int i = offset; i < desc.length - sequence.size() + 1; i++) { + for(int j = 0; j < sequence.size(); j++) { + if (!desc[i+j].equals(sequence.get(j))) { + continue on; + } + } + if (afterSequence) { + i += sequence.size(); + } + return i; + } + return -1; + }; + } + + /** + * Adds the specified parameters to the method descriptor and + * shifts the locals accordingly, taking into account "wide" types + * and non-static methods. The index should be obtained via + * {@link #getIndex} or {@link #getIndexCI}. Used to correct the locals of an + * {@link Inject} or when the target method needs to be changed to one + * added by OptiFine (which takes extra arguments) since the body + * of the original is replaced with a call to the OptiFine method. + * @param index index at which the params are to be inserted. + * Refers strictly to the index of the parameter in the array + * obtained via {@link Type#getArgumentTypes(String)}. + * @param params internal names of the params to be added + */ + public void addParams(IntSupplier index, String... params) { + addParams(index.getAsInt(), toTypeList(params)); + } + + /** + * Inserts the specified parameters at the given index in the + * method descriptor. The index is an {@code int} for convenience + * in some situations. + * @param index index at which the params are to be inserted + * @param params internal names of the params to be added + */ + public void addParams(int index, String... params) { + addParams(index, toTypeList(params)); + } + + /** + * Appends the specified parameters to the method descriptor. + * @param params internal names of the params to be appended + * @see #addParams + */ + public void addParams(String... params) { + addParams(Type.getArgumentTypes(method.desc).length, toTypeList(params)); + } + + /** + * Inserts the specified parameters at the given index in the + * method descriptor. + * @param index index at which the params are to be inserted + * @param params list of the parameter {@link Type}s to be added + * @see #addParams + */ + private void addParams(int index, List params) { + List newDesc = Arrays.stream(Type.getArgumentTypes(method.desc)).collect(Collectors.toList()); + newDesc.addAll(index, params); + int shiftBy = 0; + for (Type param : params) { + shiftBy += param.getSize(); + } + + if (method.parameters != null) { + for (int i = 0; i < params.size(); i++) { + method.parameters.add(index + i, new ParameterNode("syn_" + i, Opcodes.ACC_SYNTHETIC)); + } + } + + shiftLocals(index, shiftBy, newDesc); + } + + /** + * Removes the parameter at the given index and shifts the local + * variables accordingly. Use with caution since no check is done + * to confirm that the parameter is unused. The index should be + * obtained via {@link #getIndex} or {@link #getIndexCI}. Same use cases as + * {@link #addParams}. + * @param index index of the parameter to be removed + */ + public void removeParam(int index) { + List newDesc = Lists.newArrayList(Type.getArgumentTypes(method.desc)); + int shiftBy = -newDesc.remove(index).getSize(); + + int lvIndex = shiftLocals(index, shiftBy, newDesc); + if (method.localVariables != null) method.localVariables.removeIf(local -> local.index == lvIndex); + if (method.parameters != null) method.parameters.remove(index); + } + + /** + * Handles the shifting of local variables indices and instructions, + * and adjust the {@code maxLocals}. Additionally, it marks the method + * for updating. + * @param index the index of the parameter in the array obtained via + * {@link Type#getArgumentTypes} from which to start shifting. + * All local variables starting with the one corresponding to + * the parameter will be shifted accordingly. + * @param shiftBy how much to shift the locals by + * @param params list of the parameter {@link Type}s in the order in + * which they appear in the descriptor + * @return the calculated index of the local corresponding to the + * parameter at the given {@code index}. This is used by {@link #removeParam} + * in order to remove the {@link LocalVariableNode} with that index + */ + private int shiftLocals(int index, int shiftBy, List params) { + int lvIndex = 0; + if (!Modifier.isStatic(method.access)) lvIndex++; + + for (int i = 0; i < index; i++) { + lvIndex += params.get(i).getSize(); + } + + for (LocalVariableNode local : method.localVariables) { + if (local.index >= lvIndex) { + local.index += shiftBy; + } + } + + for (AbstractInsnNode insn : method.instructions) { + if (insn instanceof VarInsnNode && ((VarInsnNode) insn).var >= lvIndex) { + ((VarInsnNode) insn).var += shiftBy; + } else if (insn instanceof IincInsnNode && ((IincInsnNode) insn).var >= lvIndex) { + ((IincInsnNode) insn).var += shiftBy; + } + } + + method.maxLocals += shiftBy; + method.desc = Type.getMethodDescriptor(Type.getReturnType(method.desc), params.toArray(new Type[0])); + requiresUpdate = true; + + return lvIndex; + } + } + + /** + * Class used to construct an {@link At} annotation node + * from the given {@code value} and {@code target}. The + * {@code target} is required since the use only use + * case of this is when constructing a {@link Slice}. + */ + public static class AtNode { + final AnnotationNode at; + public AtNode(String value, String target) { + at = new AnnotationNode(At.class.getName()); + Annotations.setValue(at, "value", value); + Annotations.setValue(at, "target", target); + } + } + + public boolean shouldUpdateClassInfo() { + return updateClassInfo; + } + + static List toTypeList(String[] types) { + return Arrays.stream(types).map(Type::getType).collect(Collectors.toList()); + } +} diff --git a/src/main/java/me/modmuss50/optifabric/compat/OptifabricMixinErrorHandler.java b/src/main/java/me/modmuss50/optifabric/compat/OptifabricMixinErrorHandler.java new file mode 100644 index 00000000..84d0c1c9 --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/OptifabricMixinErrorHandler.java @@ -0,0 +1,61 @@ +package me.modmuss50.optifabric.compat; + +import me.modmuss50.optifabric.compat.fix.ModMixinFixer; +import me.modmuss50.optifabric.mod.OptifabricError; +import me.modmuss50.optifabric.mod.OptifabricSetup; +import org.apache.logging.log4j.Level; +import org.spongepowered.asm.mixin.FabricUtil; +import org.spongepowered.asm.mixin.extensibility.IMixinConfig; +import org.spongepowered.asm.mixin.extensibility.IMixinErrorHandler; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +public class OptifabricMixinErrorHandler implements IMixinErrorHandler { + @Override + public ErrorAction onPrepareError(IMixinConfig config, Throwable th, IMixinInfo mixin, ErrorAction action) { + return handleError(mixin, action, th, false); + } + + @Override + public ErrorAction onApplyError(String targetClassName, Throwable th, IMixinInfo mixin, ErrorAction action) { + return handleError(mixin, action, th, true); + } + + private static ErrorAction handleError(IMixinInfo mixin, ErrorAction action, Throwable th, boolean apply) { + boolean compat = !ModMixinFixer.INSTANCE.getFixers(mixin).isEmpty(); + Level level = action == ErrorAction.ERROR ? Level.ERROR : Level.WARN; + IMixinConfig config = mixin.getConfig(); + String msg = String.format(getMessage(apply, compat), mixin.getName(), config.getName(), FabricUtil.getModId(config)); + OptifabricSetup.LOGGER.log(level, msg); + //TODO: make this support more than one error and separate OptiFine errors from mod errors + if (!OptifabricError.hasError()) { + OptifabricError.setError(th, msg); + OptifabricError.modError = true; + } + if (level == Level.ERROR) { + OptifabricSetup.LOGGER.info("The following message should have been an error, but will be logged as a " + + "warn instead in order to allow the game to show the crash screen."); + } + //let the game show the crash screen instead of outright crashing + //TODO: there are some cases where doing this will do more bad than good + return ErrorAction.WARN; + } + + private static String getMessage(boolean apply, boolean compat) { + String msg; + if (compat) { + if (apply) { + msg = "Failed to apply compatibility patch for %s! Try downgrading the affected mod."; + } else { + msg = "Prepare error in patched %s! At least one of the patches has a serious flaw!"; + } + } else { + if (apply) { + msg = "Mixin %s could not be applied and no compatibility patch was found!"; + } else { + msg = "Prepare error in %s! No compatibility patch was found! This might be an issue with the original mod."; + } + } + msg = String.format(msg, "'%s' in '%s' from mod '%s'") + " Please report this issue."; + return msg; + } +} diff --git a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererMixin.java b/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererMixin.java deleted file mode 100644 index 92d0ad5c..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererMixin.java +++ /dev/null @@ -1,49 +0,0 @@ -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 me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(GameRenderer.class) -@InterceptingMixin("me/shedaniel/architectury/mixin/fabric/client/MixinGameRenderer") -abstract class GameRendererMixin { - @Shim - private native void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", ordinal = 0), - locals = LocalCapture.CAPTURE_FAILHARD, - cancellable = true) - private void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, MatrixStack matrices) { - renderScreenPre(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } - - @Shim - private native void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", shift = Shift.AFTER, ordinal = 0), - locals = LocalCapture.CAPTURE_FAILHARD) - private void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, MatrixStack matrices) { - renderScreenPost(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNew4erMixin.java b/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNew4erMixin.java deleted file mode 100644 index d5b5ff73..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNew4erMixin.java +++ /dev/null @@ -1,46 +0,0 @@ -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); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewMixin.java b/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewMixin.java deleted file mode 100644 index 9991ac6f..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -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 net.minecraft.util.math.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 GameRendererNewMixin { - @Shim - private native void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", ordinal = 0)) - private void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, Matrix4f projection, MatrixStack modelView, MatrixStack matrices) { - renderScreenPre(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } - - @Shim - private native void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", locals = LocalCapture.CAPTURE_FAILHARD, - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", shift = Shift.AFTER, ordinal = 0)) - private void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, Matrix4f projection, MatrixStack modelView, MatrixStack matrices) { - renderScreenPost(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewerMixin.java b/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewerMixin.java deleted file mode 100644 index f1f10ec4..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewerMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -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 net.minecraft.util.math.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 GameRendererNewerMixin { - @Shim - private native void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", ordinal = 0)) - private void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f projection, MatrixStack modelView, MatrixStack matrices) { - renderScreenPre(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } - - @Shim - private native void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", locals = LocalCapture.CAPTURE_FAILHARD, - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", shift = Shift.AFTER, ordinal = 0)) - private void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f projection, MatrixStack modelView, MatrixStack matrices) { - renderScreenPost(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewererMixin.java b/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewererMixin.java deleted file mode 100644 index e3d4a4a3..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewererMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -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 net.minecraft.util.math.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 GameRendererNewererMixin { - @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;render(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;render(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); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewerererMixin.java b/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewerererMixin.java deleted file mode 100644 index 15003892..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/GameRendererNewerererMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -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); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/SpriteAtlasTextureMixin.java b/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/SpriteAtlasTextureMixin.java deleted file mode 100644 index 71601ca4..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/SpriteAtlasTextureMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -package me.modmuss50.optifabric.compat.architectury.mixin; - -import java.util.Set; -import java.util.stream.Stream; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.client.texture.SpriteAtlasTexture.Data; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.profiler.Profiler; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(SpriteAtlasTexture.class) -@InterceptingMixin("me/shedaniel/architectury/mixin/fabric/client/MixinTextureAtlas") -abstract class SpriteAtlasTextureMixin { - @PlacatingSurrogate - private void preStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels) { - } - - @Inject(method = "stitch", - at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0), - locals = LocalCapture.CAPTURE_FAILHARD) - private void preStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels, Set set) { - preStitch(resourceManager, idStream, profiler, mipmapLevels, call, set); - } - - @Shim - private native void preStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, Set set); -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/SpriteAtlasTextureNewMixin.java b/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/SpriteAtlasTextureNewMixin.java deleted file mode 100644 index 422e8a5c..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/architectury/mixin/SpriteAtlasTextureNewMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.modmuss50.optifabric.compat.architectury.mixin; - -import java.util.Set; -import java.util.stream.Stream; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.client.texture.SpriteAtlasTexture.Data; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.profiler.Profiler; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(SpriteAtlasTexture.class) -@InterceptingMixin("dev/architectury/mixin/fabric/client/MixinTextureAtlas") -abstract class SpriteAtlasTextureNewMixin { - @PlacatingSurrogate - private void preStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels) { - } - - @Inject(method = "stitch", locals = LocalCapture.CAPTURE_FAILHARD, - at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", args = "ldc=extracting_frames")) - private void preStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels, Set set) { - preStitch(resourceManager, idStream, profiler, mipmapLevels, call, set); - } - - @Shim - private native void preStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, Set set); -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/charm/CharmMixinPlugin.java b/src/main/java/me/modmuss50/optifabric/compat/charm/CharmMixinPlugin.java deleted file mode 100644 index ca4cd252..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/charm/CharmMixinPlugin.java +++ /dev/null @@ -1,44 +0,0 @@ -package me.modmuss50.optifabric.compat.charm; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.InsnNode; -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 CharmMixinPlugin extends InterceptingMixinPlugin { - @Override - public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - if ("UtilMixin".equals(mixinInfo.getName())) { - String desc = "(Lcom/mojang/datafixers/DSL$TypeReference;Ljava/lang/String;)Lcom/mojang/datafixers/types/Type;"; - String getChoiceTypeInternal = RemappingUtils.getMethodName("class_156", "method_29191", desc); //Util, getChoiceTypeInternal - - for (MethodNode method : targetClass.methods) { - if (getChoiceTypeInternal.equals(method.name) && desc.equals(method.desc)) { - LabelNode skip = new LabelNode(); - - InsnList extra = new InsnList(); - extra.add(new JumpInsnNode(Opcodes.GOTO, skip)); - extra.add(new InsnNode(Opcodes.ACONST_NULL)); - extra.add(new InsnNode(Opcodes.ACONST_NULL)); - extra.add(new InsnNode(Opcodes.ACONST_NULL)); - extra.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "org/apache/logging/log4j/Logger", "error", "(Ljava/lang/String;Ljava/lang/Object;)V", true)); - extra.add(skip); - - method.instructions.insertBefore(method.instructions.getLast(), extra); - break; - } - } - } - - super.preApply(targetClassName, targetClass, mixinClassName, mixinInfo); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/BlockEntityRenderDispatcherMixin.java b/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/BlockEntityRenderDispatcherMixin.java deleted file mode 100644 index b988001e..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/BlockEntityRenderDispatcherMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package me.modmuss50.optifabric.compat.charm.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -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.block.entity.BlockEntity; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; -import net.minecraft.client.render.block.entity.BlockEntityRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.world.World; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(BlockEntityRenderDispatcher.class) -@InterceptingMixin("svenhjol/charm/mixin/storage_labels/CallStorageLabelsRenderMixin") -abstract class BlockEntityRenderDispatcherMixin { - @PlacatingSurrogate - private static void hookExtraRender(BlockEntityRenderer renderer, BlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo call, World world) { - } - - @Inject(method = "render(Lnet/minecraft/client/render/block/entity/BlockEntityRenderer;Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;)V", - at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD) - private static void hookExtraRender(BlockEntityRenderer renderer, BlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo call, World world, int light) { - hookExtraRender(renderer, blockEntity, tickDelta, matrices, vertexConsumers, call, light); - } - - @Shim - private static native void hookExtraRender(BlockEntityRenderer renderer, T blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo call, int light); -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/SpriteAtlasTextureMixin.java b/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/SpriteAtlasTextureMixin.java deleted file mode 100644 index 91c2535a..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/SpriteAtlasTextureMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.modmuss50.optifabric.compat.charm.mixin; - -import java.util.Set; -import java.util.stream.Stream; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.client.texture.SpriteAtlasTexture.Data; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.profiler.Profiler; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(SpriteAtlasTexture.class) -@InterceptingMixin("svenhjol/charm/mixin/callback/StitchTextureCallbackMixin") -class SpriteAtlasTextureMixin { - @PlacatingSurrogate - private void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels) { - } - - @Inject(method = "stitch", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) - private void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels, Set set) { - hookStitch(resourceManager, idStream, profiler, mipmapLevels, call, set); - } - - @Shim - private native void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, Set set); -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/SpriteAtlasTextureNewMixin.java b/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/SpriteAtlasTextureNewMixin.java deleted file mode 100644 index 8ab08fd9..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/SpriteAtlasTextureNewMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.modmuss50.optifabric.compat.charm.mixin; - -import java.util.Set; -import java.util.stream.Stream; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.client.texture.SpriteAtlasTexture.Data; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.profiler.Profiler; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(SpriteAtlasTexture.class) -@InterceptingMixin("svenhjol/charm/mixin/event/StitchTextureMixin") -class SpriteAtlasTextureNewMixin { - @PlacatingSurrogate - private void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels) { - } - - @Inject(method = "stitch", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) - private void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels, Set set) { - hookStitch(resourceManager, idStream, profiler, mipmapLevels, call, set); - } - - @Shim - private native void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, Set set); -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/old/SpriteAtlasTextureMixin.java b/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/old/SpriteAtlasTextureMixin.java deleted file mode 100644 index 7aa50b44..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/old/SpriteAtlasTextureMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.modmuss50.optifabric.compat.charm.mixin.old; - -import java.util.Set; -import java.util.stream.Stream; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.client.texture.SpriteAtlasTexture.Data; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.profiler.Profiler; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(SpriteAtlasTexture.class) -@InterceptingMixin("svenhjol/charm/mixin/SpriteAtlasTextureMixin") -class SpriteAtlasTextureMixin { - @PlacatingSurrogate - private void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels) { - } - - @Inject(method = "stitch", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) - private void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels, Set set) { - hookStitch(resourceManager, idStream, profiler, mipmapLevels, call, set); - } - - @Shim - private native void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, Set set); -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/old/UtilMixin.java b/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/old/UtilMixin.java deleted file mode 100644 index 93cc0036..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/old/UtilMixin.java +++ /dev/null @@ -1,26 +0,0 @@ -package me.modmuss50.optifabric.compat.charm.mixin.old; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.mojang.datafixers.DSL.TypeReference; -import com.mojang.datafixers.types.Type; - -import net.minecraft.util.Util; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(Util.class) -@InterceptingMixin("svenhjol/charm/mixin/UtilMixin") -abstract class UtilMixin { - @Inject(method = "getChoiceTypeInternal", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;debug(Ljava/lang/String;Ljava/lang/Object;)V", remap = false), cancellable = true) - private static void optifabric_hookAttemptDataFixInternal(TypeReference type, String id, CallbackInfoReturnable> call) { - hookAttemptDataFixInternal(type, id, call); - } - - @Shim - private static native void hookAttemptDataFixInternal(TypeReference type, String id, CallbackInfoReturnable> call); -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/older/SpriteAtlasTextureMixin.java b/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/older/SpriteAtlasTextureMixin.java deleted file mode 100644 index 40977713..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/charm/mixin/older/SpriteAtlasTextureMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.modmuss50.optifabric.compat.charm.mixin.older; - -import java.util.Set; -import java.util.stream.Stream; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.client.texture.SpriteAtlasTexture.Data; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.profiler.Profiler; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(SpriteAtlasTexture.class) -@InterceptingMixin("svenhjol/meson/mixin/SpriteAtlasTextureMixin") -class SpriteAtlasTextureMixin { - @PlacatingSurrogate - private void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels) { - } - - @Inject(method = "stitch", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) - private void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, int mipmapLevels, Set set) { - hookStitch(resourceManager, idStream, profiler, mipmapLevels, call, set); - } - - @Shim - private native void hookStitch(ResourceManager resourceManager, Stream idStream, Profiler profiler, int mipmapLevel, CallbackInfoReturnable call, Set set); -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/cloth/mixin/DummyMixinGameRenderer.java b/src/main/java/me/modmuss50/optifabric/compat/cloth/mixin/DummyMixinGameRenderer.java deleted file mode 100644 index ddb40df1..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/cloth/mixin/DummyMixinGameRenderer.java +++ /dev/null @@ -1,32 +0,0 @@ -package me.modmuss50.optifabric.compat.cloth.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -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 me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(GameRenderer.class) -@InterceptingMixin("me/shedaniel/cloth/mixin/client/events/MixinGameRenderer") -public class DummyMixinGameRenderer { - // Taken from https://github.com/shedaniel/cloth-api/blob/3913836e59e1df9058ece3e791ee0f5993b8bc00/cloth-client-events-v0/src/main/java/me/shedaniel/cloth/mixin/client/events/MixinGameRenderer.java#L49 - @Inject(method = "render(FJZ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", shift = At.Shift.AFTER, ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION) - public void optifabric_renderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, MatrixStack matrices) { - renderScreen(tickDelta, startTime, tick, ci, mouseX, mouseY, matrices); - } - - @Shim - public native void renderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void renderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window) { - } -} diff --git a/src/main/java/me/modmuss50/optifabric/compat/cloth/mixin/GameRendererNewMixin.java b/src/main/java/me/modmuss50/optifabric/compat/cloth/mixin/GameRendererNewMixin.java deleted file mode 100644 index 45f75530..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/cloth/mixin/GameRendererNewMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package me.modmuss50.optifabric.compat.cloth.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 net.minecraft.util.math.Matrix4f; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(GameRenderer.class) -@InterceptingMixin("me/shedaniel/cloth/mixin/client/events/MixinGameRenderer") -abstract class GameRendererNewMixin { - @Inject(method = "render(FJZ)V", locals = LocalCapture.CAPTURE_FAILEXCEPTION, - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", shift = Shift.AFTER, ordinal = 0)) - private void optifabric_renderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, Matrix4f projection, MatrixStack modelView, MatrixStack matrices) { - renderScreen(tickDelta, startTime, tick, ci, mouseX, mouseY, matrices); - } - - @Shim - public abstract void renderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void renderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window) { - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/cloth/mixin/GameRendererNewerMixin.java b/src/main/java/me/modmuss50/optifabric/compat/cloth/mixin/GameRendererNewerMixin.java deleted file mode 100644 index afa03d65..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/cloth/mixin/GameRendererNewerMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package me.modmuss50.optifabric.compat.cloth.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 net.minecraft.util.math.Matrix4f; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(GameRenderer.class) -@InterceptingMixin("me/shedaniel/cloth/mixin/client/events/MixinGameRenderer") -abstract class GameRendererNewerMixin { - @Inject(method = "render(FJZ)V", locals = LocalCapture.CAPTURE_FAILEXCEPTION, - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", shift = Shift.AFTER, ordinal = 0)) - private void optifabric_renderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window, float guiFarPlane, Matrix4f projection, MatrixStack modelView, MatrixStack matrices) { - renderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } - - @Shim - public abstract void renderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void renderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/RenderingDataBonusMixinPlugin.java b/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/RenderingDataBonusMixinPlugin.java deleted file mode 100644 index e5dc2f4c..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/RenderingDataBonusMixinPlugin.java +++ /dev/null @@ -1,21 +0,0 @@ -package me.modmuss50.optifabric.compat.fabricrenderingdata; - -import org.objectweb.asm.tree.ClassNode; - -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; -import org.spongepowered.asm.mixin.transformer.ClassInfo; - -import me.modmuss50.optifabric.compat.InterceptingMixinPlugin; -import me.modmuss50.optifabric.util.MixinUtils; - -public class RenderingDataBonusMixinPlugin extends InterceptingMixinPlugin { - @Override - public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - if ("ChunkRendererRegionBuilderMixin".equals(mixinInfo.getName())) { - ClassInfo info = ClassInfo.forName(targetClassName); - MixinUtils.completeClassInfo(info, targetClass.methods); - } - - super.preApply(targetClassName, targetClass, mixinClassName, mixinInfo); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/RenderingDataExtraMixinPlugin.java b/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/RenderingDataExtraMixinPlugin.java deleted file mode 100644 index 7cdd6737..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/RenderingDataExtraMixinPlugin.java +++ /dev/null @@ -1,21 +0,0 @@ -package me.modmuss50.optifabric.compat.fabricrenderingdata; - -import org.objectweb.asm.tree.ClassNode; - -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; -import org.spongepowered.asm.mixin.transformer.ClassInfo; - -import me.modmuss50.optifabric.compat.InterceptingMixinPlugin; -import me.modmuss50.optifabric.util.MixinUtils; - -public class RenderingDataExtraMixinPlugin extends InterceptingMixinPlugin { - @Override - public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - if ("ChunkRendererRegionMixin".equals(mixinInfo.getName())) { - ClassInfo info = ClassInfo.forName(targetClassName); - MixinUtils.completeClassInfo(info, targetClass.methods); - } - - super.preApply(targetClassName, targetClass, mixinClassName, mixinInfo); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/mixin/ChunkRendererRegionBuilderMixin.java b/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/mixin/ChunkRendererRegionBuilderMixin.java deleted file mode 100644 index 4b9d5598..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/mixin/ChunkRendererRegionBuilderMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.modmuss50.optifabric.compat.fabricrenderingdata.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import net.minecraft.class_6850; -import net.minecraft.class_6850.class_6851; -import net.minecraft.client.render.chunk.ChunkRendererRegion; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(class_6850.class) -@InterceptingMixin({"net/fabricmc/fabric/mixin/rendering/data/attachment/client/MixinChunkRendererRegionBuilder", "net/fabricmc/fabric/mixin/rendering/data/attachment/client/ChunkRendererRegionBuilderMixin"}) -abstract class ChunkRendererRegionBuilderMixin { - @PlacatingSurrogate - private void create(World world, BlockPos startPos, BlockPos endPos, int chunkRadius, CallbackInfoReturnable call) { - } - - @Inject(at = @At("RETURN"), method = "createRegion", remap = false, locals = LocalCapture.CAPTURE_FAILHARD) - private void createOF(World world, BlockPos startPos, BlockPos endPos, int chunkRadius, boolean checkEmpty, CallbackInfoReturnable call, int i, int j, int k, int l, class_6851[][] chunks) { - create(world, startPos, endPos, chunkRadius, call, i, k, j, l, chunks); - } - - @Shim - private native void create(World world, BlockPos startPos, BlockPos endPos, int chunkRadius, CallbackInfoReturnable call, int i, int j, int k, int l, class_6851[][] chunks); -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/mixin/ChunkRendererRegionMixin.java b/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/mixin/ChunkRendererRegionMixin.java deleted file mode 100644 index 88bb9d54..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/fabricrenderingdata/mixin/ChunkRendererRegionMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package me.modmuss50.optifabric.compat.fabricrenderingdata.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import net.minecraft.client.render.chunk.ChunkRendererRegion; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.WorldChunk; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(ChunkRendererRegion.class) -@InterceptingMixin({"net/fabricmc/fabric/mixin/rendering/data/attachment/client/MixinChunkRendererRegion", "net/fabricmc/fabric/mixin/rendering/data/attachment/client/ChunkRendererRegionMixin"}) -abstract class ChunkRendererRegionMixin { - @PlacatingSurrogate - private static void init(World world, BlockPos startPos, BlockPos endPos, int chunkRadius, CallbackInfoReturnable call) { - } - - @Inject(at = @At("RETURN"), method = "generateCache", remap = false, locals = LocalCapture.CAPTURE_FAILHARD) - private static void initOF(World world, BlockPos startPos, BlockPos endPos, int chunkRadius, boolean checkEmpty, CallbackInfoReturnable call, int i, int j, int k, int l, WorldChunk[][] chunks) { - init(world, startPos, endPos, chunkRadius, call, i, k, j, l, chunks); - } - - @Shim - private native static void init(World world, BlockPos startPos, BlockPos endPos, int chunkRadius, CallbackInfoReturnable call, int i, int j, int k, int l, WorldChunk[][] chunks); -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererMixin.java b/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererMixin.java deleted file mode 100644 index 955ff0af..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererMixin.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.modmuss50.optifabric.compat.fabricscreenapi.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 me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(GameRenderer.class) -@InterceptingMixin("net/fabricmc/fabric/mixin/screen/GameRendererMixin") -abstract class GameRendererMixin { - @Shim - private native void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(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, MatrixStack matrices) { - onBeforeRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } - - @Shim - private native void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(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, MatrixStack matrices) { - onAfterRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNew3erMixin.java b/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNew3erMixin.java deleted file mode 100644 index 1def470a..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNew3erMixin.java +++ /dev/null @@ -1,49 +0,0 @@ -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); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNew4erMixin.java b/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNew4erMixin.java deleted file mode 100644 index 32858d4f..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNew4erMixin.java +++ /dev/null @@ -1,49 +0,0 @@ -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); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNewMixin.java b/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNewMixin.java deleted file mode 100644 index 07d1ed57..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNewMixin.java +++ /dev/null @@ -1,50 +0,0 @@ -package me.modmuss50.optifabric.compat.fabricscreenapi.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 net.minecraft.util.math.Matrix4f; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(GameRenderer.class) -@InterceptingMixin("net/fabricmc/fabric/mixin/screen/GameRendererMixin") -abstract class GameRendererNewMixin { - @Shim - private native void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(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, Matrix4f projection, MatrixStack modelView, MatrixStack matrices) { - onBeforeRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } - - @Shim - private native void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(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, Matrix4f projection, MatrixStack modelView, MatrixStack matrices) { - onAfterRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNewerMixin.java b/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNewerMixin.java deleted file mode 100644 index 6cccf5fd..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNewerMixin.java +++ /dev/null @@ -1,50 +0,0 @@ -package me.modmuss50.optifabric.compat.fabricscreenapi.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 net.minecraft.util.math.Matrix4f; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(GameRenderer.class) -@InterceptingMixin("net/fabricmc/fabric/mixin/screen/GameRendererMixin") -abstract class GameRendererNewerMixin { - @Shim - private native void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(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 modelView, MatrixStack matrices) { - onBeforeRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } - - @Shim - private native void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @Inject(method = "render(FJZ)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(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 modelView, MatrixStack matrices) { - onAfterRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNewererMixin.java b/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNewererMixin.java deleted file mode 100644 index e9d4575d..00000000 --- a/src/main/java/me/modmuss50/optifabric/compat/fabricscreenapi/mixin/GameRendererNewererMixin.java +++ /dev/null @@ -1,51 +0,0 @@ -package me.modmuss50.optifabric.compat.fabricscreenapi.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 org.joml.Matrix4f; - -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.util.Window; -import net.minecraft.client.util.math.MatrixStack; - -import me.modmuss50.optifabric.compat.InterceptingMixin; -import me.modmuss50.optifabric.compat.PlacatingSurrogate; -import me.modmuss50.optifabric.compat.Shim; - -@Mixin(GameRenderer.class) -@InterceptingMixin("net/fabricmc/fabric/mixin/screen/GameRendererMixin") -abstract class GameRendererNewererMixin { - @Shim - private native void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @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 modelView, MatrixStack matrices) { - onBeforeRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } - - @Shim - private native void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, MatrixStack matrices); - - @PlacatingSurrogate - private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo call, int mouseX, int mouseY, Window window) { - } - - @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 modelView, MatrixStack matrices) { - onAfterRenderScreen(tickDelta, startTime, tick, call, mouseX, mouseY, matrices); - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/compat/fix/BlockEntityRenderDispatcherMixinFixer.java b/src/main/java/me/modmuss50/optifabric/compat/fix/BlockEntityRenderDispatcherMixinFixer.java new file mode 100644 index 00000000..f1fb5b3e --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/fix/BlockEntityRenderDispatcherMixinFixer.java @@ -0,0 +1,23 @@ +package me.modmuss50.optifabric.compat.fix; + +import me.modmuss50.optifabric.compat.MixinNodeTransformer; +import me.modmuss50.optifabric.util.RemappingUtils; + +import java.util.Collections; +import java.util.List; +import java.util.function.IntSupplier; + +public class BlockEntityRenderDispatcherMixinFixer implements IMixinFixer { + @Override + public List getTargets() { + return Collections.singletonList("svenhjol/charm/mixin/storage_labels/CallStorageLabelsRenderMixin"); + } + + @Override + public void fix(MixinNodeTransformer transformer) { + transformer.transformMethods("hookExtraRender", method -> { + IntSupplier lightIndex = method.getIndexCI(false, "I"); + method.addParams(lightIndex, 'L' + RemappingUtils.getClassName("class_1937") + ';'); + }); + } +} diff --git a/src/main/java/me/modmuss50/optifabric/compat/fix/CharmUtilMixinFixer.java b/src/main/java/me/modmuss50/optifabric/compat/fix/CharmUtilMixinFixer.java new file mode 100644 index 00000000..788cc6d0 --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/fix/CharmUtilMixinFixer.java @@ -0,0 +1,20 @@ +package me.modmuss50.optifabric.compat.fix; + +import me.modmuss50.optifabric.compat.MixinNodeTransformer; + +import java.util.Collections; +import java.util.List; + +public class CharmUtilMixinFixer implements IMixinFixer { + @Override + public List getTargets() { + return Collections.singletonList("svenhjol/charm/mixin/UtilMixin"); + } + + @Override + public void fix(MixinNodeTransformer transformer) { + String target = "Lorg/apache/logging/log4j/Logger;debug(Ljava/lang/String;Ljava/lang/Object;)V"; + transformer.transformMethods("hookAttemptDataFixInternal", method -> method.transformInjector(injector -> + injector.setAt(new MixinNodeTransformer.AtNode("INVOKE", target)))); + } +} diff --git a/src/main/java/me/modmuss50/optifabric/compat/fix/ChunkRendererRegionMixinFixer.java b/src/main/java/me/modmuss50/optifabric/compat/fix/ChunkRendererRegionMixinFixer.java new file mode 100644 index 00000000..3cd1525d --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/fix/ChunkRendererRegionMixinFixer.java @@ -0,0 +1,40 @@ +package me.modmuss50.optifabric.compat.fix; + +import me.modmuss50.optifabric.compat.MixinNodeTransformer; +import me.modmuss50.optifabric.mod.OptifabricSetup; + +import java.util.Arrays; +import java.util.List; +import java.util.function.IntSupplier; + +public class ChunkRendererRegionMixinFixer implements IMixinFixer { + @Override + public List getTargets() { + return Arrays.asList( + "net/fabricmc/fabric/mixin/rendering/data/attachment/client/MixinChunkRendererRegion", + "net/fabricmc/fabric/mixin/rendering/data/attachment/client/ChunkRendererRegionMixin", + "net/fabricmc/fabric/mixin/rendering/data/attachment/client/MixinChunkRendererRegionBuilder", + "net/fabricmc/fabric/mixin/rendering/data/attachment/client/ChunkRendererRegionBuilderMixin", + "net/fabricmc/fabric/mixin/blockview/client/ChunkRendererRegionBuilderMixin" + ); + } + + @Override + public void fix(MixinNodeTransformer transformer) { + List methods = Arrays.asList("create", "createDataMap"); + String newMethod; + if (OptifabricSetup.generateCachePresent) { + newMethod = "generateCache"; + } else if (OptifabricSetup.createRegionPresent) { + newMethod = "createRegion"; + } else { + return; + } + + transformer.transformMethods(methods, method -> { + IntSupplier chunkRadius = method.getIndex(true, "I"); + method.addParams(chunkRadius, "Z"); + method.transformInjector(injector -> injector.setMethod(newMethod)); + }); + } +} diff --git a/src/main/java/me/modmuss50/optifabric/compat/fix/GameRendererMixinFixer.java b/src/main/java/me/modmuss50/optifabric/compat/fix/GameRendererMixinFixer.java new file mode 100644 index 00000000..885b41b5 --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/fix/GameRendererMixinFixer.java @@ -0,0 +1,65 @@ +package me.modmuss50.optifabric.compat.fix; + +import com.google.common.collect.Lists; +import me.modmuss50.optifabric.compat.MixinNodeTransformer; +import me.modmuss50.optifabric.mod.OptifabricSetup; +import me.modmuss50.optifabric.util.RemappingUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.function.IntSupplier; + +public class GameRendererMixinFixer implements IMixinFixer { + @Override + public List getTargets() { + return Arrays.asList( + "net/fabricmc/fabric/mixin/screen/GameRendererMixin", + "dev/architectury/mixin/fabric/client/MixinGameRenderer", + "dev/architectury/mixin/fabric/client/MixinGameRenderer013", + "me/shedaniel/architectury/mixin/fabric/client/MixinGameRenderer", + "me/shedaniel/cloth/mixin/client/events/MixinGameRenderer"); + } + + @Override + public void fix(MixinNodeTransformer transformer) { + String window = 'L' + RemappingUtils.getClassName("class_1041") + ';'; + String matrixStack = 'L' + RemappingUtils.getClassName("class_4587") + ';'; + String matrix4f = 'L' + RemappingUtils.getClassName("class_1159") + ';'; + String drawContext = 'L' + RemappingUtils.getClassName("class_332") + ';'; + boolean useMatrix4f = OptifabricSetup.isPresent("minecraft", ">=1.17-alpha.21.10.a"); + boolean useJomlMatrix4F = OptifabricSetup.isPresent("minecraft", ">=1.19.3"); + boolean completeModelView = OptifabricSetup.isPresent("fabric-screen-api-v1", "<1.0.47"); + boolean useDrawContext = OptifabricSetup.isPresent("minecraft", ">=1.20"); + List fabricMethods = Arrays.asList("onBeforeRenderScreen", "onAfterRenderScreen"); + List methods = Lists.newArrayList("renderScreenPre", "renderScreenPost", "renderScreen"); + methods.addAll(fabricMethods); + + transformer.transformMethods(fabricMethods, method -> { + IntSupplier matrixStackIndex = method.getIndexCI(false, matrixStack); + List params = new ArrayList<>(); + params.add(window); //window + if (useMatrix4f) { + if (useJomlMatrix4F) { + params.add("Lorg/joml/Matrix4f;"); //projection + } else { + params.add(matrix4f); //projection + } + if (completeModelView) params.add(matrixStack); //modelView + } + method.addParams(matrixStackIndex, params.toArray(new String[0])); + OptifabricSetup.usingScreenAPI = true; + }); + + transformer.transformMethods(methods, method -> { + if (OptifabricSetup.farPlanePresent) { + IntSupplier windowIndex = method.getIndexCI(true, window); + method.addParams(windowIndex, "F"); //guiFarPlane + } + if (useDrawContext) { + IntSupplier drawContextIndex = method.getIndexCI(false, drawContext); + method.addParams(drawContextIndex, "F"); //guiOffsetZ + } + }); + } +} diff --git a/src/main/java/me/modmuss50/optifabric/compat/fix/IMixinFixer.java b/src/main/java/me/modmuss50/optifabric/compat/fix/IMixinFixer.java new file mode 100644 index 00000000..420edfd8 --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/fix/IMixinFixer.java @@ -0,0 +1,10 @@ +package me.modmuss50.optifabric.compat.fix; + +import me.modmuss50.optifabric.compat.MixinNodeTransformer; + +import java.util.List; + +public interface IMixinFixer { + List getTargets(); + void fix(MixinNodeTransformer transformer); +} diff --git a/src/main/java/me/modmuss50/optifabric/compat/fix/ModMixinFixer.java b/src/main/java/me/modmuss50/optifabric/compat/fix/ModMixinFixer.java new file mode 100644 index 00000000..b6a71bce --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/fix/ModMixinFixer.java @@ -0,0 +1,30 @@ +package me.modmuss50.optifabric.compat.fix; + +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class ModMixinFixer { + public static final ModMixinFixer INSTANCE = new ModMixinFixer(); + + private final List classFixes = new ArrayList<>(); + + private ModMixinFixer() { + addFixer(new BlockEntityRenderDispatcherMixinFixer()); + addFixer(new CharmUtilMixinFixer()); + addFixer(new ChunkRendererRegionMixinFixer()); + addFixer(new GameRendererMixinFixer()); + addFixer(new ModelLoaderBakerImplFixer()); + addFixer(new TextureAtlasMixinFixer()); + } + + public void addFixer(IMixinFixer fixer) { + classFixes.add(fixer); + } + + public List getFixers(IMixinInfo mixin) { + return classFixes.stream().filter(fixer -> fixer.getTargets().contains(mixin.getClassRef())).collect(Collectors.toList()); + } +} diff --git a/src/main/java/me/modmuss50/optifabric/compat/fix/ModelLoaderBakerImplFixer.java b/src/main/java/me/modmuss50/optifabric/compat/fix/ModelLoaderBakerImplFixer.java new file mode 100644 index 00000000..6de6dd3b --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/fix/ModelLoaderBakerImplFixer.java @@ -0,0 +1,27 @@ +package me.modmuss50.optifabric.compat.fix; + +import me.modmuss50.optifabric.compat.MixinNodeTransformer; +import me.modmuss50.optifabric.util.RemappingUtils; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class ModelLoaderBakerImplFixer implements IMixinFixer { + @Override + public List getTargets() { + return Collections.singletonList("net/fabricmc/fabric/mixin/client/model/loading/ModelLoaderBakerImplMixin"); + } + + @Override + public void fix(MixinNodeTransformer transformer) { + String bakeDesc = RemappingUtils.mapMethodDescriptor("(Lnet/minecraft/class_2960;Lnet/minecraft/class_3665;Ljava/util/function/Function;)Lnet/minecraft/class_1087;"); + String optifineBake = 'L' + RemappingUtils.getClassName("class_1088$class_7778") + ";bake" + bakeDesc; + transformer.transformMethods("invokeModifyBeforeBake", method -> { + method.addParams("Ljava/util/function/Function;"); + }); + transformer.transformMethods(Arrays.asList("invokeModifyAfterBake", "invokeModifyBeforeBake"), method -> { + method.transformInjector(injector -> injector.setMethod(optifineBake)); + }); + } +} diff --git a/src/main/java/me/modmuss50/optifabric/compat/fix/TextureAtlasMixinFixer.java b/src/main/java/me/modmuss50/optifabric/compat/fix/TextureAtlasMixinFixer.java new file mode 100644 index 00000000..d37d08f0 --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/compat/fix/TextureAtlasMixinFixer.java @@ -0,0 +1,33 @@ +package me.modmuss50.optifabric.compat.fix; + +import me.modmuss50.optifabric.compat.MixinNodeTransformer; + +import java.util.Arrays; +import java.util.List; +import java.util.function.IntSupplier; + +public class TextureAtlasMixinFixer implements IMixinFixer { + + @Override + public List getTargets() { + return Arrays.asList( + "me/shedaniel/architectury/mixin/fabric/client/MixinTextureAtlas", + "dev/architectury/mixin/fabric/client/MixinTextureAtlas", + "svenhjol/meson/mixin/SpriteAtlasTextureMixin", + "svenhjol/charm/mixin/SpriteAtlasTextureMixin", + "svenhjol/charm/mixin/event/StitchTextureMixin", + "svenhjol/charm/mixin/callback/StitchTextureCallbackMixin"); + } + + @Override + public void fix(MixinNodeTransformer transformer) { + transformer.transformMethods(Arrays.asList("preStitch", "hookStitch"), method -> { + IntSupplier setIndex = method.getIndexCI(false, "Ljava/util/Set;"); + /* + Normally Optifine's mipmapLevels (lv) should be passed instead of the method argument with the + same name (which Optifine calls maxMipmapLevelIn), but these injectors only care about the set + */ + method.addParams(setIndex, "I"); + }); + } +} diff --git a/src/main/java/me/modmuss50/optifabric/mixin/MixinTitleScreen.java b/src/main/java/me/modmuss50/optifabric/mixin/MixinTitleScreen.java index 5f44581d..92e3e420 100644 --- a/src/main/java/me/modmuss50/optifabric/mixin/MixinTitleScreen.java +++ b/src/main/java/me/modmuss50/optifabric/mixin/MixinTitleScreen.java @@ -47,6 +47,21 @@ private void init(CallbackInfo info) { String actionButtonText, helpButtonText; BooleanConsumer action; + //TODO: refactor (almost) everything here + if (OptifabricError.modError) { + String stack = OptifabricError.getErrorLog(); + actionButtonText = stack != null ? "Copy stack-trace" : "Open logs folder"; + helpButtonText = "Open issues"; + action = help -> { + if (help) { + Util.getOperatingSystem().open("https://github.com/Chocohead/OptiFabric/issues"); + } else if (stack != null) { + client.keyboard.setClipboard(stack); + } else { + Util.getOperatingSystem().open(new File(FabricLoader.getInstance().getGameDirectory(), "logs")); + } + }; + } else { switch (OptifineVersion.jarType) { case SOMETHING_ELSE: //Valid jar states, we shouldn't be here case OPTIFINE_INSTALLER: @@ -85,6 +100,7 @@ private void init(CallbackInfo info) { break; } } + } client.openScreen(new ConfirmScreen(action, Text.literal("There was an error loading OptiFabric!", Formatting.RED), Text.literal(OptifabricError.getError()), Text.literal(helpButtonText, Formatting.GREEN), Text.literal(actionButtonText))); diff --git a/src/main/java/me/modmuss50/optifabric/mod/FeatureFinder.java b/src/main/java/me/modmuss50/optifabric/mod/FeatureFinder.java deleted file mode 100644 index d52c4acd..00000000 --- a/src/main/java/me/modmuss50/optifabric/mod/FeatureFinder.java +++ /dev/null @@ -1,19 +0,0 @@ -package me.modmuss50.optifabric.mod; - -import java.util.function.BooleanSupplier; - -public abstract class FeatureFinder implements BooleanSupplier { - private boolean haveLooked, isPresent; - - protected abstract boolean isPresent(); - - @Override - public boolean getAsBoolean() { - if (!haveLooked) { - isPresent = isPresent(); - haveLooked = true; - } - - return isPresent; - } -} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/mod/OptifabricError.java b/src/main/java/me/modmuss50/optifabric/mod/OptifabricError.java index 3dcccedf..50d5ba96 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/OptifabricError.java +++ b/src/main/java/me/modmuss50/optifabric/mod/OptifabricError.java @@ -6,6 +6,8 @@ public class OptifabricError { private static String error; private static String stack; + //TODO: handle mod errors separately + public static boolean modError; public static boolean hasError() { return error != null; diff --git a/src/main/java/me/modmuss50/optifabric/mod/OptifabricSetup.java b/src/main/java/me/modmuss50/optifabric/mod/OptifabricSetup.java index 0a35c9c6..20610f6b 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/OptifabricSetup.java +++ b/src/main/java/me/modmuss50/optifabric/mod/OptifabricSetup.java @@ -2,7 +2,6 @@ import java.io.File; import java.util.Optional; -import java.util.function.BooleanSupplier; import java.util.function.Predicate; import java.util.regex.Pattern; @@ -10,6 +9,8 @@ import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.AbstractInsnNode; @@ -28,8 +29,11 @@ import net.fabricmc.loader.util.version.SemanticVersionImpl; import net.fabricmc.loader.util.version.SemanticVersionPredicateParser; +import me.modmuss50.optifabric.compat.MixinFixerExtension; +import me.modmuss50.optifabric.compat.OptifabricMixinErrorHandler; import me.modmuss50.optifabric.mod.OptifineVersion.JarType; import me.modmuss50.optifabric.patcher.ClassCache; +import me.modmuss50.optifabric.util.MixinInternals; import me.modmuss50.optifabric.util.RemappingUtils; import com.chocohead.mm.api.ClassTinkerers; @@ -37,10 +41,19 @@ public class OptifabricSetup implements Runnable { public static File optifineRuntimeJar = null; public static boolean usingScreenAPI; - - //This is called early on to allow us to get the transformers in beofore minecraft starts + public static final Logger LOGGER = LogManager.getLogger("OptiFabric"); + public static boolean particlesPresent; + public static boolean farPlanePresent; + public static boolean setupFogPresent; + public static boolean createRegionPresent; + public static boolean generateCachePresent; + + //This is called early on to allow us to get the transformers in before minecraft starts @Override public void run() { + MixinInternals.registerExtension(new MixinFixerExtension()); + Mixins.registerErrorHandlerClass(OptifabricMixinErrorHandler.class.getName()); + OptifineInjector injector; try { Pair runtime = OptifineSetup.getRuntime(); @@ -56,68 +69,46 @@ public void run() { OptifineVersion.jarType = JarType.INTERNAL_ERROR; OptifabricError.setError(e, "Failed to load OptiFine, please report this!\n\n" + e.getMessage()); } - System.err.println("Failed to setup optifine:"); - e.printStackTrace(); + LOGGER.error("Failed to setup optifine: ", e); return; //Avoid crashing out any other Fabric ASM users } - BooleanSupplier particlesPresent = new FeatureFinder() { - @Override - protected boolean isPresent() { - return injector.predictFuture(RemappingUtils.getClassName("class_702")).filter(node -> {//ParticleManager - //(MatrixStack, VertexConsumerProvider$Immediate, LightmapTextureManager, Camera, Frustum) - String desc = RemappingUtils.mapMethodDescriptor("(Lnet/minecraft/class_4587;Lnet/minecraft/class_4597$class_4598;" - + "Lnet/minecraft/class_765;Lnet/minecraft/class_4184;FLnet/minecraft/class_4604;)V"); - - for (MethodNode method : node.methods) { - if (("renderParticles".equals(method.name) || "render".equals(method.name)) && desc.equals(method.desc)) { - return true; - } - } + particlesPresent = injector.predictFuture(RemappingUtils.getClassName("class_702")).filter(node -> {//ParticleManager + //(MatrixStack, VertexConsumerProvider$Immediate, LightmapTextureManager, Camera, Frustum) + String desc = RemappingUtils.mapMethodDescriptor("(Lnet/minecraft/class_4587;Lnet/minecraft/class_4597$class_4598;" + + "Lnet/minecraft/class_765;Lnet/minecraft/class_4184;FLnet/minecraft/class_4604;)V"); - return false; - }).isPresent(); + for (MethodNode method : node.methods) { + if (("renderParticles".equals(method.name) || "render".equals(method.name)) && desc.equals(method.desc)) { + return true; + } } - }; - BooleanSupplier farPlanePresent = new FeatureFinder() { - @Override - protected boolean isPresent() { - return injector.predictFuture(RemappingUtils.getClassName("class_757")).filter(node -> {//GameRenderer - String render = RemappingUtils.getMethodName("class_757", "method_3192", "(FJZ)V"); - - for (MethodNode method : node.methods) { - if (render.equals(method.name) && "(FJZ)V".equals(method.desc)) { - for (AbstractInsnNode insn : method.instructions) { - if (insn.getType() == AbstractInsnNode.FIELD_INSN && "ForgeHooksClient_getGuiFarPlane".equals(((FieldInsnNode) insn).name)) { - return true; - } - } - - break; - } - } - return false; - }).isPresent(); - } - }; - BooleanSupplier setupFogPresent = new FeatureFinder() { - @Override - protected boolean isPresent() { - return injector.predictFuture(RemappingUtils.getClassName("class_758")).filter(node -> {//BackgroundRenderer - //(Camera, BackgroundRenderer$FogType) - String desc = RemappingUtils.mapMethodDescriptor("(Lnet/minecraft/class_4184;Lnet/minecraft/class_758$class_4596;FZF)V"); + return false; + }).isPresent(); + farPlanePresent = injector.predictFuture(RemappingUtils.getClassName("class_757")).filter(node -> {//GameRenderer + String render = RemappingUtils.getMethodName("class_757", "method_3192", "(FJZ)V"); - for (MethodNode method : node.methods) { - if ("setupFog".equals(method.name) && desc.equals(method.desc)) { + for (MethodNode method : node.methods) { + if (render.equals(method.name) && "(FJZ)V".equals(method.desc)) { + for (AbstractInsnNode insn : method.instructions) { + if (insn.getType() == AbstractInsnNode.FIELD_INSN && "ForgeHooksClient_getGuiFarPlane".equals(((FieldInsnNode) insn).name)) { return true; } } - return false; - }).isPresent(); + break; + } } - }; + + return false; + }).isPresent(); + setupFogPresent = injector.isMethodPresent("class_758", "setupFog", //BackgroundRenderer + "(Lnet/minecraft/class_4184;Lnet/minecraft/class_758$class_4596;FZF)V"); //Camera, FogType + String chunkDesc = "(Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_2338;IZ)" + + "Lnet/minecraft/class_853;"; //(World, BlockPos, BlockPos)ChunkRendererRegion + createRegionPresent = injector.isMethodPresent("class_6850", "createRegion", chunkDesc); + generateCachePresent = injector.isMethodPresent("class_853", "generateCache", chunkDesc); if (isPresent("fabric-renderer-api-v1")) { if (isPresent("minecraft", ">=1.19")) { @@ -127,7 +118,7 @@ protected boolean isPresent() { } } - if (isPresent("fabric-rendering-v1", ">=1.5.0") && particlesPresent.getAsBoolean()) { + if (isPresent("fabric-rendering-v1", ">=1.5.0") && particlesPresent) { if (isPresent("minecraft", ">=1.19.3")) { Mixins.addConfiguration("optifabric.compat.fabric-rendering.new-mixins.json"); } else { @@ -140,34 +131,6 @@ protected boolean isPresent() { if (isPresent("fabric-rendering-data-attachment-v1")) { Mixins.addConfiguration("optifabric.compat.fabric-rendering-data.mixins.json"); - - if (isPresent("fabric-rendering-data-attachment-v1", ">0.3.0")) { - //0.43.1+ and with a patch to ChunkRendererRegionBuilder - injector.predictFuture(RemappingUtils.getClassName("class_6850")).ifPresent(node -> {//ChunkRendererRegionBuilder, (World, BlockPos, BlockPos)ChunkRendererRegion - String desc = RemappingUtils.mapMethodDescriptor("(Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_2338;IZ)Lnet/minecraft/class_853;"); - - for (MethodNode method : node.methods) { - if ("createRegion".equals(method.name) && desc.equals(method.desc)) { - assert isPresent("minecraft", ">=1.18-rc.1"); - Mixins.addConfiguration("optifabric.compat.fabric-rendering-data.bonus-mixins.json"); - break; - } - } - }); - } else if (isPresent("fabric-rendering-data-attachment-v1", ">0.2.0")) { - //Below 0.43.1 and with a patch to ChunkRendererRegion - injector.predictFuture(RemappingUtils.getClassName("class_853")).ifPresent(node -> {//ChunkRendererRegion, (World, BlockPos, BlockPos)ChunkRendererRegion - String desc = RemappingUtils.mapMethodDescriptor("(Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_2338;IZ)Lnet/minecraft/class_853;"); - - for (MethodNode method : node.methods) { - if ("generateCache".equals(method.name) && desc.equals(method.desc)) { - assert isPresent("minecraft", ">=1.18-beta.1"); - Mixins.addConfiguration("optifabric.compat.fabric-rendering-data.extra-mixins.json"); - break; - } - } - }); - } } if (isPresent("fabric-renderer-indigo")) { @@ -209,25 +172,6 @@ protected boolean isPresent() { Mixins.addConfiguration("optifabric.compat.fabric-item-api.mixins.json"); } - if (isPresent("fabric-screen-api-v1")) { - if (isPresent("minecraft", ">=1.20")) { - Mixins.addConfiguration("optifabric.compat.fabric-screen-api.new4er-mixins.json"); - } else if (isPresent("fabric-api", ">=0.81.0")) { - Mixins.addConfiguration("optifabric.compat.fabric-screen-api.new3er-mixins.json"); - } else if (isPresent("minecraft", ">=1.19.3")) { - Mixins.addConfiguration("optifabric.compat.fabric-screen-api.newerer-mixins.json"); - } else if (isPresent("minecraft", ">=1.17-alpha.21.10.a")) { - if (farPlanePresent.getAsBoolean()) { - Mixins.addConfiguration("optifabric.compat.fabric-screen-api.newer-mixins.json"); - } else { - Mixins.addConfiguration("optifabric.compat.fabric-screen-api.new-mixins.json"); - } - } else { - Mixins.addConfiguration("optifabric.compat.fabric-screen-api.mixins.json"); - } - usingScreenAPI = true; - } - if (isPresent("fabric-lifecycle-events-v1", ">=1.4.6") && isPresent("minecraft", "1.17.x")) { Mixins.addConfiguration("optifabric.compat.fabric-lifecycle-events.mixins.json"); } else if (isPresent("fabric-lifecycle-events-v1", ">=2.0.8")) { @@ -239,19 +183,6 @@ protected boolean isPresent() { Mixins.addConfiguration("optifabric.optifine.old-mixins.json"); } - if (isPresent("fabricloader", ">=0.13.0") && (isPresent("cloth-client-events-v0", ">=3.1.58") || isPresent("cloth-client-events-v0", ">=2.1.60 <3.0") || isPresent("cloth-client-events-v0", ">=1.6.59 <2.0"))) { - // no mixins are needed -- cloth had a workaround for https://github.com/FabricMC/Mixin/issues/80 - // but it is now fixed in fabricloader - } else if (isPresent("cloth-client-events-v0", ">=2.0")) { - if (farPlanePresent.getAsBoolean()) { - Mixins.addConfiguration("optifabric.compat.cloth.newer-mixins.json"); - } else { - Mixins.addConfiguration("optifabric.compat.cloth.new-mixins.json"); - } - } else if (isPresent("cloth-client-events-v0")) { - Mixins.addConfiguration("optifabric.compat.cloth.mixins.json"); - } - if (isPresent("clothesline")) { Mixins.addConfiguration("optifabric.compat.clothesline.mixins.json"); } @@ -289,7 +220,7 @@ protected boolean isPresent() { if (isPresent("apoli", ">=2.3.1")) { Mixins.addConfiguration("optifabric.compat.apoli-newerer.mixins.json"); - if (setupFogPresent.getAsBoolean()) { + if (setupFogPresent) { Mixins.addConfiguration("optifabric.compat.apoli-newerer.extra-mixins.json"); } } else if (isPresent("apoli", ">=2.2.2")) { @@ -300,7 +231,7 @@ protected boolean isPresent() { Mixins.addConfiguration("optifabric.compat.apoli.mixins.json"); } - if (isPresent("additionalentityattributes") && setupFogPresent.getAsBoolean()) { + if (isPresent("additionalentityattributes") && setupFogPresent) { Mixins.addConfiguration("optifabric.compat.additional-entity-attributes.mixins.json"); } @@ -327,7 +258,7 @@ protected boolean isPresent() { Mixins.addConfiguration("optifabric.compat.carpet.mixins.json"); } - if (particlesPresent.getAsBoolean()) { + if (particlesPresent) { if (isPresent("minecraft", ">=1.18.2")) { Mixins.addConfiguration("optifabric.compat.carpet.extra-new-mixins.json"); } else { @@ -364,30 +295,6 @@ protected boolean isPresent() { Mixins.addConfiguration("optifabric.compat.age-of-exile.mixins.json"); } - if (isPresent("charm", ">=2.0 <2.1")) { - Mixins.addConfiguration("optifabric.compat.charm-older.mixins.json"); - } else if (isPresent("charm", ">=2.1 <3.0")) { - Mixins.addConfiguration("optifabric.compat.charm-old.mixins.json"); - - if (isPresent("charm", ">=2.2.2")) { - injector.predictFuture(RemappingUtils.getClassName("class_156")).ifPresent(node -> {//Util - String desc = "(Lcom/mojang/datafixers/DSL$TypeReference;Ljava/lang/String;)Lcom/mojang/datafixers/types/Type;"; - String getChoiceTypeInternal = RemappingUtils.getMethodName("class_156", "method_29191", desc); //Util, getChoiceTypeInternal - - for (MethodNode method : node.methods) { - if (getChoiceTypeInternal.equals(method.name) && desc.equals(method.desc)) { - Mixins.addConfiguration("optifabric.compat.charm-plus.mixins.json"); - break; - } - } - }); - } - } else if (isPresent("charm", ">=3.0 <4.0")) { - Mixins.addConfiguration("optifabric.compat.charm.mixins.json"); - } else if (isPresent("charm", ">=4.0")) { - Mixins.addConfiguration("optifabric.compat.charm-new.mixins.json"); - } - if (isPresent("voxelmap")) { Mixins.addConfiguration("optifabric.compat.voxelmap.mixins.json"); } @@ -404,25 +311,6 @@ protected boolean isPresent() { Mixins.addConfiguration("optifabric.compat.images.mixins.json"); } - if (isPresent("architectury", ">=9.0.6")) { - Mixins.addConfiguration("optifabric.compat.architectury-AB.new4er-mixins.json"); - } else if (isPresent("architectury", ">=7.0.52")) { - Mixins.addConfiguration("optifabric.compat.architectury-AB.newererer-mixins.json"); - } else if (isPresent("architectury", ">=3.7")) { - Mixins.addConfiguration("optifabric.compat.architectury-AB.newerer-mixins.json"); - } else if (isPresent("architectury", ">=2.0")) { - assert isPresent("minecraft", ">=1.17-beta.1"); - if (farPlanePresent.getAsBoolean()) { - Mixins.addConfiguration("optifabric.compat.architectury-AB.newer-mixins.json"); - } else { - Mixins.addConfiguration("optifabric.compat.architectury-AB.new-mixins.json"); - } - } else if (isPresent("architectury", ">=1.0.20")) { - Mixins.addConfiguration("optifabric.compat.architectury-B.mixins.json"); - } else if (isPresent("architectury", ">=1.0.4")) { - Mixins.addConfiguration("optifabric.compat.architectury-A.mixins.json"); - } - if (isPresent("frex", ">=4.3")) { Mixins.addConfiguration("optifabric.compat.frex.mixins.json"); } else if (isPresent("frex", "=4.2")) { @@ -473,7 +361,7 @@ protected boolean isPresent() { } } - if (isPresent("cullparticles") && particlesPresent.getAsBoolean()) { + if (isPresent("cullparticles") && particlesPresent) { Mixins.addConfiguration("optifabric.compat.cullparticles.mixins.json"); } @@ -536,11 +424,11 @@ protected boolean isPresent() { } } - private static boolean isPresent(String modID) { + public static boolean isPresent(String modID) { return FabricLoader.getInstance().isModLoaded(modID); } - static boolean isPresent(String modID, String versionRange) { + public static boolean isPresent(String modID, String versionRange) { return isPresent(modID, modMetadata -> compareVersions(versionRange, modMetadata)); } @@ -561,8 +449,7 @@ private static boolean compareVersions(String versionRange, ModMetadata mod) { SemanticVersionImpl version = new SemanticVersionImpl(mod.getVersion().getFriendlyString(), false); return predicate.test(version); } catch (@SuppressWarnings("deprecation") net.fabricmc.loader.util.version.VersionParsingException e) { - System.err.println("Error comparing the version for ".concat(MoreObjects.firstNonNull(mod.getName(), mod.getId()))); - e.printStackTrace(); + LOGGER.error("Error comparing the version for ".concat(MoreObjects.firstNonNull(mod.getName(), mod.getId())), e); return false; //Let's just gamble on the version not being valid also not being a problem } } diff --git a/src/main/java/me/modmuss50/optifabric/mod/OptifineInjector.java b/src/main/java/me/modmuss50/optifabric/mod/OptifineInjector.java index ae2f7bd0..09b2e424 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/OptifineInjector.java +++ b/src/main/java/me/modmuss50/optifabric/mod/OptifineInjector.java @@ -6,6 +6,7 @@ import java.util.Set; import java.util.function.Consumer; +import me.modmuss50.optifabric.util.RemappingUtils; import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.FieldNode; @@ -31,6 +32,12 @@ public OptifineInjector(ClassCache classCache) { this.classCache = classCache; } + public boolean isMethodPresent(String owner, String name, String desc) { + String remappedDesc = RemappingUtils.mapMethodDescriptor(desc); + return predictFuture(RemappingUtils.getClassName(owner)).filter(node -> node.methods.stream().anyMatch( + methodNode -> name.equals(methodNode.name) && remappedDesc.equals(methodNode.desc))).isPresent(); + } + public Optional predictFuture(String className) { byte[] bytes = classCache.getClass(className); return bytes != null ? Optional.of(ASMUtils.readClass(bytes)) : Optional.empty(); @@ -40,7 +47,7 @@ public void setup() { Consumer transformer = target -> { //Avoid double patching things, not that this should happen if (!patched.add(target.name)) { - System.err.println("Already patched " + target.name); + OptifabricSetup.LOGGER.error("Already patched " + target.name); return; } diff --git a/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java b/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java index 619a98ac..07d7f5ee 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java +++ b/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java @@ -90,7 +90,7 @@ public static Pair getRuntime() throws IOException { //Validate that the classCache found is for the same input jar if (Arrays.equals(classCache.getHash(), modHash)) { - System.out.println("Found existing patched optifine jar, using that"); + OptifabricSetup.LOGGER.info("Found existing patched optifine jar, using that"); if (classCache.isConverted()) { classCache.save(optifinePatches); @@ -98,10 +98,10 @@ public static Pair getRuntime() throws IOException { return Pair.of(remappedJar, classCache); } else { - System.out.println("Class cache is from a different optifine jar, deleting and re-generating"); + OptifabricSetup.LOGGER.info("Class cache is from a different optifine jar, deleting and re-generating"); } } else { - System.out.println("Setting up optifine for the first time, this may take a few seconds."); + OptifabricSetup.LOGGER.info("Setting up optifine for the first time, this may take a few seconds."); } Path minecraftJar = getMinecraftJar(); @@ -134,7 +134,7 @@ public static Pair getRuntime() throws IOException { File jarOfTheFree = new File(workDir, "Optifine-jarofthefree.jar"); LambdaRebuilder rebuilder = new LambdaRebuilder(minecraftJar.toFile()); - System.out.println("De-Volderfiying jar"); + OptifabricSetup.LOGGER.info("De-Volderfiying jar"); //Find all the SRG named classes and remove them ZipUtils.transform(optifineModJar, new ZipTransformer() { @@ -152,7 +152,7 @@ public InputStream apply(ZipFile zip, ZipEntry entry) throws IOException { if (!name.startsWith("srg/")) { if (name.endsWith(".class") && !name.startsWith("net/") && !name.startsWith("notch/net/") && !name.startsWith("optifine/") && !name.startsWith("javax/")) { - //System.out.println("Finding lambdas to fix in ".concat(name)); + //OptifabricSetup.LOGGER.info("Finding lambdas to fix in ".concat(name)); ClassNode node = ASMUtils.readClass(zip, entry); rebuilder.findLambdas(node); @@ -185,7 +185,7 @@ public InputStream apply(ZipFile zip, ZipEntry entry) throws IOException { rebuilder.close(); String namespace = FabricLoader.getInstance().getMappingResolver().getCurrentRuntimeNamespace(); - System.out.println("Remapping optifine from official to " + namespace); + OptifabricSetup.LOGGER.info("Remapping optifine from official to " + namespace); File completeJar = new File(workDir, "Optifine-remapped.jar"); remapOptifine(jarOfTheFree, getLibs(minecraftJar), completeJar, createMappings("official", namespace, rebuilder)); @@ -197,7 +197,7 @@ public InputStream apply(ZipFile zip, ZipEntry entry) throws IOException { Consumer jarFinaliser; if (remappedJar.exists() && !remappedJar.delete()) { - System.err.println("Failed to clear " + remappedJar + ", is another instance of the game running?"); + OptifabricSetup.LOGGER.error("Failed to clear " + remappedJar + ", is another instance of the game running?"); remappedJar = completedJar; jarFinaliser = visitor -> ZipUtils.filterInPlace(completedJar, visitor); } else { @@ -205,7 +205,7 @@ public InputStream apply(ZipFile zip, ZipEntry entry) throws IOException { jarFinaliser = visitor -> ZipUtils.filter(completedJar, visitor, finalRemappedJar); } if (optifinePatches.exists() && !optifinePatches.delete()) { - System.err.println("Failed to clear " + optifinePatches + ", is another instance of the game running?"); + OptifabricSetup.LOGGER.error("Failed to clear " + optifinePatches + ", is another instance of the game running?"); optifinePatches = new File(workDir, "Optifine.classes.gz"); } @@ -215,7 +215,7 @@ public InputStream apply(ZipFile zip, ZipEntry entry) throws IOException { boolean extract = Boolean.getBoolean("optifabric.extract"); if (extract) { - System.out.println("Extracting optifine classes"); + OptifabricSetup.LOGGER.info("Extracting optifine classes"); File optifineClasses = new File(versionDir, "optifine-classes"); if(optifineClasses.exists()){ FileUtils.deleteDirectory(optifineClasses); @@ -227,7 +227,7 @@ public InputStream apply(ZipFile zip, ZipEntry entry) throws IOException { } private static void runInstaller(File installer, File output, File minecraftJar) throws IOException { - System.out.println("Running optifine patcher"); + OptifabricSetup.LOGGER.info("Running optifine patcher"); try (URLClassLoader classLoader = new URLClassLoader(new URL[] {installer.toURI().toURL()}, OptifineSetup.class.getClassLoader())) { Class clazz = classLoader.loadClass("optifine.Patcher"); @@ -272,6 +272,12 @@ private static IMappingProvider createMappings(String from, String to, IMappingP ClassDef builtChunk = nameToClass.get("net/minecraft/class_846$class_851"); extraFields.put(new Member(rebuildTask.getName(from), "this$1", 'L' + builtChunk.getName(from) + ';'), "field_20839"); + ClassDef bakerImpl = nameToClass.get("net/minecraft/class_1088$class_7778"); + if (bakerImpl != null) {//Only present in 1.19.3+ + ClassDef modelLoader = nameToClass.get("net/minecraft/class_1088"); + extraFields.put(new Member(bakerImpl.getName(from), "this$0", 'L' + modelLoader.getName(from) + ';'), "field_40571"); + } + ClassDef particleManager = nameToClass.get("net/minecraft/class_702"); particleManager.getFields().stream().filter(field -> "field_3835".equals(field.getName("intermediary"))).forEach(field -> { extraFields.put(new Member(particleManager.getName(from), field.getName(from), "Ljava/util/Map;"), field.getName(to)); @@ -364,7 +370,7 @@ private static Path getMinecraftJar() { if (givenJarFile.exists()) { return givenJarFile.toPath(); } else { - System.err.println("Supplied Minecraft jar at " + givenJar + " doesn't exist, falling back"); + OptifabricSetup.LOGGER.error("Supplied Minecraft jar at " + givenJar + " doesn't exist, falling back"); } } @@ -450,7 +456,7 @@ private static ClassCache generateClassCache(Consumer from, File to, } }); - System.out.println("Found " + classCache.getClasses().size() + " patched classes"); + OptifabricSetup.LOGGER.info("Found " + classCache.getClasses().size() + " patched classes"); classCache.save(to); return classCache; } diff --git a/src/main/java/me/modmuss50/optifabric/mod/OptifineVersion.java b/src/main/java/me/modmuss50/optifabric/mod/OptifineVersion.java index 5ae3b4c3..da13312c 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/OptifineVersion.java +++ b/src/main/java/me/modmuss50/optifabric/mod/OptifineVersion.java @@ -111,7 +111,7 @@ private static JarType getJarType(File file) throws IOException { } } catch (IOException | IllegalStateException e) { OptifabricError.setError(e, "Failed to find current minecraft version, please report this"); - e.printStackTrace(); + OptifabricSetup.LOGGER.error(e); return JarType.INTERNAL_ERROR; } diff --git a/src/main/java/me/modmuss50/optifabric/patcher/LambdaRebuilder.java b/src/main/java/me/modmuss50/optifabric/patcher/LambdaRebuilder.java index 6d02f074..5dc07e83 100644 --- a/src/main/java/me/modmuss50/optifabric/patcher/LambdaRebuilder.java +++ b/src/main/java/me/modmuss50/optifabric/patcher/LambdaRebuilder.java @@ -31,6 +31,7 @@ import com.google.common.collect.Sets; import com.google.common.util.concurrent.Runnables; +import me.modmuss50.optifabric.mod.OptifabricSetup; import org.apache.commons.lang3.tuple.Pair; import it.unimi.dsi.fastutil.objects.Object2IntMap; @@ -204,7 +205,7 @@ private int findLambdas(String className, List original, List commonMethods, M boolean vague = !from.desc.equals(to.desc); //Are we trying to fudge a fix? if (vague && !ALLOW_VAGUE_EQUIVALENCE) { - System.err.println("Description changed remapping lambda handle: " + className + '#' + from.name + from.desc + " => " + className + '#' + to.name + to.desc); + OptifabricSetup.LOGGER.warn("Description changed remapping lambda handle: {}#{}{} => {}#{}{}", className, from.name, from.desc, className, to.name, to.desc); return false; //Don't add the fix if it is wrong } else if (vague) { - System.out.printf("Fuzzing %s#%s%s as %s%s%n", className, from.name, from.desc, to.name, to.desc); + OptifabricSetup.LOGGER.warn("Fuzzing {}#{}{} as {}{}", className, from.name, from.desc, to.name, to.desc); fuzzes.put(new Member(className, from.name, from.desc), Pair.of(to.name, to.desc)); } else { diff --git a/src/main/java/me/modmuss50/optifabric/patcher/fixes/ChunkRendererFix.java b/src/main/java/me/modmuss50/optifabric/patcher/fixes/ChunkRendererFix.java index c756d46e..249e97eb 100644 --- a/src/main/java/me/modmuss50/optifabric/patcher/fixes/ChunkRendererFix.java +++ b/src/main/java/me/modmuss50/optifabric/patcher/fixes/ChunkRendererFix.java @@ -2,6 +2,7 @@ import java.util.ListIterator; +import me.modmuss50.optifabric.mod.OptifabricSetup; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AbstractInsnNode; @@ -53,7 +54,7 @@ public void fix(ClassNode classNode, ClassNode old) { + "ZL" + (!nativeRandom ? "net/minecraft/class_5819;)V" : "java/util/Random;)Z"); String name = RemappingUtils.getMethodName("class_776", "method_3355", desc); - System.out.println(String.format("Replacement `renderBlock` call: %s.%s", name, desc)); + OptifabricSetup.LOGGER.info("Replacement `renderBlock` call: {}.{}", name, desc); //Replaces the method call with the vanilla one, this calls down to the same method just without the forge model data methodInsnNode.name = name; diff --git a/src/main/java/me/modmuss50/optifabric/util/MixinInternals.java b/src/main/java/me/modmuss50/optifabric/util/MixinInternals.java new file mode 100644 index 00000000..78c0f883 --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/util/MixinInternals.java @@ -0,0 +1,104 @@ +package me.modmuss50.optifabric.util; + +import org.apache.commons.lang3.tuple.Pair; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.MixinEnvironment; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import org.spongepowered.asm.mixin.transformer.ClassInfo; +import org.spongepowered.asm.mixin.transformer.IMixinTransformer; +import org.spongepowered.asm.mixin.transformer.ext.Extensions; +import org.spongepowered.asm.mixin.transformer.ext.IExtension; +import org.spongepowered.asm.mixin.transformer.ext.ITargetClassContext; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; + +@SuppressWarnings("unchecked") +public class MixinInternals { + private static final Field TARGET_CLASS_CONTEXT_MIXINS_FIELD; + private static final Method MIXIN_INFO_GET_STATE_METHOD; + private static final Field STATE_CLASS_NODE_FIELD; + private static final Field STATE_CLASS_INFO_FIELD; + private static final Field CLASS_INFO_METHODS_FIELD; + private static final Field EXTENSIONS_FIELD; + private static final Field ACTIVE_EXTENSIONS_FIELD; + + static { + try { + Class TargetClassContext = Class.forName("org.spongepowered.asm.mixin.transformer.TargetClassContext"); + TARGET_CLASS_CONTEXT_MIXINS_FIELD = TargetClassContext.getDeclaredField("mixins"); + TARGET_CLASS_CONTEXT_MIXINS_FIELD.setAccessible(true); + Class MixinInfo = Class.forName("org.spongepowered.asm.mixin.transformer.MixinInfo"); + MIXIN_INFO_GET_STATE_METHOD = MixinInfo.getDeclaredMethod("getState"); + MIXIN_INFO_GET_STATE_METHOD.setAccessible(true); + Class State = Class.forName("org.spongepowered.asm.mixin.transformer.MixinInfo$State"); + STATE_CLASS_NODE_FIELD = State.getDeclaredField("classNode"); + STATE_CLASS_NODE_FIELD.setAccessible(true); + STATE_CLASS_INFO_FIELD = State.getDeclaredField("classInfo"); + STATE_CLASS_INFO_FIELD.setAccessible(true); + CLASS_INFO_METHODS_FIELD = ClassInfo.class.getDeclaredField("methods"); + CLASS_INFO_METHODS_FIELD.setAccessible(true); + EXTENSIONS_FIELD = Extensions.class.getDeclaredField("extensions"); + EXTENSIONS_FIELD.setAccessible(true); + ACTIVE_EXTENSIONS_FIELD = Extensions.class.getDeclaredField("activeExtensions"); + ACTIVE_EXTENSIONS_FIELD.setAccessible(true); + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + throw new RuntimeException("Failed to access some mixin internals!", e); + } + } + + public static List> getMixinsFor(ITargetClassContext context) { + try { + List> result = new ArrayList<>(); + SortedSet mixins = (SortedSet) TARGET_CLASS_CONTEXT_MIXINS_FIELD.get(context); + for (IMixinInfo mixin : mixins) { + result.add(Pair.of(mixin, getClassNode(mixin))); + } + return result; + } catch (IllegalAccessException e) { + throw new RuntimeException("Failed to use mixin internals!", e); + } + } + + public static ClassInfo getClassInfoFor(IMixinInfo mixinInfo) { + try { + Object state = MIXIN_INFO_GET_STATE_METHOD.invoke(mixinInfo); + return (ClassInfo) STATE_CLASS_INFO_FIELD.get(state); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } + + public static Set getClassInfoMethods(ClassInfo classInfo) { + try { + return (Set) CLASS_INFO_METHODS_FIELD.get(classInfo); + } catch (IllegalAccessException e) { + throw new RuntimeException("Failed to use mixin internals!", e); + } + } + + public static void registerExtension(IExtension extension) { + try { + IMixinTransformer transformer = (IMixinTransformer) MixinEnvironment.getDefaultEnvironment().getActiveTransformer(); + Extensions extensions = (Extensions) transformer.getExtensions(); + List extensionsList = (List) EXTENSIONS_FIELD.get(extensions); + extensionsList.add(extension); + List activeExtensions = new ArrayList<>((List) ACTIVE_EXTENSIONS_FIELD.get(extensions)); + activeExtensions.add(extension); + ACTIVE_EXTENSIONS_FIELD.set(extensions, Collections.unmodifiableList(activeExtensions)); + } catch (IllegalAccessException e) { + throw new RuntimeException("Failed to use mixin internals!", e); + } + } + + private static ClassNode getClassNode(IMixinInfo mixin) { + try { + Object state = MIXIN_INFO_GET_STATE_METHOD.invoke(mixin); + return (ClassNode) STATE_CLASS_NODE_FIELD.get(state); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException("Failed to use mixin internals!", e); + } + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 4d73bf81..ea83ff2b 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -36,7 +36,7 @@ }, "depends": { "fabricloader": ">=0.8.0", - "minecraft": ["1.16.1", "1.16.2", "1.16.3", "1.16.4", "1.16.5", "1.17-alpha.21.8.b", "1.17-beta.4", "1.17", "1.17.1", "1.18-beta.1", "1.18", "1.18.1", "1.18.2", "1.19", "1.19.1", "1.19.2", "1.19.3", "1.19.4", "1.20", "1.20.1"], + "minecraft": ["1.16.1", "1.16.2", "1.16.3", "1.16.4", "1.16.5", "1.17-alpha.21.8.b", "1.17-beta.4", "1.17", "1.17.1", "1.18", "1.18.1", "1.18.2", "1.19", "1.19.1", "1.19.2", "1.19.3", "1.19.4", "1.20", "1.20.1"], "mm": ">=2.0" }, "conflicts": { diff --git a/src/main/resources/optifabric.compat.architectury-A.mixins.json b/src/main/resources/optifabric.compat.architectury-A.mixins.json deleted file mode 100644 index a4f40733..00000000 --- a/src/main/resources/optifabric.compat.architectury-A.mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.architectury.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.architectury-AB.new-mixins.json b/src/main/resources/optifabric.compat.architectury-AB.new-mixins.json deleted file mode 100644 index 49362205..00000000 --- a/src/main/resources/optifabric.compat.architectury-AB.new-mixins.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.architectury.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNewMixin", - "SpriteAtlasTextureNewMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.architectury-AB.new4er-mixins.json b/src/main/resources/optifabric.compat.architectury-AB.new4er-mixins.json deleted file mode 100644 index 0482316d..00000000 --- a/src/main/resources/optifabric.compat.architectury-AB.new4er-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.architectury.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNew4erMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.architectury-AB.newer-mixins.json b/src/main/resources/optifabric.compat.architectury-AB.newer-mixins.json deleted file mode 100644 index 9e042286..00000000 --- a/src/main/resources/optifabric.compat.architectury-AB.newer-mixins.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.architectury.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNewerMixin", - "SpriteAtlasTextureNewMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.architectury-AB.newerer-mixins.json b/src/main/resources/optifabric.compat.architectury-AB.newerer-mixins.json deleted file mode 100644 index f18825e2..00000000 --- a/src/main/resources/optifabric.compat.architectury-AB.newerer-mixins.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.architectury.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNewererMixin", - "SpriteAtlasTextureNewMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.architectury-AB.newererer-mixins.json b/src/main/resources/optifabric.compat.architectury-AB.newererer-mixins.json deleted file mode 100644 index 3d927ebe..00000000 --- a/src/main/resources/optifabric.compat.architectury-AB.newererer-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.architectury.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNewerererMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.architectury-B.mixins.json b/src/main/resources/optifabric.compat.architectury-B.mixins.json deleted file mode 100644 index 1717d4d9..00000000 --- a/src/main/resources/optifabric.compat.architectury-B.mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.compat.architectury-A.mixins.json", - "package": "me.modmuss50.optifabric.compat.architectury.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "SpriteAtlasTextureMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.charm-new.mixins.json b/src/main/resources/optifabric.compat.charm-new.mixins.json deleted file mode 100644 index cbb9bf40..00000000 --- a/src/main/resources/optifabric.compat.charm-new.mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.charm.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "SpriteAtlasTextureNewMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.charm-old.mixins.json b/src/main/resources/optifabric.compat.charm-old.mixins.json deleted file mode 100644 index 2c363edb..00000000 --- a/src/main/resources/optifabric.compat.charm-old.mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.charm.mixin.old", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "SpriteAtlasTextureMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.charm-older.mixins.json b/src/main/resources/optifabric.compat.charm-older.mixins.json deleted file mode 100644 index ddd5c446..00000000 --- a/src/main/resources/optifabric.compat.charm-older.mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.charm.mixin.older", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "SpriteAtlasTextureMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.charm-plus.mixins.json b/src/main/resources/optifabric.compat.charm-plus.mixins.json deleted file mode 100644 index 9663df49..00000000 --- a/src/main/resources/optifabric.compat.charm-plus.mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.compat.charm-old.mixins.json", - "package": "me.modmuss50.optifabric.compat.charm.mixin.old", - "plugin": "me.modmuss50.optifabric.compat.charm.CharmMixinPlugin", - "mixins": [ - "UtilMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.charm.mixins.json b/src/main/resources/optifabric.compat.charm.mixins.json deleted file mode 100644 index e83a70ad..00000000 --- a/src/main/resources/optifabric.compat.charm.mixins.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.charm.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "BlockEntityRenderDispatcherMixin", - "SpriteAtlasTextureMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.cloth.mixins.json b/src/main/resources/optifabric.compat.cloth.mixins.json deleted file mode 100644 index 682b6cde..00000000 --- a/src/main/resources/optifabric.compat.cloth.mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.cloth.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "DummyMixinGameRenderer" - ] -} diff --git a/src/main/resources/optifabric.compat.cloth.new-mixins.json b/src/main/resources/optifabric.compat.cloth.new-mixins.json deleted file mode 100644 index 7782b6a8..00000000 --- a/src/main/resources/optifabric.compat.cloth.new-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.cloth.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNewMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.cloth.newer-mixins.json b/src/main/resources/optifabric.compat.cloth.newer-mixins.json deleted file mode 100644 index 773c5a2d..00000000 --- a/src/main/resources/optifabric.compat.cloth.newer-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.cloth.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNewerMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.fabric-rendering-data.bonus-mixins.json b/src/main/resources/optifabric.compat.fabric-rendering-data.bonus-mixins.json deleted file mode 100644 index 678816ec..00000000 --- a/src/main/resources/optifabric.compat.fabric-rendering-data.bonus-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.compat.fabric-rendering-data.mixins.json", - "package": "me.modmuss50.optifabric.compat.fabricrenderingdata.mixin", - "plugin": "me.modmuss50.optifabric.compat.fabricrenderingdata.RenderingDataBonusMixinPlugin", - "mixins": [ - "ChunkRendererRegionBuilderMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.fabric-rendering-data.extra-mixins.json b/src/main/resources/optifabric.compat.fabric-rendering-data.extra-mixins.json deleted file mode 100644 index ee971dbb..00000000 --- a/src/main/resources/optifabric.compat.fabric-rendering-data.extra-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.compat.fabric-rendering-data.mixins.json", - "package": "me.modmuss50.optifabric.compat.fabricrenderingdata.mixin", - "plugin": "me.modmuss50.optifabric.compat.fabricrenderingdata.RenderingDataExtraMixinPlugin", - "mixins": [ - "ChunkRendererRegionMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.fabric-screen-api.mixins.json b/src/main/resources/optifabric.compat.fabric-screen-api.mixins.json deleted file mode 100644 index fab09f74..00000000 --- a/src/main/resources/optifabric.compat.fabric-screen-api.mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.fabricscreenapi.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.fabric-screen-api.new-mixins.json b/src/main/resources/optifabric.compat.fabric-screen-api.new-mixins.json deleted file mode 100644 index 5dd9c267..00000000 --- a/src/main/resources/optifabric.compat.fabric-screen-api.new-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.fabricscreenapi.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNewMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.fabric-screen-api.new3er-mixins.json b/src/main/resources/optifabric.compat.fabric-screen-api.new3er-mixins.json deleted file mode 100644 index 6874bcbc..00000000 --- a/src/main/resources/optifabric.compat.fabric-screen-api.new3er-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.fabricscreenapi.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNew3erMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.fabric-screen-api.new4er-mixins.json b/src/main/resources/optifabric.compat.fabric-screen-api.new4er-mixins.json deleted file mode 100644 index 90213257..00000000 --- a/src/main/resources/optifabric.compat.fabric-screen-api.new4er-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.fabricscreenapi.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNew4erMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.fabric-screen-api.newer-mixins.json b/src/main/resources/optifabric.compat.fabric-screen-api.newer-mixins.json deleted file mode 100644 index 8074e930..00000000 --- a/src/main/resources/optifabric.compat.fabric-screen-api.newer-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.fabricscreenapi.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNewerMixin" - ] -} \ No newline at end of file diff --git a/src/main/resources/optifabric.compat.fabric-screen-api.newerer-mixins.json b/src/main/resources/optifabric.compat.fabric-screen-api.newerer-mixins.json deleted file mode 100644 index 53d66a29..00000000 --- a/src/main/resources/optifabric.compat.fabric-screen-api.newerer-mixins.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "optifabric.mixins.json", - "package": "me.modmuss50.optifabric.compat.fabricscreenapi.mixin", - "plugin": "me.modmuss50.optifabric.compat.InterceptingMixinPlugin", - "mixins": [ - "GameRendererNewererMixin" - ] -} \ No newline at end of file diff --git a/src/shim/java/net/minecraft/class_6850.java b/src/shim/java/net/minecraft/class_6850.java deleted file mode 100644 index 9bff371f..00000000 --- a/src/shim/java/net/minecraft/class_6850.java +++ /dev/null @@ -1,6 +0,0 @@ -package net.minecraft; - -public class class_6850 { - public static class class_6851 { - } -} \ No newline at end of file diff --git a/src/shim/java/org/joml/Matrix4f.java b/src/shim/java/org/joml/Matrix4f.java deleted file mode 100644 index da7bfe79..00000000 --- a/src/shim/java/org/joml/Matrix4f.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.joml; - -public class Matrix4f { -} \ No newline at end of file