Committing self-wrench

- Fluid Pumps now orient themselves at adjacent pipes when placed
- Deployers mounted on minecart contraptions can no longer pick up minecart contraptions using a wrench
This commit is contained in:
simibubi 2022-08-13 14:29:18 +02:00
parent c33fc73f3a
commit 33daccc397
5 changed files with 34 additions and 6 deletions

View file

@ -51,6 +51,7 @@ public class DeployerFakePlayer extends FakePlayer {
Pair<BlockPos, Float> blockBreakingProgress;
ItemStack spawnedItemEffects;
public boolean placedTracks;
public boolean onMinecartContraption;
public DeployerFakePlayer(ServerLevel world) {
super(world, DEPLOYER_PROFILE);

View file

@ -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"))

View file

@ -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;

View file

@ -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)

View file

@ -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<PumpTileEntity> {
public class PumpBlock extends DirectionalKineticBlock
implements SimpleWaterloggedBlock, ICogWheel, ITE<PumpTileEntity> {
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) {