Skip to content

Commit

Permalink
Add falling block portal dupe patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldexun committed Apr 12, 2023
1 parent 3b54315 commit 15a2ff4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/charles445/rltweaker/asm/RLTweakerASM.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.charles445.rltweaker.asm.patch.PatchDoorPathfinding;
import com.charles445.rltweaker.asm.patch.PatchEnchant;
import com.charles445.rltweaker.asm.patch.PatchEntityBlockDestroy;
import com.charles445.rltweaker.asm.patch.PatchFallingBlockPortalDupe;
import com.charles445.rltweaker.asm.patch.PatchFixOldGorgon;
import com.charles445.rltweaker.asm.patch.PatchFixOldHippocampus;
import com.charles445.rltweaker.asm.patch.PatchHopper;
Expand Down Expand Up @@ -436,6 +437,11 @@ private void createPatches()
new PatchCustomAttributeInstances();
}

if(ASMConfig.getBoolean("general.patches.patchFallingBlockPortalDupe", false))
{
new PatchFallingBlockPortalDupe();
}

//new PatchForgeNetwork();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.charles445.rltweaker.asm.patch;

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.InsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;

import com.charles445.rltweaker.asm.util.ASMUtil;
import com.charles445.rltweaker.asm.util.TransformUtil;

public class PatchFallingBlockPortalDupe extends PatchManager {

public PatchFallingBlockPortalDupe() {
super("Patch Falling Block Portal Dupe");

this.add(new Patch(this, "net.minecraft.entity.item.EntityFallingBlock", ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES) {
@Override
public void patch(ClassNode clazzNode) {
MethodNode m_onUpdate = this.findMethod(clazzNode, "func_70071_h_", "onUpdate");

AbstractInsnNode target = ASMUtil.findMethodInsn(m_onUpdate, Opcodes.INVOKEVIRTUAL, "net/minecraft/entity/item/EntityFallingBlock", "func_70091_d", "move", "(Lnet/minecraft/entity/MoverType;DDD)V", 0);

LabelNode labelNode = new LabelNode();
m_onUpdate.instructions.insert(target, ASMUtil.listOf(
new VarInsnNode(Opcodes.ALOAD, 0),
TransformUtil.createObfFieldInsn(Opcodes.GETFIELD, "net/minecraft/entity/item/EntityFallingBlock", "field_70128_L", "Z"),
new JumpInsnNode(Opcodes.IFEQ, labelNode),
new InsnNode(Opcodes.RETURN),
labelNode));
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,11 @@ public class PatchConfig
@RLConfig.RLCraftTwoEightTwo("true")
@RLConfig.RLCraftTwoNine("true")
public boolean patchCustomAttributeInstances = true;

@Config.RequiresMcRestart
@Config.Comment("Fixes falling block portal dupe.")
@RLConfig.ImprovementsOnly("true")
@RLConfig.RLCraftTwoEightTwo("true")
@RLConfig.RLCraftTwoNine("true")
public boolean patchFallingBlockPortalDupe = true;
}

0 comments on commit 15a2ff4

Please sign in to comment.