asm packet return to crafting inventory

This commit is contained in:
GlodBlock committed 2022-09-21 00:04:41 +08:00
1 parent a63add7bff
commit 733774e7a3
2 files changed
+20

No files matched your search

@@ -52,6 +52,17 @@ public class CoreModHooks {
return stack;
}
public static ItemStack removeFluidPackets(InventoryCrafting inv, int index) {
ItemStack stack = inv.getStackInSlot(index);
if (stack != null && stack.getItem() instanceof ItemFluidPacket) {
FluidStack fluid = ItemFluidPacket.getFluidStack(stack);
return ItemFluidDrop.newStack(fluid);
}
else {
return stack;
}
}
@Nullable
public static InventoryAdaptor wrapInventory(@Nullable TileEntity tile, ForgeDirection face) {
return tile != null ? FluidConvertingInventoryAdaptor.wrap(tile, Util.from(face)) : null;
@@ -83,6 +83,15 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper {
return;
}
}
if (opcode == Opcodes.INVOKEVIRTUAL &&
owner.equals("net/minecraft/inventory/InventoryCrafting") && name.equals("getStackInSlot")) {
super.visitMethodInsn(Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"removeFluidPackets",
"(Lnet/minecraft/inventory/InventoryCrafting;I)Lnet/minecraft/item/ItemStack;",
false);
return;
}
super.visitMethodInsn(opcode, owner, name, desc, itf);
if (gotInventory) {
if (opcode == Opcodes.INVOKESTATIC