2626import aztech .modern_industrialization .MI ;
2727import aztech .modern_industrialization .blocks .storage .tank .TankBlockEntity ;
2828import java .util .List ;
29+ import net .minecraft .ChatFormatting ;
2930import net .minecraft .nbt .CompoundTag ;
31+ import net .minecraft .nbt .NbtOps ;
32+ import net .minecraft .network .chat .Component ;
3033import net .minecraft .resources .ResourceLocation ;
34+ import net .minecraft .world .level .material .Fluids ;
35+ import net .neoforged .neoforge .fluids .FluidStack ;
36+ import org .jetbrains .annotations .Nullable ;
3137import snownee .jade .api .Accessor ;
38+ import snownee .jade .api .fluid .JadeFluidObject ;
39+ import snownee .jade .api .ui .IDisplayHelper ;
40+ import snownee .jade .api .ui .IElementHelper ;
3241import snownee .jade .api .view .ClientViewGroup ;
3342import snownee .jade .api .view .FluidView ;
3443import snownee .jade .api .view .IClientExtensionProvider ;
@@ -49,7 +58,34 @@ public List<ViewGroup<CompoundTag>> getGroups(Accessor<?> accessor) {
4958
5059 @ Override
5160 public List <ClientViewGroup <FluidView >> getClientGroups (Accessor <?> accessor , List <ViewGroup <CompoundTag >> list ) {
52- return ClientViewGroup .map (list , FluidView ::readDefault , null );
61+ return ClientViewGroup .map (list , TankComponentProvider ::readFluidViewLong , null );
62+ }
63+
64+ /**
65+ * Copy/paste of {@link FluidView#readDefault(CompoundTag)} with fluid name getting changed such that it stops showing Air for large amounts.
66+ */
67+ @ Nullable
68+ public static FluidView readFluidViewLong (CompoundTag tag ) {
69+ long capacity = tag .getLong ("capacity" );
70+ if (capacity <= 0L ) {
71+ return null ;
72+ }
73+ JadeFluidObject fluidObject = JadeFluidObject .CODEC .parse (NbtOps .INSTANCE , tag .get ("fluid" )).result ().orElse (null );
74+ if (fluidObject == null ) {
75+ return null ;
76+ }
77+ long amount = fluidObject .getAmount ();
78+ FluidView fluidView = new FluidView (IElementHelper .get ().fluid (fluidObject ));
79+ fluidView .fluidName = new FluidStack (fluidObject .getType ().builtInRegistryHolder (), 1 , fluidObject .getComponents ()).getHoverName ();
80+ fluidView .current = IDisplayHelper .get ().humanReadableNumber ((double ) amount , "B" , true );
81+ fluidView .max = IDisplayHelper .get ().humanReadableNumber ((double ) capacity , "B" , true );
82+ fluidView .ratio = (float ) ((double ) amount / (double ) capacity );
83+ if (fluidObject .getType ().isSame (Fluids .EMPTY )) {
84+ fluidView .overrideText = Component .translatable ("jade.fluid" , FluidView .EMPTY_FLUID ,
85+ Component .literal (fluidView .max ).withStyle (ChatFormatting .GRAY ));
86+ }
87+
88+ return fluidView ;
5389 }
5490
5591 @ Override
0 commit comments