diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerFakePlayer.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerFakePlayer.java index 682b626d7..15f408253 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerFakePlayer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerFakePlayer.java @@ -51,6 +51,7 @@ public class DeployerFakePlayer extends FakePlayer { Pair blockBreakingProgress; ItemStack spawnedItemEffects; public boolean placedTracks; + public boolean onMinecartContraption; public DeployerFakePlayer(ServerLevel world) { super(world, DEPLOYER_PROFILE); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java index 116918e76..e64bfce04 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java @@ -275,6 +275,7 @@ public class DeployerMovementBehaviour implements MovementBehaviour { private DeployerFakePlayer getPlayer(MovementContext context) { if (!(context.temporaryData instanceof DeployerFakePlayer) && context.world instanceof ServerLevel) { DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) context.world); + deployerFakePlayer.onMinecartContraption = context.contraption instanceof MountedContraption; deployerFakePlayer.getInventory() .load(context.tileData.getList("Inventory", Tag.TAG_COMPOUND)); if (context.data.contains("HeldItem")) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovingInteraction.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovingInteraction.java index 401d77731..58bedbfd1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovingInteraction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovingInteraction.java @@ -6,6 +6,7 @@ import com.simibubi.create.AllItems; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovingInteractionBehaviour; +import com.simibubi.create.content.contraptions.components.structureMovement.mounted.MountedContraption; import com.simibubi.create.foundation.utility.NBTHelper; import net.minecraft.core.BlockPos; @@ -55,6 +56,7 @@ public class DeployerMovingInteraction extends MovingInteractionBehaviour { if (!(ctx.temporaryData instanceof DeployerFakePlayer) && ctx.world instanceof ServerLevel) { DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) ctx.world); + deployerFakePlayer.onMinecartContraption = ctx.contraption instanceof MountedContraption; deployerFakePlayer.getInventory() .load(ctx.tileData.getList("Inventory", Tag.TAG_COMPOUND)); ctx.temporaryData = fake = deployerFakePlayer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java index 28c22731a..50bd66123 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MinecartContraptionItem.java @@ -8,6 +8,7 @@ import javax.annotation.Nullable; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import com.simibubi.create.AllItems; +import com.simibubi.create.content.contraptions.components.deployer.DeployerFakePlayer; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity; @@ -208,6 +209,8 @@ public class MinecartContraptionItem extends Item { return; if (!entity.isAlive()) return; + if (player instanceof DeployerFakePlayer dfp && dfp.onMinecartContraption) + return; AbstractMinecart cart = (AbstractMinecart) entity; Type type = cart.getMinecartType(); if (type != Type.RIDEABLE && type != Type.FURNACE && type != Type.CHEST) diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpBlock.java index 7bf15694d..93956008f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpBlock.java @@ -5,14 +5,18 @@ import java.util.Random; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; +import com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeBlock; import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; import com.simibubi.create.foundation.block.ITE; +import com.simibubi.create.foundation.block.ProperWaterloggedBlock; +import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.network.protocol.game.DebugPackets; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.BlockGetter; @@ -32,7 +36,8 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.ticks.TickPriority; -public class PumpBlock extends DirectionalKineticBlock implements SimpleWaterloggedBlock, ICogWheel, ITE { +public class PumpBlock extends DirectionalKineticBlock + implements SimpleWaterloggedBlock, ICogWheel, ITE { public PumpBlock(Properties p_i48415_1_) { super(p_i48415_1_); @@ -96,10 +101,26 @@ public class PumpBlock extends DirectionalKineticBlock implements SimpleWaterlog @Override public BlockState getStateForPlacement(BlockPlaceContext context) { - FluidState FluidState = context.getLevel() - .getFluidState(context.getClickedPos()); - return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED, - Boolean.valueOf(FluidState.getType() == Fluids.WATER)); + BlockState toPlace = super.getStateForPlacement(context); + Level level = context.getLevel(); + BlockPos pos = context.getClickedPos(); + Player player = context.getPlayer(); + toPlace = ProperWaterloggedBlock.withWater(level, toPlace, pos); + + if (player != null && player.isSteppingCarefully()) + return toPlace; + + for (Direction d : Iterate.directions) { + BlockPos adjPos = pos.relative(d); + BlockState adjState = level.getBlockState(adjPos); + if (!FluidPipeBlock.canConnectTo(level, adjPos, adjState, d)) + continue; + toPlace = toPlace.setValue(FACING, d); + if (context.getClickedFace() == d.getOpposite()) + break; + } + + return toPlace; } public static boolean isPump(BlockState state) { @@ -113,7 +134,7 @@ public class PumpBlock extends DirectionalKineticBlock implements SimpleWaterlog return; if (state != oldState) world.scheduleTick(pos, this, 1, TickPriority.HIGH); - + if (isPump(state) && isPump(oldState) && state.getValue(FACING) == oldState.getValue(FACING) .getOpposite()) { BlockEntity tileEntity = world.getBlockEntity(pos);