Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Dec 8, 2024
1 parent f3bc5bc commit c7731da
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 6 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ Programmable Hatches Mod

注意,该MOD并非GTNH Mod Pack内的官方MOD,讨论此MOD时请注意场合。

如果在游玩本MOD的过程中遇到BUG或其他问题,请提交issue,必要时请附带复现方式与相关报错log。
如果在安装本MOD游玩的过程中遇到BUG或其他问题,请优先向本代码仓库提交issue而不是GTNH官方提交!

或者自行备份后移除本mod后确认问题不是来自本mod,再向官方提交。

提交issue必要时请附带复现方式与相关报错log。

## MOD安装须知

Expand Down Expand Up @@ -175,9 +179,6 @@ Programmable Hatches Mod

解决装配线自动化难题的好办法,具体使用方式游戏内查看tooltips。

* 警告锚

连入AE网络后,AE线缆所在的区块被卸载时将在聊天框内发出警告。

* OC扩展部件

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
import reobf.proghatches.block.TileIOHub.APIType;
import reobf.proghatches.main.Config;

public class DualInputHachOC extends DualInputHatch implements Environment,SidedEnvironment,IGridProxyable, IActionHost{
public class DualInputHachOC extends DualInputHatch implements reobf.proghatches.oc.IActualEnvironment, Environment,SidedEnvironment,IGridProxyable, IActionHost{


public DualInputHachOC(int id, String name, String nameRegional, int tier, boolean mMultiFluid
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/reobf/proghatches/main/asm/ASMCallbacks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package reobf.proghatches.main.asm;

import gregtech.api.metatileentity.CommonMetaTileEntity;
import gregtech.api.metatileentity.CoverableTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import reobf.proghatches.oc.IActualEnvironment;

public class ASMCallbacks {
public static boolean checkIsRealEnvironment(Object o){

if(o instanceof CommonMetaTileEntity){

CommonMetaTileEntity mte=(CommonMetaTileEntity) o;
if(mte.getMetaTileEntity() instanceof IActualEnvironment){


return o instanceof li.cil.oc.api.network.Environment;
}else{return false;}

}


return o instanceof li.cil.oc.api.network.Environment;
}
}
3 changes: 2 additions & 1 deletion src/main/java/reobf/proghatches/main/asm/FMLPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public String[] getASMTransformerClass() {
EUInterfaceTransformer.class.getName() ,
AEItemTransformer.class.getName() ,
MUITransformer.class.getName(),
DataCopyableTransformer.class.getName()
DataCopyableTransformer.class.getName(),
MFUTransformer.class.getName()

};
}
Expand Down
74 changes: 74 additions & 0 deletions src/main/java/reobf/proghatches/main/asm/MFUTransformer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package reobf.proghatches.main.asm;

import net.minecraft.launchwrapper.IClassTransformer;

import reobf.proghatches.main.asm.repack.objectwebasm.ClassReader;
import reobf.proghatches.main.asm.repack.objectwebasm.ClassWriter;
import reobf.proghatches.main.asm.repack.objectwebasm.MethodVisitor;
import reobf.proghatches.main.asm.repack.objectwebasm.Opcodes;
import reobf.proghatches.main.asm.repack.objectwebasm.tree.ClassNode;
import reobf.proghatches.main.asm.repack.objectwebasm.tree.MethodNode;

public class MFUTransformer implements IClassTransformer {boolean done;

@Override
public byte[] transform(String name, String transformedName, byte[] basicClass) {
if(!done)
if(name.equals("li.cil.oc.server.component.UpgradeMF")){
done=true;
ClassReader classReader = new ClassReader(basicClass);
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS|ClassWriter.COMPUTE_FRAMES);
ClassNode n=new ClassNode(Opcodes.ASM5){

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature,
String[] exceptions) {
if(name.equals("updateBoundState")){
MethodNode mn = new TheNode(access, name, desc, signature,exceptions){





};
methods.add(mn);
return mn;

}
return super.visitMethod(access, name, desc, signature, exceptions);
}
};

classReader.accept(n, ClassReader.EXPAND_FRAMES);
n.accept(classWriter);


return classWriter.toByteArray();

}





return basicClass;
}
static class TheNode extends MethodNode{

public TheNode(int access, String name, String desc, String signature, String[] exceptions) {
super(Opcodes.ASM5,access, name, desc, signature, exceptions);
}
@Override
public void visitTypeInsn(int opcode, String type) {
if(opcode==Opcodes.INSTANCEOF&&type.equals("li/cil/oc/api/network/Environment")){

super.visitMethodInsn(Opcodes.INVOKESTATIC, "reobf/proghatches/main/asm/ASMCallbacks", "checkIsRealEnvironment", "(Ljava/lang/Object;)Z", false);
return;

}
super.visitTypeInsn(opcode, type);
}

}

}
5 changes: 5 additions & 0 deletions src/main/java/reobf/proghatches/oc/IActualEnvironment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package reobf.proghatches.oc;

public interface IActualEnvironment {

}

0 comments on commit c7731da

Please sign in to comment.