mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 19:59:42 +00:00
Cleanup Fluid deprecations stuff.
This commit is contained in:
1 parent
22e99a2cff
commit
b4dc15a9cb
6 files changed
+7
-190
No files matched your search
@@ -13,7 +13,7 @@ public class FMLForgePlugin implements IFMLLoadingPlugin
|
||||
@Override
|
||||
public String[] getASMTransformerClass()
|
||||
{
|
||||
return new String[] { "net.minecraftforge.classloading.FluidIdTransformer" };
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package net.minecraftforge.classloading;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
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.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;;
|
||||
|
||||
public class FluidIdTransformer implements IClassTransformer {
|
||||
private static final String FLUID_TYPE = "net/minecraftforge/fluids/FluidStack";
|
||||
private static final String GETID_NAME = "getFluidID";
|
||||
private static final String LEGACY_FIELDNAME = "fluidID";
|
||||
private static final String GETID_DESC = "()I";
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null)
|
||||
return null;
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader(basicClass);
|
||||
classReader.accept(classNode, 0);
|
||||
|
||||
for (MethodNode m: classNode.methods)
|
||||
{
|
||||
for (ListIterator<AbstractInsnNode> it = m.instructions.iterator(); it.hasNext(); )
|
||||
{
|
||||
AbstractInsnNode insnNode = it.next();
|
||||
if (insnNode.getType() == AbstractInsnNode.FIELD_INSN)
|
||||
{
|
||||
FieldInsnNode fi = (FieldInsnNode)insnNode;
|
||||
if (FLUID_TYPE.equals(fi.owner) && LEGACY_FIELDNAME.equals(fi.name) && fi.getOpcode() == Opcodes.GETFIELD)
|
||||
{
|
||||
FMLLog.fine("Method %s.%s%s: Replacing GETFIELD fluidID with INVOKEVIRTUAL getFluidID", name, m.name, m.desc);
|
||||
it.remove();
|
||||
MethodInsnNode replace = new MethodInsnNode(Opcodes.INVOKEVIRTUAL, FLUID_TYPE, GETID_NAME, GETID_DESC, false);
|
||||
it.add(replace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
classNode.accept(writer);
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user