33import com .cleanroommc .modularui .api .value .ISyncOrValue ;
44import com .cleanroommc .modularui .api .value .IValue ;
55import com .cleanroommc .modularui .screen .RichTooltip ;
6+ import com .cleanroommc .modularui .value .ObjectValue ;
67
78import net .minecraftforge .fluids .FluidStack ;
89
1415public class FluidDisplayWidget extends AbstractFluidDisplayWidget <FluidDisplayWidget > {
1516
1617 private IValue <FluidStack > value ;
18+ private int capacity = 0 ;
1719 private boolean displayAmount = true ;
1820
1921 @ Override
@@ -37,11 +39,49 @@ protected boolean displayAmountText() {
3739 return this .value != null ? this .value .getValue () : null ;
3840 }
3941
42+ @ Override
43+ public int getCapacity () {
44+ return capacity ;
45+ }
46+
47+ public FluidDisplayWidget value (IValue <FluidStack > value ) {
48+ setSyncOrValue (value );
49+ return this ;
50+ }
51+
52+ public FluidDisplayWidget value (FluidStack value ) {
53+ return value (new ObjectValue <>(FluidStack .class , value ));
54+ }
55+
56+ /**
57+ * Sets the capacity of the slot. This is only used for drawing and doesn't affect the actual capacity in any way. When the capacity is
58+ * greater than zero, the fluid will be drawn partially depending on the fill level.
59+ *
60+ * @param capacity capacity for drawing the fluid
61+ * @return this
62+ */
63+ public FluidDisplayWidget capacity (int capacity ) {
64+ this .capacity = capacity ;
65+ return this ;
66+ }
67+
68+ /**
69+ * Sets whether the amount number should be displayed in the bottom left corner of the slot.
70+ *
71+ * @param displayAmount true if amount should be displayed
72+ * @return this
73+ */
4074 public FluidDisplayWidget displayAmount (boolean displayAmount ) {
4175 this .displayAmount = displayAmount ;
4276 return this ;
4377 }
4478
79+ /**
80+ * Adds additional tooltip lines for the fluid. The function is called every frame.
81+ *
82+ * @param tooltip tooltip function for additional lines
83+ * @return this
84+ */
4585 public FluidDisplayWidget fluidTooltip (BiConsumer <RichTooltip , FluidStack > tooltip ) {
4686 return tooltipAutoUpdate (true ).tooltipBuilder (t -> tooltip .accept (t , getFluidStack ()));
4787 }
0 commit comments