@@ -82,32 +82,25 @@ public CoverPump(@NotNull CoverDefinition definition, @NotNull CoverableView cov
8282 this .fluidFilterContainer = new FluidFilterContainer (this );
8383 }
8484
85- public void setStringTransferRate (String s ) {
86- this .fluidFilterContainer .setTransferSize (
87- getBucketMode () == BucketMode .MILLI_BUCKET ?
88- Integer .parseInt (s ) :
89- Integer .parseInt (s ) * 1000 );
85+ public void setStringTransferRate (String str ) {
86+ this .fluidFilterContainer .setTransferSize (getBucketMode ().toMilliBuckets (str ));
9087 }
9188
9289 public String getStringTransferRate () {
93- return String .valueOf (getBucketMode () == BucketMode .MILLI_BUCKET ?
94- this .fluidFilterContainer .getTransferSize () :
95- this .fluidFilterContainer .getTransferSize () / 1000 );
90+ return String .valueOf (getBucketMode ().fromMilliBuckets (this .fluidFilterContainer .getTransferSize ()));
9691 }
9792
9893 public void setTransferRate (int transferRate ) {
99- if (bucketMode == BucketMode .BUCKET ) transferRate *= 1000 ;
100- this .transferRate = MathHelper .clamp (transferRate , 1 , maxFluidTransferRate );
94+ this .transferRate = MathHelper .clamp (this .bucketMode .toMilliBuckets (transferRate ), 1 , maxFluidTransferRate );
10195 markDirty ();
10296 }
10397
10498 public int getTransferRate () {
105- return bucketMode == BucketMode . BUCKET ? transferRate / 1000 : transferRate ;
99+ return this . bucketMode . fromMilliBuckets ( transferRate ) ;
106100 }
107101
108102 protected void adjustTransferRate (int amount ) {
109- amount *= this .bucketMode == BucketMode .BUCKET ? 1000 : 1 ;
110- setTransferRate (this .transferRate + amount );
103+ setTransferRate (this .transferRate + this .bucketMode .toMilliBuckets (amount ));
111104 }
112105
113106 public void setIoMode (IOMode ioMode ) {
@@ -217,7 +210,7 @@ protected Flow createUI(GuiData data, PanelSyncManager syncManager) {
217210 .left (0 ).width (18 )
218211 .onMousePressed (mouseButton -> {
219212 int val = throughputSync .getValue () - getIncrementValue (MouseData .create (mouseButton ));
220- throughputSync .setValue (val );
213+ throughputSync .setValue (Math . max ( val , 1 ) );
221214 return true ;
222215 })
223216 .onUpdateListener (w -> w .overlay (createAdjustOverlay (false ))))
@@ -233,7 +226,7 @@ protected Flow createUI(GuiData data, PanelSyncManager syncManager) {
233226 .width (18 )
234227 .onMousePressed (mouseButton -> {
235228 int val = throughputSync .getValue () + getIncrementValue (MouseData .create (mouseButton ));
236- throughputSync .setValue (val );
229+ throughputSync .setValue (Math . min ( val , maxFluidTransferRate ) );
237230 return true ;
238231 })
239232 .onUpdateListener (w -> w .overlay (createAdjustOverlay (true )))));
@@ -441,16 +434,24 @@ public int fromMilliBuckets(int mB) {
441434 }
442435
443436 /**
444- * Convert from buckets to this unit. Will return the input value on {@link #BUCKET } and multiply by 1000 on
445- * {@link #MILLI_BUCKET }.
437+ * Convert from milli buckets to this unit. Will return the input value on {@link #MILLI_BUCKET } and multiply by
438+ * 1000 on {@link #BUCKET }.
446439 */
447- public int fromBuckets (int B ) {
440+ public int toMilliBuckets (int mB ) {
448441 return switch (this ) {
449- case BUCKET -> B ;
450- case MILLI_BUCKET -> B * 1000 ;
442+ case BUCKET -> mB * 1000 ;
443+ case MILLI_BUCKET -> mB ;
451444 };
452445 }
453446
447+ /**
448+ * Parse a string into milli buckets. Will return the string value unmodified on {@link #MILLI_BUCKET} and
449+ * multiplied by 1000 on {@link #BUCKET}.
450+ */
451+ public int toMilliBuckets (@ NotNull String val ) {
452+ return toMilliBuckets (Integer .parseInt (val ));
453+ }
454+
454455 public boolean isFullBuckets () {
455456 return this == BUCKET ;
456457 }
0 commit comments