Skip to content

Commit

Permalink
Reservoir対応
Browse files Browse the repository at this point in the history
  • Loading branch information
KatatsumuriPan committed Dec 7, 2023
1 parent 3fc3644 commit 25377c2
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import kpan.uti_alsofluids.asm.tf.integration.gregtech.TF_GTFluid$GTMaterialFluid;
import kpan.uti_alsofluids.asm.tf.integration.gregtech.TF_MetaTileEntityFluidHatch;
import kpan.uti_alsofluids.asm.tf.integration.gregtech.TF_MetaTileEntityQuantumTank;
import kpan.uti_alsofluids.asm.tf.integration.gregtech.TF_MetaTileEntityReservoirHatch;
import kpan.uti_alsofluids.asm.tf.integration.gregtech.TF_PhantomFluidWidget;
import kpan.uti_alsofluids.asm.tf.integration.gregtech.TF_TankWidget;
import kpan.uti_alsofluids.asm.tf.integration.jei.TF_FluidStackRenderer;
Expand Down Expand Up @@ -68,8 +69,9 @@ public byte[] transform(String name, String transformedName, byte[] bytes) {
cv = TF_GuiFluidTerminal.appendVisitor(cv, transformedName);
cv = TF_LanguageMapUs.appendVisitor(cv, transformedName);
cv = TF_GTFluid$GTMaterialFluid.appendVisitor(cv, transformedName);
cv = TF_MetaTileEntityQuantumTank.appendVisitor(cv, transformedName);
cv = TF_MetaTileEntityFluidHatch.appendVisitor(cv, transformedName);
cv = TF_MetaTileEntityQuantumTank.appendVisitor(cv, transformedName);
cv = TF_MetaTileEntityReservoirHatch.appendVisitor(cv, transformedName);
cv = TF_TankWidget.appendVisitor(cv, transformedName);
cv = TF_PhantomFluidWidget.appendVisitor(cv, transformedName);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package kpan.uti_alsofluids.asm.tf.integration.gregtech;

import kpan.uti_alsofluids.asm.core.AsmTypes;
import kpan.uti_alsofluids.asm.core.adapters.Instructions;
import kpan.uti_alsofluids.asm.core.adapters.Instructions.OpcodeInt;
import kpan.uti_alsofluids.asm.core.adapters.MyClassVisitor;
import kpan.uti_alsofluids.asm.core.adapters.ReplaceInstructionsAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

public class TF_MetaTileEntityReservoirHatch {

private static final String TARGET = "gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityReservoirHatch";
private static final String FLUID_NAME_TEXT_WIDGET = AsmTypes.HOOK + "integration/gregtech/" + "FluidNameTextWidget";

public static ClassVisitor appendVisitor(ClassVisitor cv, String className) {
if (TARGET.equals(className)) {
ClassVisitor newcv = new MyClassVisitor(cv, className) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
if (name.equals("createTankUI")) {
mv = new ReplaceInstructionsAdapter(mv, name,
Instructions.create()
.typeInsn(Opcodes.NEW, "gregtech/api/gui/widgets/AdvancedTextWidget")
.insn(Opcodes.DUP)
.intInsn(OpcodeInt.BIPUSH, 11)
.intInsn(OpcodeInt.BIPUSH, 40)
.aload(0)
.aload(5)
.label(10)
.invokespecial(TARGET, "getFluidNameText", "(Lgregtech/api/gui/widgets/TankWidget;)Ljava/util/function/Consumer;")
.ldcInsn(0xFFFFFF)
.invokespecial("gregtech/api/gui/widgets/AdvancedTextWidget", "<init>", "(IILjava/util/function/Consumer;I)V")
,
Instructions.create()
.typeInsn(Opcodes.NEW, FLUID_NAME_TEXT_WIDGET)
.insn(Opcodes.DUP)
.intInsn(OpcodeInt.BIPUSH, 11)
.intInsn(OpcodeInt.BIPUSH, 40)
.aload(0)
.aload(5)
.label(10)
.invokespecial(TARGET, "getFluidNameText", "(Lgregtech/api/gui/widgets/TankWidget;)Ljava/util/function/Consumer;")
.ldcInsn(0xFFFFFF)
.invokespecial(FLUID_NAME_TEXT_WIDGET, "<init>", "(IILjava/util/function/Consumer;I)V")
);
success();
}
return mv;
}
};
return newcv;
}
return cv;
}
}

0 comments on commit 25377c2

Please sign in to comment.