mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-18 16:02:19 +01:00
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:
parent
c33fc73f3a
commit
33daccc397
5 changed files with 34 additions and 6 deletions
|
@ -51,6 +51,7 @@ public class DeployerFakePlayer extends FakePlayer {
|
||||||
Pair<BlockPos, Float> blockBreakingProgress;
|
Pair<BlockPos, Float> blockBreakingProgress;
|
||||||
ItemStack spawnedItemEffects;
|
ItemStack spawnedItemEffects;
|
||||||
public boolean placedTracks;
|
public boolean placedTracks;
|
||||||
|
public boolean onMinecartContraption;
|
||||||
|
|
||||||
public DeployerFakePlayer(ServerLevel world) {
|
public DeployerFakePlayer(ServerLevel world) {
|
||||||
super(world, DEPLOYER_PROFILE);
|
super(world, DEPLOYER_PROFILE);
|
||||||
|
|
|
@ -275,6 +275,7 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
|
||||||
private DeployerFakePlayer getPlayer(MovementContext context) {
|
private DeployerFakePlayer getPlayer(MovementContext context) {
|
||||||
if (!(context.temporaryData instanceof DeployerFakePlayer) && context.world instanceof ServerLevel) {
|
if (!(context.temporaryData instanceof DeployerFakePlayer) && context.world instanceof ServerLevel) {
|
||||||
DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) context.world);
|
DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) context.world);
|
||||||
|
deployerFakePlayer.onMinecartContraption = context.contraption instanceof MountedContraption;
|
||||||
deployerFakePlayer.getInventory()
|
deployerFakePlayer.getInventory()
|
||||||
.load(context.tileData.getList("Inventory", Tag.TAG_COMPOUND));
|
.load(context.tileData.getList("Inventory", Tag.TAG_COMPOUND));
|
||||||
if (context.data.contains("HeldItem"))
|
if (context.data.contains("HeldItem"))
|
||||||
|
|
|
@ -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.AbstractContraptionEntity;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
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.MovingInteractionBehaviour;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.MountedContraption;
|
||||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -55,6 +56,7 @@ public class DeployerMovingInteraction extends MovingInteractionBehaviour {
|
||||||
|
|
||||||
if (!(ctx.temporaryData instanceof DeployerFakePlayer) && ctx.world instanceof ServerLevel) {
|
if (!(ctx.temporaryData instanceof DeployerFakePlayer) && ctx.world instanceof ServerLevel) {
|
||||||
DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) ctx.world);
|
DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) ctx.world);
|
||||||
|
deployerFakePlayer.onMinecartContraption = ctx.contraption instanceof MountedContraption;
|
||||||
deployerFakePlayer.getInventory()
|
deployerFakePlayer.getInventory()
|
||||||
.load(ctx.tileData.getList("Inventory", Tag.TAG_COMPOUND));
|
.load(ctx.tileData.getList("Inventory", Tag.TAG_COMPOUND));
|
||||||
ctx.temporaryData = fake = deployerFakePlayer;
|
ctx.temporaryData = fake = deployerFakePlayer;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import javax.annotation.Nullable;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.simibubi.create.AllItems;
|
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.AbstractContraptionEntity;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity;
|
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity;
|
||||||
|
@ -208,6 +209,8 @@ public class MinecartContraptionItem extends Item {
|
||||||
return;
|
return;
|
||||||
if (!entity.isAlive())
|
if (!entity.isAlive())
|
||||||
return;
|
return;
|
||||||
|
if (player instanceof DeployerFakePlayer dfp && dfp.onMinecartContraption)
|
||||||
|
return;
|
||||||
AbstractMinecart cart = (AbstractMinecart) entity;
|
AbstractMinecart cart = (AbstractMinecart) entity;
|
||||||
Type type = cart.getMinecartType();
|
Type type = cart.getMinecartType();
|
||||||
if (type != Type.RIDEABLE && type != Type.FURNACE && type != Type.CHEST)
|
if (type != Type.RIDEABLE && type != Type.FURNACE && type != Type.CHEST)
|
||||||
|
|
|
@ -5,14 +5,18 @@ import java.util.Random;
|
||||||
import com.simibubi.create.AllShapes;
|
import com.simibubi.create.AllShapes;
|
||||||
import com.simibubi.create.AllTileEntities;
|
import com.simibubi.create.AllTileEntities;
|
||||||
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
|
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.content.contraptions.relays.elementary.ICogWheel;
|
||||||
import com.simibubi.create.foundation.block.ITE;
|
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.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
import net.minecraft.network.protocol.game.DebugPackets;
|
import net.minecraft.network.protocol.game.DebugPackets;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
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.BlockPlaceContext;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
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.phys.shapes.VoxelShape;
|
||||||
import net.minecraft.world.ticks.TickPriority;
|
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_) {
|
public PumpBlock(Properties p_i48415_1_) {
|
||||||
super(p_i48415_1_);
|
super(p_i48415_1_);
|
||||||
|
@ -96,10 +101,26 @@ public class PumpBlock extends DirectionalKineticBlock implements SimpleWaterlog
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||||
FluidState FluidState = context.getLevel()
|
BlockState toPlace = super.getStateForPlacement(context);
|
||||||
.getFluidState(context.getClickedPos());
|
Level level = context.getLevel();
|
||||||
return super.getStateForPlacement(context).setValue(BlockStateProperties.WATERLOGGED,
|
BlockPos pos = context.getClickedPos();
|
||||||
Boolean.valueOf(FluidState.getType() == Fluids.WATER));
|
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) {
|
public static boolean isPump(BlockState state) {
|
||||||
|
|
Loading…
Reference in a new issue