Skip to content

Commit

Permalink
Fix patches of charset, LP and TFCMedicinal
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Jan 29, 2024
1 parent d9a615e commit 73d8b4b
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 18 deletions.
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.5.2
mod_version=0.5.4
mod_base_package=com.cleanroommc.fugue
mod_authors=kappa_maintainer
mod_description=A mod that patch dead mods for Cleanroom
6 changes: 5 additions & 1 deletion src/main/java/com/cleanroommc/FugueLoadingPlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cleanroommc;

import com.cleanroommc.transformer.CommonRegistrar$Transformer;
import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.fml.common.Loader;
Expand Down Expand Up @@ -33,7 +34,7 @@ public class FugueLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
"EntityPlayerRayTraceTransformer",
"SplashProgressTransformerTransformer",
"InitializerTransformer",
"ClassBlockMultipartContainerHandlerTransformer",
"LogisticPipesTransformer",
"OpenDisksUnpackTransformer",
"SoundUnpackTransformer",
"EnumInputClassTransformer"
Expand Down Expand Up @@ -71,6 +72,9 @@ public static void unRegisterUselessTransformer() {
}
}
}
if (!Loader.isModLoaded("tfcmedicinal")) {
CommonRegistrar$Transformer.halt();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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.utils.colorspace.Colorspace;
import pl.asie.charset.lib.utils.colorspace.Colorspaces;
Expand All @@ -17,9 +18,14 @@
@Mixin(value = Colorspaces.class, remap = false)
@SuppressWarnings("unchecked")
public class ColorspacesMixin {
@Shadow private static Table<Colorspace, Colorspace, Function<float[], float[]>> conversionTable;
//@Shadow private static Table<Colorspace, Colorspace, Function<float[], float[]>> conversionTable;

@Redirect(method = "buildConversionTable", at = @At(value = "INVOKE", target = "Lcom/google/common/graph/ValueGraph;edgeValue(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"))
private static Object buildConversionTable(ValueGraph instance, Object object1, Object object2) {
return instance.edgeValue(object1, object2).get();
}

@Inject(method = "buildConversionTable", at = @At(value = "JUMP", opcode = Opcodes.IF_ICMPGE, ordinal = 3), cancellable = true)
/*@Inject(method = "buildConversionTable", at = @At(value = "JUMP", opcode = Opcodes.IF_ICMPGE, ordinal = 3), cancellable = true)
private static void buildConversionTable(ValueGraph<Colorspace, Function<float[], float[]>> conversionGraph,
CallbackInfo ci,
@Local(ordinal = 3) Colorspace[] path,
Expand All @@ -38,5 +44,5 @@ private static void buildConversionTable(ValueGraph<Colorspace, Function<float[]
conversionTable.put(from, to, function);
}
ci.cancel();
}
} */
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,25 @@
import org.objectweb.asm.tree.MethodNode;

public class CommonRegistrar$Transformer implements IClassTransformer {
private static boolean hit = false;
private static int hit = 3;

public static void halt() {
hit = 0;
}
@Override
public byte[] transform(String s, String s1, byte[] bytes) {
if (bytes == null)
{
return null;
}

if (hit || !s1.equals("com.lumintorious.tfcmedicinal.CommonRegistrar$"))
if (hit == 0 ||
(
!s1.equals("com.lumintorious.tfcmedicinal.CommonRegistrar$") &&
!s1.equals("com.lumintorious.tfcmedicinal.object.mpestle.MPestleRecipe$") &&
!s1.equals("com.lumintorious.tfcmedicinal.object.heater.HeaterRecipe")
)
)
{
return bytes;
}
Expand All @@ -45,15 +55,15 @@ public byte[] transform(String s, String s1, byte[] bytes) {
{
for (MethodNode methodNode : classNode.methods)
{
if (methodNode.name.equals("registerBarrelRecipes")) {
if (methodNode.name.equals("registerBarrelRecipes") || methodNode.name.equals("<init>")) {
InsnList instructions = methodNode.instructions;
if (instructions != null)
{
for (AbstractInsnNode insnNode : instructions)
{
if (insnNode.getOpcode() == Opcodes.INVOKESTATIC && insnNode instanceof MethodInsnNode methodInsnNode)
{
if (methodInsnNode.owner.equals("net/dries007/tfc/objects/inventory/ingredient/IIngredient") && methodInsnNode.name.equals("of"))
if (methodInsnNode.owner.equals("net/dries007/tfc/objects/inventory/ingredient/IIngredient") && (methodInsnNode.name.equals("of") || methodInsnNode.name.equals("empty")))
{
methodInsnNode.itf = true;
modified = true;
Expand All @@ -66,7 +76,7 @@ public byte[] transform(String s, String s1, byte[] bytes) {
}
if (modified)
{
hit = true;
hit--;
ClassWriter classWriter = new ClassWriter(0);

classNode.accept(classWriter);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.cleanroommc.transformer;

public class IHaltableTransformer {
static void halt(){}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,36 @@
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.*;

public class ClassBlockMultipartContainerHandlerTransformer implements IClassTransformer {
public ClassBlockMultipartContainerHandlerTransformer(){
public class LogisticPipesTransformer implements IClassTransformer {
public LogisticPipesTransformer(){
FugueLoadingPlugin.registerToKnownTransformer("logisticspipes", this);
}
private static int hit = 0;
@Override
public byte[] transform(String s, String s1, byte[] bytes) {
if (bytes == null)
{
return null;
}

if (!s1.equals("logisticspipes.asm.mcmp.ClassBlockMultipartContainerHandler"))

int match = 0;
if (s1.equals("logisticspipes.asm.mcmp.ClassBlockMultipartContainerHandler"))
{
match = 1;
}
if (s1.equals("logisticspipes.asm.td.ClassRenderDuctItemsHandler"))
{
match = 1;
}
if (s1.equals("logisticspipes.asm.td.ClassTravelingItemHandler"))
{
match = 3;
}
if (match == 0)
{
return bytes;
}


ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
Expand All @@ -33,7 +46,7 @@ public byte[] transform(String s, String s1, byte[] bytes) {
{
for (MethodNode methodNode : classNode.methods)
{
if (methodNode.name.equals("handleClass")) {
if (methodNode.name.equals("handleClass") || methodNode.name.equals("handleRenderDuctItemsClass")) {
InsnList instructions = methodNode.instructions;
if (instructions != null)
{
Expand All @@ -43,7 +56,11 @@ public byte[] transform(String s, String s1, byte[] bytes) {
{
instructions.insert(iConstNode, new InsnNode(Opcodes.ICONST_0));
instructions.remove(iConstNode);
modified = true;
match--;
if (match == 0) {
modified = true;
break;
}
}
}
}
Expand All @@ -52,7 +69,10 @@ public byte[] transform(String s, String s1, byte[] bytes) {
}
if (modified)
{
Launch.classLoader.unRegisterSuperTransformer(this);
hit++;
if (hit == 3) {
Launch.classLoader.unRegisterSuperTransformer(this);
}
ClassWriter classWriter = new ClassWriter(0);

classNode.accept(classWriter);
Expand Down

0 comments on commit 73d8b4b

Please sign in to comment.