feat: replaced invasive PortalGui mod with patch
as of now it's just permanently on but some switch will come
This commit is contained in:
parent
5ac2a187ba
commit
6871d1dc3c
2 changed files with 53 additions and 20 deletions
|
@ -1,20 +0,0 @@
|
|||
package ftbsc.bscv.modules.self;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import ftbsc.bscv.ICommons;
|
||||
import ftbsc.bscv.api.ILoadable;
|
||||
import ftbsc.bscv.modules.AbstractModule;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
@AutoService(ILoadable.class)
|
||||
public class PortalGui extends AbstractModule implements ICommons {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent event) {
|
||||
if (MC.player == null) return;
|
||||
// TODO is there a more elegant way to do this?
|
||||
MC.player.isInsidePortal = false; // ACCESSTRANSFORMER
|
||||
}
|
||||
|
||||
}
|
53
src/main/java/ftbsc/bscv/patches/PortalGuiPatch.java
Normal file
53
src/main/java/ftbsc/bscv/patches/PortalGuiPatch.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package ftbsc.bscv.patches;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.JumpInsnNode;
|
||||
import org.objectweb.asm.tree.LabelNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import ftbsc.lll.processor.annotations.Injector;
|
||||
import ftbsc.lll.processor.annotations.Patch;
|
||||
import ftbsc.lll.processor.annotations.Target;
|
||||
import ftbsc.lll.tools.PatternMatcher;
|
||||
import ftbsc.lll.tools.debug.BytecodePrinter;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
|
||||
@Patch(value = ClientPlayerEntity.class, reason = "prevent minecraft from force closing guis when entering portals")
|
||||
public abstract class PortalGuiPatch implements Opcodes {
|
||||
@Target
|
||||
abstract void handleNetherPortalClient();
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
LabelNode skip = new LabelNode();
|
||||
|
||||
System.out.println("Finding first pattern");
|
||||
// BytecodePrinter.printAsmMethod(main);
|
||||
AbstractInsnNode found = PatternMatcher.builder()
|
||||
.opcodes(ALOAD, GETFIELD, IFEQ)
|
||||
.ignoreFrames()
|
||||
.ignoreLabels()
|
||||
.ignoreLineNumbers()
|
||||
.build()
|
||||
.find(main)
|
||||
.getLast();
|
||||
|
||||
System.out.println("Finding second pattern");
|
||||
AbstractInsnNode after = PatternMatcher.builder()
|
||||
.opcodes(GETFIELD, ACONST_NULL, CHECKCAST, INVOKEVIRTUAL)
|
||||
.ignoreFrames()
|
||||
.ignoreLabels()
|
||||
.ignoreLineNumbers()
|
||||
.build()
|
||||
.find(main)
|
||||
.getLast();
|
||||
|
||||
main.instructions.insert(found, new JumpInsnNode(GOTO, skip));
|
||||
main.instructions.insert(after, skip);
|
||||
|
||||
BytecodePrinter.printAsmMethod(main);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue