mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
add crafting preview screen support nei bookmark
This commit is contained in:
1 parent
292a70ab6e
commit
8cafbceed7
9 files changed
+96
-11
No files matched your search
@@ -48,6 +48,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
|
||||
private GuiButton start;
|
||||
private GuiButton selectCPU;
|
||||
private int tooltip = -1;
|
||||
private ItemStack hoveredStack;
|
||||
|
||||
public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
|
||||
{
|
||||
@@ -202,7 +203,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
|
||||
final List<String> lineList = new LinkedList<String>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
hoveredStack = null;
|
||||
final int offY = 23;
|
||||
|
||||
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
|
||||
@@ -324,6 +325,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
|
||||
|
||||
toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
hoveredStack = is;
|
||||
}
|
||||
|
||||
this.drawItem( posX, posY, is );
|
||||
@@ -550,5 +552,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
|
||||
lineList.add(GuiText.HoldShiftForTooltip.getLocal());
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getHoveredStack() {
|
||||
return hoveredStack;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS;
|
||||
|
||||
public class FCClassTransformer implements IClassTransformer {
|
||||
|
||||
@@ -29,6 +32,9 @@ public class FCClassTransformer implements IClassTransformer {
|
||||
case "net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm":
|
||||
tform = GuiCraftingTransformer.INSTANCE;
|
||||
break;
|
||||
case "appeng.integration.modules.NEI":
|
||||
tform = NEITransfermer.INSTANCE;
|
||||
break;
|
||||
default:
|
||||
return code;
|
||||
}
|
||||
@@ -46,17 +52,18 @@ public class FCClassTransformer implements IClassTransformer {
|
||||
|
||||
@Override
|
||||
public byte[] transformClass(byte[] code) {
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader reader = new ClassReader(code);
|
||||
reader.accept(classNode, 0);
|
||||
ClassWriter writer = new ClassWriter(reader, getWriteFlags());
|
||||
reader.accept(getClassMapper(writer), 0);
|
||||
classNode.accept(getClassMapper(writer,classNode));
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
protected int getWriteFlags() {
|
||||
return 0;
|
||||
return COMPUTE_FRAMES|COMPUTE_MAXS;
|
||||
}
|
||||
|
||||
protected abstract ClassVisitor getClassMapper(ClassVisitor downstream);
|
||||
|
||||
protected abstract ClassVisitor getClassMapper(ClassVisitor downstream, ClassNode classNode);
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,15 @@ import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
import appeng.crafting.MECraftingInventory;
|
||||
import appeng.me.MachineSet;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import com.glodblock.github.client.gui.GuiFluidCraftConfirm;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
@@ -26,6 +29,7 @@ import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.SetBackedMachineSet;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -169,4 +173,24 @@ public class CoreModHooks {
|
||||
Ae2Reflect.markCPUDirty(instance);
|
||||
}
|
||||
|
||||
public static ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) {
|
||||
if (gui instanceof GuiCraftConfirm){
|
||||
return ((GuiCraftConfirm)gui).getHoveredStack();
|
||||
} else if (gui instanceof GuiFluidCraftConfirm) {
|
||||
return ((GuiFluidCraftConfirm)gui).getHoveredStack();
|
||||
} else if (gui instanceof GuiCraftingCPU){
|
||||
return ((GuiCraftingCPU)gui).getHoveredStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static boolean shouldShowTooltip(GuiContainer gui) {
|
||||
if (gui instanceof GuiFluidCraftConfirm)
|
||||
return ((GuiFluidCraftConfirm)gui).getHoveredStack() == null;
|
||||
if (gui instanceof GuiCraftConfirm)
|
||||
return ((GuiCraftConfirm)gui).getHoveredStack() == null;
|
||||
if (gui instanceof GuiCraftingCPU)
|
||||
return ((GuiCraftingCPU)gui).getHoveredStack() == null;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -4,6 +4,7 @@ import com.glodblock.github.coremod.FCClassTransformer;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
public class ContainerInterfaceTerminalTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
@@ -14,7 +15,7 @@ public class ContainerInterfaceTerminalTransformer extends FCClassTransformer.Cl
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream, ClassNode classNode) {
|
||||
return new TransformContainerInterfaceTerminal(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
@@ -15,7 +16,7 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream, ClassNode classNode) {
|
||||
return new TransformCraftingCPUCluster(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
@@ -15,7 +16,7 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream, ClassNode classNode) {
|
||||
return new TransformCraftingTreeNode(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import com.glodblock.github.coremod.FCClassTransformer;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
public class DualityInterfaceTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
@@ -14,7 +15,7 @@ public class DualityInterfaceTransformer extends FCClassTransformer.ClassMapper
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream, ClassNode classNode) {
|
||||
return new TransformDualityInterface(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.glodblock.github.coremod.FCClassTransformer;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
public class GuiCraftingTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
@@ -14,7 +15,7 @@ public class GuiCraftingTransformer extends FCClassTransformer.ClassMapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream, ClassNode classNode) {
|
||||
return new TransformGuiCrafting(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.glodblock.github.coremod.transform;
|
||||
import com.glodblock.github.coremod.FCClassTransformer;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.*;
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
public class NEITransfermer extends FCClassTransformer.ClassMapper{
|
||||
|
||||
public static final NEITransfermer INSTANCE = new NEITransfermer();
|
||||
|
||||
private NEITransfermer(){}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream, ClassNode classNode) {
|
||||
for (MethodNode method : classNode.methods){
|
||||
if(method.name.equals("getStackUnderMouse")){
|
||||
InsnList toInsert = new InsnList();
|
||||
toInsert.add(new VarInsnNode(ALOAD, 1));
|
||||
toInsert.add(new VarInsnNode(ILOAD, 2));
|
||||
toInsert.add(new VarInsnNode(ILOAD, 3));
|
||||
toInsert.add(new MethodInsnNode(INVOKESTATIC, "com/glodblock/github/coremod/hooker/CoreModHooks", "getStackUnderMouse", "(Lnet/minecraft/client/gui/inventory/GuiContainer;II)Lnet/minecraft/item/ItemStack;", false));
|
||||
toInsert.add(new InsnNode(ARETURN));
|
||||
method.instructions = toInsert;
|
||||
}else if(method.name.equals("shouldShowTooltip")){
|
||||
InsnList toInsert = new InsnList();
|
||||
toInsert.add(new VarInsnNode(ALOAD, 1));
|
||||
toInsert.add(new MethodInsnNode(INVOKESTATIC, "com/glodblock/github/coremod/hooker/CoreModHooks", "shouldShowTooltip", "(Lnet/minecraft/client/gui/inventory/GuiContainer;)Z", false));
|
||||
toInsert.add(new InsnNode(IRETURN));
|
||||
method.instructions = toInsert;
|
||||
}
|
||||
}
|
||||
return new NEITransfermer.TransformNEI(Opcodes.ASM5, downstream);
|
||||
}
|
||||
private static class TransformNEI extends ClassVisitor {
|
||||
TransformNEI(int api, ClassVisitor cv) {
|
||||
super(api, cv);
|
||||
}
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user