Add config option to prevent placing fluid source blocks

This commit is contained in:
Stephen Barnes 2021-09-18 16:59:27 -05:00
parent 85d64010bd
commit f9791243f8
3 changed files with 15 additions and 4 deletions

View file

@ -11,6 +11,7 @@ import javax.annotation.Nullable;
import com.simibubi.create.AllFluids; import com.simibubi.create.AllFluids;
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler;
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.fluid.FluidHelper;
import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.BlockFace;
@ -214,6 +215,10 @@ public class OpenEndedPipe extends FlowSource {
.scheduleTick(outputPos, Fluids.WATER, 1); .scheduleTick(outputPos, Fluids.WATER, 1);
return true; return true;
} }
if (!AllConfigs.SERVER.fluids.placeFluidSourceBlocks.get())
return true;
world.setBlock(outputPos, fluid.getFluid() world.setBlock(outputPos, fluid.getFluid()
.defaultFluidState() .defaultFluidState()
.createLegacyBlock(), 3); .createLegacyBlock(), 3);

View file

@ -7,6 +7,7 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.fluid.FluidHelper;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
@ -126,12 +127,13 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
int maxBlocks = maxBlocks(); int maxBlocks = maxBlocks();
boolean evaporate = world.dimensionType() boolean evaporate = world.dimensionType()
.ultraWarm() && fluid.is(FluidTags.WATER); .ultraWarm() && fluid.is(FluidTags.WATER);
boolean canPlaceSources = AllConfigs.SERVER.fluids.placeFluidSourceBlocks.get();
if ((!fillInfinite() && infinite) || evaporate) { if ((!fillInfinite() && infinite) || evaporate || !canPlaceSources) {
FluidState fluidState = world.getFluidState(rootPos); FluidState fluidState = world.getFluidState(rootPos);
boolean equivalentTo = fluidState.getType() boolean equivalentTo = fluidState.getType()
.isSame(fluid); .isSame(fluid);
if (!equivalentTo && !evaporate) if (!equivalentTo && !evaporate && canPlaceSources)
return false; return false;
if (simulate) if (simulate)
return true; return true;
@ -142,7 +144,8 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
int k = root.getZ(); int k = root.getZ();
world.playSound(null, i, j, k, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, world.playSound(null, i, j, k, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F,
2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
} } else if (!canPlaceSources)
AllTriggers.triggerForNearbyPlayers(AllTriggers.HOSE_PULLEY, world, tileEntity.getBlockPos(), 8);
return true; return true;
} }

View file

@ -12,6 +12,8 @@ public class CFluids extends ConfigBase {
public ConfigBool fillInfinite = b(false, "fillInfinite",Comments.fillInfinite); public ConfigBool fillInfinite = b(false, "fillInfinite",Comments.fillInfinite);
public ConfigInt hosePulleyRange = i(128, 1, "hosePulleyRange", Comments.blocks, Comments.hosePulleyRange); public ConfigInt hosePulleyRange = i(128, 1, "hosePulleyRange", Comments.blocks, Comments.hosePulleyRange);
public ConfigBool placeFluidSourceBlocks = b(true, "placeFluidSourceBlocks", Comments.placeFluidSourceBlocks);
@Override @Override
public String getName() { public String getName() {
return "fluids"; return "fluids";
@ -29,7 +31,8 @@ public class CFluids extends ConfigBase {
static String toDisable = "[-1 to disable this behaviour]"; static String toDisable = "[-1 to disable this behaviour]";
static String hosePulleyBlockThreshold = static String hosePulleyBlockThreshold =
"The minimum amount of fluid blocks the hose pulley needs to find before deeming it an infinite source."; "The minimum amount of fluid blocks the hose pulley needs to find before deeming it an infinite source.";
static String fillInfinite="Does hose pulley poor fluids to the world even if it is an infinite source?"; static String fillInfinite = "Does hose pulley pour fluids into infinite sources?";
static String placeFluidSourceBlocks = "Can open-ended pipes and hose pulleys place fluid source blocks?";
} }
} }