Skip to content

Commit

Permalink
Add patch to Advanced Rocketry
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Jan 9, 2024
1 parent e3539e6 commit 45e36f7
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Also check [The Fugue Plane](https://forgottenrealms.fandom.com/wiki/Fugue_Plane
* Snow! Real Magic
* Botania Tweaks
* Aqua Acrobatics
* Advanced Rocketry

## Note
Add ! to start of the file name to fix Lag Goggles.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mappings_version=39-1.12
mod_id=fugue
mod_name=Fugue
mod_main_class=Fugue
mod_version=0.3.0
mod_version=0.3.1
mod_base_package=com.cleanroommc.fugue
mod_authors=kappa_maintainer
mod_description=A mod that patch dead mods for Cleanroom
4 changes: 3 additions & 1 deletion src/main/java/com/cleanroommc/FugueLoadingPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class FugueLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
static {
Launch.classLoader.addTransformerExclusionFilter("com.github.terminatornl.laggoggles.");
Launch.classLoader.addTransformerExclusionFilter("quaternary.botaniatweaks.");
Launch.classLoader.addTransformerExclusionFilter("zmaster587.advancedRocketry.asm.");
Launch.classLoader.registerTransformer("com.cleanroommc.transformer.InitializerTransformer");
}

Expand All @@ -22,7 +23,8 @@ public String[] getASMTransformerClass() {

return new String[]{
"com.cleanroommc.transformer.EnderCoreTransformerTransformer",
"com.cleanroommc.transformer.InitializerTransformer"
"com.cleanroommc.transformer.InitializerTransformer",
"com.cleanroommc.transformer.ClassTransformerTransformer"
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
import com.google.common.collect.Table;
import com.google.common.graph.ValueGraph;
import com.llamalad7.mixinextras.sugar.Local;
import org.checkerframework.checker.units.qual.A;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import pl.asie.charset.lib.loader.ModuleLoader;
import pl.asie.charset.lib.utils.colorspace.Colorspace;
import pl.asie.charset.lib.utils.colorspace.Colorspaces;

Expand All @@ -23,7 +20,6 @@ public class ColorspacesMixin {
@Shadow private static Table<Colorspace, Colorspace, Function<float[], float[]>> conversionTable;

@Inject(method = "buildConversionTable", at = @At(value = "JUMP", opcode = Opcodes.IF_ICMPGE, ordinal = 3), cancellable = true)
@SuppressWarnings("uncheck")
private static void buildConversionTable(ValueGraph<Colorspace, Function<float[], float[]>> conversionGraph,
CallbackInfo ci,
@Local(ordinal = 3) Colorspace[] path,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.cleanroommc.transformer;

import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.*;

public class ClassTransformerTransformer implements IClassTransformer {
private static boolean hit = false;
@Override
public byte[] transform(String s, String s1, byte[] bytes) {
if (bytes == null)
{
return null;
}

if (hit || !s1.equals("zmaster587.advancedRocketry.asm.ClassTransformer"))
{
return bytes;
}


ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
boolean modified = false;
AbstractInsnNode prevLine = null;
if (classNode.methods != null)
{
for (MethodNode methodNode : classNode.methods)
{
if (methodNode.name.equals("transform")) {
InsnList instructions = methodNode.instructions;
if (instructions != null)
{
for (AbstractInsnNode insnNode : instructions)
{
if (insnNode instanceof LineNumberNode lineNumberNode)
{
if (lineNumberNode.line == 693) {
instructions.remove(instructions.get(instructions.indexOf(lineNumberNode) + 1));
instructions.insert(lineNumberNode, new InsnNode(Opcodes.ICONST_0));
modified = true;
}
}
}
}
}
}
}
if (modified)
{
hit = true;
ClassWriter classWriter = new ClassWriter(0);

classNode.accept(classWriter);
return classWriter.toByteArray();
}
return bytes;
}
}

0 comments on commit 45e36f7

Please sign in to comment.