mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-17 19:05:29 +00:00
fluid display
This commit is contained in:
1 parent
213b43d213
commit
12565b1389
9 files changed
+108
-18
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user