mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-13 05:54:17 +01:00
Fix stabilized contraption moving bearing block
This commit is contained in:
parent
c77e7c28d7
commit
7436ceb209
@ -135,7 +135,7 @@ public abstract class Contraption {
|
||||
|
||||
public abstract boolean assemble(World world, BlockPos pos);
|
||||
|
||||
protected abstract boolean canAxisBeStabilized(Axis axis);
|
||||
public abstract boolean canBeStabilized(Direction facing, BlockPos localPos);
|
||||
|
||||
protected abstract AllContraptionTypes getType();
|
||||
|
||||
@ -338,7 +338,7 @@ public abstract class Contraption {
|
||||
|
||||
private void moveBearing(BlockPos pos, List<BlockPos> frontier, Set<BlockPos> visited, BlockState state) {
|
||||
Direction facing = state.get(MechanicalBearingBlock.FACING);
|
||||
if (!canAxisBeStabilized(facing.getAxis())) {
|
||||
if (!canBeStabilized(facing, pos.subtract(anchor))) {
|
||||
BlockPos offset = pos.offset(facing);
|
||||
if (!visited.contains(offset))
|
||||
frontier.add(offset);
|
||||
|
@ -5,7 +5,6 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.template.Template.BlockInfo;
|
||||
@ -48,7 +47,7 @@ public abstract class TranslatingContraption extends Contraption {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAxisBeStabilized(Axis axis) {
|
||||
public boolean canBeStabilized(Direction facing, BlockPos localPos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.template.Template.BlockInfo;
|
||||
@ -84,8 +83,10 @@ public class BearingContraption extends Contraption {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAxisBeStabilized(Axis axis) {
|
||||
return axis == facing.getAxis();
|
||||
public boolean canBeStabilized(Direction facing, BlockPos localPos) {
|
||||
if (facing.getOpposite() == this.facing && BlockPos.ZERO.equals(localPos))
|
||||
return false;
|
||||
return facing.getAxis() == this.facing.getAxis();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -110,15 +109,17 @@ public class ClockworkContraption extends Contraption {
|
||||
|
||||
@Override
|
||||
public void readNBT(World world, CompoundNBT tag, boolean spawnData) {
|
||||
facing = Direction.byIndex(tag.getInt("Facing"));
|
||||
facing = Direction.byIndex(tag.getInt("facing"));
|
||||
handType = NBTHelper.readEnum(tag, "HandType", HandType.class);
|
||||
offset = tag.getInt("offset");
|
||||
super.readNBT(world, tag, spawnData);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAxisBeStabilized(Axis axis) {
|
||||
return axis == facing.getAxis();
|
||||
public boolean canBeStabilized(Direction facing, BlockPos localPos) {
|
||||
if (BlockPos.ZERO.equals(localPos) || BlockPos.ZERO.equals(localPos.offset(facing)))
|
||||
return false;
|
||||
return facing.getAxis() == this.facing.getAxis();
|
||||
}
|
||||
|
||||
public static enum HandType {
|
||||
|
@ -45,7 +45,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
|
||||
AbstractContraptionEntity entity = context.contraption.entity;
|
||||
if (entity instanceof ControlledContraptionEntity) {
|
||||
ControlledContraptionEntity controlledCE = (ControlledContraptionEntity) entity;
|
||||
if (controlledCE.getRotationAxis() == axis)
|
||||
if (context.contraption.canBeStabilized(facing, context.localPos))
|
||||
offset = -controlledCE.getAngle(renderPartialTicks);
|
||||
|
||||
} else if (entity instanceof OrientedContraptionEntity) {
|
||||
|
@ -55,7 +55,7 @@ public class StabilizedContraption extends Contraption {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAxisBeStabilized(Axis axis) {
|
||||
public boolean canBeStabilized(Direction facing, BlockPos localPos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class MountedContraption extends Contraption {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAxisBeStabilized(Axis axis) {
|
||||
public boolean canBeStabilized(Direction facing, BlockPos localPos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user