From 5b63f30df390c045d5c0b8b07189ed229a50460f Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed, 31 Mar 2021 15:22:41 +0200 Subject: [PATCH] Abort Mission - Drills and other block breakers on contraptions now give up trying to destroy a block when their movement direction is reversed --- .../components/actors/DrillMovementBehaviour.java | 5 ++--- .../bearing/MechanicalBearingTileEntity.java | 5 +++++ .../structureMovement/gantry/GantryContraptionEntity.java | 2 ++ .../piston/LinearActuatorTileEntity.java | 8 +++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java index fd9a3959a..914ac161d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java @@ -1,10 +1,11 @@ package com.simibubi.create.content.contraptions.components.actors; +import javax.annotation.Nullable; + import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; -import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.VecHelper; @@ -17,8 +18,6 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; - public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour { @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingTileEntity.java index e92e9ff22..4f3525ae6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/MechanicalBearingTileEntity.java @@ -101,6 +101,11 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity public void onSpeedChanged(float prevSpeed) { super.onSpeedChanged(prevSpeed); assembleNextTick = true; + + if (movedContraption != null && Math.signum(prevSpeed) != Math.signum(getSpeed()) && prevSpeed != 0) { + movedContraption.getContraption() + .stop(world); + } } public float getAngularSpeed() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java index c16b3d03d..003142dbf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java @@ -69,6 +69,8 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { if (!isStalled() && ticksExisted > 2) move(movementVec.x, movementVec.y, movementVec.z); + if (Math.signum(prevAxisMotion) != Math.signum(axisMotion) && prevAxisMotion != 0) + contraption.stop(world); if (!world.isRemote && (prevAxisMotion != axisMotion || ticksExisted % 3 == 0)) sendPacket(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java index c958b6a92..4694bf984 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java @@ -20,7 +20,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -public abstract class LinearActuatorTileEntity extends KineticTileEntity implements IControlContraption, IDisplayAssemblyExceptions { +public abstract class LinearActuatorTileEntity extends KineticTileEntity + implements IControlContraption, IDisplayAssemblyExceptions { public float offset; public boolean running; @@ -147,6 +148,11 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity impleme super.onSpeedChanged(prevSpeed); assembleNextTick = true; waitingForSpeedChange = false; + + if (movedContraption != null && Math.signum(prevSpeed) != Math.signum(getSpeed()) && prevSpeed != 0) { + movedContraption.getContraption() + .stop(world); + } } @Override