From 9df9a9918572f0b8c30c89dca0830f2cb515f030 Mon Sep 17 00:00:00 2001 From: grimmauld Date: Sat, 20 Mar 2021 22:49:42 +0100 Subject: [PATCH] We have SPONGE! (and not only for mixins...) --- .../content/contraptions/processing/BasinBlock.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java index d11a5a6fc..eaaba35bf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java @@ -22,6 +22,7 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; +import net.minecraft.item.Items; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.properties.BlockStateProperties; @@ -36,6 +37,10 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; @@ -95,6 +100,11 @@ public class BasinBlock extends Block implements ITE, IWrenchab if (EmptyingByBasin.canItemBeEmptied(worldIn, heldItem) || GenericItemFilling.canItemBeFilled(worldIn, heldItem)) return ActionResultType.SUCCESS; + if (heldItem.getItem().equals(Items.SPONGE) && + !te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY).map(iFluidHandler -> + iFluidHandler.drain(Integer.MAX_VALUE, IFluidHandler.FluidAction.EXECUTE)).orElse(FluidStack.EMPTY).isEmpty()) { + return ActionResultType.SUCCESS; + } return ActionResultType.PASS; }