diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java index dca07f3ac..07e125e8b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidPropagator.java @@ -11,6 +11,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.fluids.PipeConnection.Flow; import com.simibubi.create.content.contraptions.fluids.pipes.AxisPipeBlock; import com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeBlock; +import com.simibubi.create.content.contraptions.fluids.pipes.VanillaFluidTargets; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.BlockHelper; @@ -159,7 +160,7 @@ public class FluidPropagator { if (PumpBlock.isPump(connectedState) && connectedState.getValue(PumpBlock.FACING) .getAxis() == side.getAxis()) return false; - if (connectedState.hasProperty(BlockStateProperties.LEVEL_HONEY)) + if (VanillaFluidTargets.shouldPipesConnectTo(connectedState)) return true; if (BlockHelper.hasBlockSolidSide(connectedState, reader, connectedPos, side.getOpposite())) return false; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java index 6e1dd4f45..ef85478f5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.contraptions.fluids; -import static net.minecraft.world.level.block.state.properties.BlockStateProperties.LEVEL_HONEY; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED; import java.util.ArrayList; @@ -9,6 +8,7 @@ import java.util.List; import javax.annotation.Nullable; import com.simibubi.create.AllFluids; +import com.simibubi.create.content.contraptions.fluids.pipes.VanillaFluidTargets; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.config.AllConfigs; @@ -30,7 +30,6 @@ import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.AABB; @@ -132,12 +131,9 @@ public class OpenEndedPipe extends FlowSource { FluidState fluidState = state.getFluidState(); boolean waterlog = state.hasProperty(WATERLOGGED); - if (state.hasProperty(BlockStateProperties.LEVEL_HONEY) && state.getValue(LEVEL_HONEY) >= 5) { - if (!simulate) - world.setBlock(outputPos, state.setValue(LEVEL_HONEY, 0), 3); - return new FluidStack(AllFluids.HONEY.get() - .getSource(), 250); - } + FluidStack drainBlock = VanillaFluidTargets.drainBlock(world, outputPos, state, simulate); + if (!drainBlock.isEmpty()) + return drainBlock; if (!waterlog && !state.getMaterial() .isReplaceable()) diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java index 77760eaf1..a7d7a1583 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java @@ -168,7 +168,7 @@ public class FluidPipeBlock extends PipeBlock implements SimpleWaterloggedBlock, Direction direction) { if (FluidPropagator.hasFluidCapability(world, neighbourPos, direction.getOpposite())) return true; - if (neighbour.hasProperty(BlockStateProperties.LEVEL_HONEY)) + if (VanillaFluidTargets.shouldPipesConnectTo(neighbour)) return true; FluidTransportBehaviour transport = TileEntityBehaviour.get(world, neighbourPos, FluidTransportBehaviour.TYPE); BracketedTileEntityBehaviour bracket = diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/VanillaFluidTargets.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/VanillaFluidTargets.java new file mode 100644 index 000000000..0b761d4e6 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/VanillaFluidTargets.java @@ -0,0 +1,49 @@ +package com.simibubi.create.content.contraptions.fluids.pipes; + +import static net.minecraft.world.level.block.state.properties.BlockStateProperties.LEVEL_HONEY; + +import com.simibubi.create.AllFluids; + +import net.minecraft.core.BlockPos; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.material.Fluids; +import net.minecraftforge.fluids.FluidStack; + +public class VanillaFluidTargets { + + public static boolean shouldPipesConnectTo(BlockState state) { + if (state.hasProperty(BlockStateProperties.LEVEL_HONEY)) + return true; + if (state.is(BlockTags.CAULDRONS)) + return true; + return false; + } + + public static FluidStack drainBlock(Level level, BlockPos pos, BlockState state, boolean simulate) { + if (state.hasProperty(BlockStateProperties.LEVEL_HONEY) && state.getValue(LEVEL_HONEY) >= 5) { + if (!simulate) + level.setBlock(pos, state.setValue(LEVEL_HONEY, 0), 3); + return new FluidStack(AllFluids.HONEY.get() + .getSource(), 250); + } + + if (state.getBlock() == Blocks.LAVA_CAULDRON) { + if (!simulate) + level.setBlock(pos, Blocks.CAULDRON.defaultBlockState(), 3); + return new FluidStack(Fluids.LAVA, 1000); + } + + if (state.getBlock() == Blocks.WATER_CAULDRON) { + if (!simulate) + level.setBlock(pos, Blocks.CAULDRON.defaultBlockState(), 3); + return new FluidStack(Fluids.WATER, 1000); + } + + return FluidStack.EMPTY; + } + +}