@@ -142,13 +142,7 @@ protected void tick(@Nonnull Block b) {
142
142
}
143
143
144
144
Block nextFluid = findNextFluid (fluid );
145
-
146
- if (nextFluid != null ) {
147
- removeCharge (blockLocation , ENERGY_CONSUMPTION );
148
- menu .consumeItem (slot );
149
- menu .pushItem (bucket , getOutputSlots ());
150
- nextFluid .setType (Material .AIR );
151
- }
145
+ removeFluid (menu , blockLocation , slot , bucket , nextFluid , null );
152
146
153
147
return ;
154
148
} else if (SlimefunUtils .isItemSimilar (itemInSlot , emptyBottle , true , false )) {
@@ -159,22 +153,35 @@ protected void tick(@Nonnull Block b) {
159
153
}
160
154
161
155
Block nextFluid = findNextFluid (fluid );
162
-
163
- if (nextFluid != null ) {
164
- removeCharge (blockLocation , ENERGY_CONSUMPTION );
165
- menu .consumeItem (slot );
166
- menu .pushItem (bottle , getOutputSlots ());
167
-
168
- if (ThreadLocalRandom .current ().nextInt (100 ) < 30 ) {
169
- nextFluid .setType (Material .AIR );
170
- }
171
- }
156
+ removeFluid (menu , blockLocation , slot , bottle , nextFluid , 30 );
172
157
173
158
return ;
174
159
}
175
160
}
176
161
}
177
162
163
+ /**
164
+ * @param menu Menu from which take the iem and push the new element
165
+ * @param blockLocation Location of the FluidPump
166
+ * @param slot Slot to consume the item from
167
+ * @param stack Item to push into the menu
168
+ * @param nextFluid Fluid to potentially remove
169
+ * @param chance Chance of the removal of the fluid, if null it is 100%
170
+ */
171
+ private void removeFluid (BlockMenu menu , Location blockLocation , int slot , ItemStack stack , Block nextFluid , Integer chance ) {
172
+ if (nextFluid == null ) {
173
+ return ;
174
+ }
175
+
176
+ removeCharge (blockLocation , ENERGY_CONSUMPTION );
177
+ menu .consumeItem (slot );
178
+ menu .pushItem (stack , getOutputSlots ());
179
+
180
+ if (chance == null || ThreadLocalRandom .current ().nextInt (100 ) < chance ) {
181
+ nextFluid .setType (Material .AIR );
182
+ }
183
+ }
184
+
178
185
@ Nullable
179
186
private Block findNextFluid (@ Nonnull Block fluid ) {
180
187
if (fluid .getType () == Material .WATER || fluid .getType () == Material .BUBBLE_COLUMN ) {
0 commit comments