mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-12 18:57:37 +00:00
tiny asm fixes
This commit is contained in:
2 files changed
+23
-5
No files matched your search
@@ -20,10 +20,14 @@ public class GameDataHooks {
|
||||
return gameData.endlessIDsItemBlockCache;
|
||||
}
|
||||
|
||||
//Called by ASM
|
||||
@SuppressWarnings("unused")
|
||||
public static void cacheItemBlock(ItemBlock itemBlock, GameData gameData) {
|
||||
forGameData(gameData).put(itemBlock.field_150939_a, new WeakReference<>(itemBlock));
|
||||
}
|
||||
|
||||
//Called by ASM
|
||||
@SuppressWarnings("unused")
|
||||
public static ItemBlock fetchCachedItemBlock(Block block, GameData gameData) {
|
||||
var weakItem = forGameData(gameData).get(block);
|
||||
if (weakItem != null) {
|
||||
@@ -32,6 +36,8 @@ public class GameDataHooks {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Called by ASM
|
||||
@SuppressWarnings("unused")
|
||||
public static Iterable<Item> fakeIterable() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.asm.AsmTransformException;
|
||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
||||
import com.falsepattern.endlessids.asm.IETransformer;
|
||||
import lombok.val;
|
||||
@@ -71,19 +72,30 @@ public class GameDataAccelerator implements IClassNodeTransformer {
|
||||
var iter = method.instructions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
var insn = iter.next();
|
||||
if (!(insn instanceof FieldInsnNode))
|
||||
if ((insn.getOpcode() != Opcodes.GETFIELD) && !(insn instanceof FieldInsnNode))
|
||||
continue;
|
||||
var fieldInsn = (FieldInsnNode) insn;
|
||||
if (!(fieldInsn.owner.equals("cpw/mods/fml/common/registry/GameData") &&
|
||||
fieldInsn.name.equals("iItemRegistry") &&
|
||||
fieldInsn.desc.equals("Lcpw/mods/fml/common/registry/FMLControlledNamespacedRegistry;")))
|
||||
continue;
|
||||
iter.previous();
|
||||
iter.previous();
|
||||
iter.remove();
|
||||
iter.next();
|
||||
{
|
||||
val testInsn = iter.previous();
|
||||
if (testInsn.getOpcode() != Opcodes.ALOAD || ((VarInsnNode)testInsn).var != 0)
|
||||
throw new AsmTransformException("Opcode assertion 1 failed!");
|
||||
}
|
||||
iter.remove();
|
||||
iter.next();
|
||||
{
|
||||
val testInsn = iter.next();
|
||||
if (testInsn.getOpcode() != Opcodes.INVOKEVIRTUAL)
|
||||
throw new AsmTransformException("Opcodes assertion 2 failed!");
|
||||
|
||||
val testInvoke = (MethodInsnNode)testInsn;
|
||||
if (!testInvoke.owner.equals("cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry") ||
|
||||
!testInvoke.name.equals("typeSafeIterable"))
|
||||
throw new AsmTransformException("Opcodes assertion 3 failed!");
|
||||
}
|
||||
iter.remove();
|
||||
iter.add(new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
|
||||
Reference in new issue
Block a user