mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-12 16:27:40 +00:00
fluid display
This commit is contained in:
1 parent
213b43d213
commit
12565b1389
9 files changed
+108
-18
No files matched your search
@@ -387,8 +387,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
|
||||
}
|
||||
}
|
||||
|
||||
System.out.print(action + "\n");
|
||||
|
||||
if( Ae2ReflectClient.getDragClick(this).size() > 1 )
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.coremod.hooker.CoreModHooks;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
@@ -252,7 +253,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
||||
lineList.add( GuiText.FromStorage.getLocal() + ": " + stored.getStackSize());
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
@@ -277,7 +278,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) );
|
||||
lineList.add( GuiText.Missing.getLocal() + ": " + missingStack.getStackSize());
|
||||
}
|
||||
|
||||
red = true;
|
||||
@@ -310,7 +311,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
|
||||
final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
|
||||
final int posY = y * offY + yo;
|
||||
|
||||
final ItemStack is = refStack.copy().getItemStack();
|
||||
final ItemStack is = CoreModHooks.displayFluid(refStack.copy());
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
|
||||
+1
-4
@@ -131,10 +131,7 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
|
||||
public void setFluid(int id, IAEFluidStack fluidStack) {
|
||||
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
|
||||
if (inv != null && this.isValidForConfig(id, AEFluidStack.create(fluidStack))) {
|
||||
ItemStack tmp = ItemFluidPacket.newStack(fluidStack.getFluidStack());
|
||||
if (tmp != null) {
|
||||
tmp.setStackDisplayName(fluidStack.getFluidStack().getLocalizedName());
|
||||
}
|
||||
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluidStack.getFluidStack());
|
||||
inv.setInventorySlotContents(id, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -140,7 +140,6 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
|
||||
|
||||
@Override
|
||||
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
|
||||
System.out.print(action + "\n");
|
||||
if (this.isCraftingMode()) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
|
||||
@@ -34,6 +34,10 @@ public class ItemFluidPacket extends Item {
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
FluidStack fluid = getFluidStack(stack);
|
||||
boolean display = isDisplay(stack);
|
||||
if (display) {
|
||||
return fluid != null ? fluid.getLocalizedName() : super.getItemStackDisplayName(stack);
|
||||
}
|
||||
return fluid != null ? String.format("%s, %,d mB", fluid.getLocalizedName(), fluid.amount)
|
||||
: super.getItemStackDisplayName(stack);
|
||||
}
|
||||
@@ -42,6 +46,8 @@ public class ItemFluidPacket extends Item {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flags) {
|
||||
FluidStack fluid = getFluidStack(stack);
|
||||
boolean display = isDisplay(stack);
|
||||
if (display) return;
|
||||
if (fluid != null) {
|
||||
for (String line : StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_PACKET).split("\\\\n")) {
|
||||
tooltip.add(EnumChatFormatting.GRAY + line);
|
||||
@@ -51,6 +57,13 @@ public class ItemFluidPacket extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDisplay(ItemStack stack) {
|
||||
if (stack == null || !stack.hasTagCompound() || stack.getTagCompound() == null) {
|
||||
return false;
|
||||
}
|
||||
return stack.getTagCompound().getBoolean("DisplayOnly");
|
||||
}
|
||||
|
||||
public static FluidStack getFluidStack(ItemStack stack) {
|
||||
if (stack == null || !stack.hasTagCompound()) {
|
||||
return null;
|
||||
@@ -76,6 +89,22 @@ public class ItemFluidPacket extends Item {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack newDisplayStack(@Nullable FluidStack fluid) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
FluidStack copy = fluid.copy();
|
||||
copy.amount = 1000;
|
||||
ItemStack stack = new ItemStack(ItemAndBlockHolder.PACKET);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
NBTTagCompound fluidTag = new NBTTagCompound();
|
||||
copy.writeToNBT(fluidTag);
|
||||
tag.setTag("FluidStack", fluidTag);
|
||||
tag.setBoolean("DisplayOnly", true);
|
||||
stack.setTagCompound(tag);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IAEItemStack newAeStack(@Nullable FluidStack fluid) {
|
||||
return AEItemStack.create(newStack(fluid));
|
||||
|
||||
@@ -163,10 +163,7 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
|
||||
}
|
||||
|
||||
public void setFluidInSlot(int id, IAEFluidStack fluid) {
|
||||
ItemStack tmp = ItemFluidPacket.newStack(fluid == null ? null : fluid.getFluidStack());
|
||||
if (tmp != null) {
|
||||
tmp.setStackDisplayName(fluid.getFluidStack().getLocalizedName());
|
||||
}
|
||||
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack());
|
||||
this.config.setInventorySlotContents(id, tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.glodblock.github.coremod;
|
||||
|
||||
import com.glodblock.github.coremod.transform.ContainerInterfaceTerminalTransformer;
|
||||
import com.glodblock.github.coremod.transform.CraftingCpuTransformer;
|
||||
import com.glodblock.github.coremod.transform.CraftingTreeNodeTransformer;
|
||||
import com.glodblock.github.coremod.transform.DualityInterfaceTransformer;
|
||||
import com.glodblock.github.coremod.transform.*;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
@@ -27,6 +24,10 @@ public class FCClassTransformer implements IClassTransformer {
|
||||
case "appeng.container.implementations.ContainerInterfaceTerminal":
|
||||
tform = ContainerInterfaceTerminalTransformer.INSTANCE;
|
||||
break;
|
||||
case "appeng.client.gui.implementations.GuiCraftingCPU":
|
||||
case "appeng.client.gui.implementations.GuiCraftConfirm":
|
||||
tform = GuiCraftingTransformer.INSTANCE;
|
||||
break;
|
||||
default:
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,10 @@ import com.glodblock.github.util.SetBackedMachineSet;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashSet;
|
||||
@@ -88,4 +90,12 @@ public class CoreModHooks {
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack displayFluid(IAEItemStack aeStack) {
|
||||
if (aeStack.getItemStack() != null && aeStack.getItemStack().getItem() instanceof ItemFluidDrop) {
|
||||
FluidStack fluid = ItemFluidDrop.getFluidStack(aeStack.getItemStack());
|
||||
return ItemFluidPacket.newDisplayStack(fluid);
|
||||
}
|
||||
else return aeStack.getItemStack();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
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;
|
||||
|
||||
public class GuiCraftingTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
public static final GuiCraftingTransformer INSTANCE = new GuiCraftingTransformer();
|
||||
|
||||
private GuiCraftingTransformer() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
return new TransformGuiCrafting(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
private static class TransformGuiCrafting extends ClassVisitor {
|
||||
|
||||
TransformGuiCrafting(int api, ClassVisitor cv) {
|
||||
super(api, cv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if ("drawFG".equals(name)) {
|
||||
return new TransformFluidIcon(api, super.visitMethod(access, name, desc, signature, exceptions));
|
||||
}
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class TransformFluidIcon extends MethodVisitor {
|
||||
|
||||
TransformFluidIcon(int api, MethodVisitor mv) {
|
||||
super(api, mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
|
||||
if (opcode == Opcodes.INVOKEINTERFACE && owner.equals("appeng/api/storage/data/IAEItemStack") && name.equals("getItemStack")) {
|
||||
super.visitMethodInsn(Opcodes.INVOKESTATIC,
|
||||
"com/glodblock/github/coremod/hooker/CoreModHooks",
|
||||
"displayFluid",
|
||||
"(Lappeng/api/storage/data/IAEItemStack;)Lnet/minecraft/item/ItemStack;",
|
||||
false);
|
||||
}
|
||||
else {
|
||||
super.visitMethodInsn(opcode, owner, name, desc, itf);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user