use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class BeltTunnelBlock method getTunnelState.
private BlockState getTunnelState(BlockGetter reader, BlockPos pos) {
BlockState state = defaultBlockState();
BlockState belt = reader.getBlockState(pos.below());
if (AllBlocks.BELT.has(belt))
state = state.setValue(HORIZONTAL_AXIS, belt.getValue(BeltBlock.HORIZONTAL_FACING).getAxis());
Axis axis = state.getValue(HORIZONTAL_AXIS);
// T and Cross
Direction left = Direction.get(AxisDirection.POSITIVE, axis).getClockWise();
boolean onLeft = hasValidOutput(reader, pos.below(), left);
boolean onRight = hasValidOutput(reader, pos.below(), left.getOpposite());
if (onLeft && onRight)
state = state.setValue(SHAPE, Shape.CROSS);
else if (onLeft)
state = state.setValue(SHAPE, Shape.T_LEFT);
else if (onRight)
state = state.setValue(SHAPE, Shape.T_RIGHT);
if (state.getValue(SHAPE) == Shape.STRAIGHT) {
boolean canHaveWindow = canHaveWindow(reader, pos, axis);
if (canHaveWindow)
state = state.setValue(SHAPE, Shape.WINDOW);
}
return state;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class RotatedPillarCTBehaviour method getUpDirection.
@Override
protected Direction getUpDirection(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) {
Axis axis = state.getValue(LayeredBlock.AXIS);
if (axis == Axis.Y)
return super.getUpDirection(reader, pos, state, face);
boolean alongX = axis == Axis.X;
if (face.getAxis().isVertical() && alongX)
return super.getUpDirection(reader, pos, state, face).getClockWise();
if (face.getAxis() == axis || face.getAxis().isVertical())
return super.getUpDirection(reader, pos, state, face);
return Direction.fromAxisAndDirection(axis, alongX ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE);
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class Contraption method moveGantryPinion.
protected void moveGantryPinion(Level world, BlockPos pos, Queue<BlockPos> frontier, Set<BlockPos> visited, BlockState state) {
BlockPos offset = pos.relative(state.getValue(GantryCarriageBlock.FACING));
if (!visited.contains(offset))
frontier.add(offset);
Axis rotationAxis = ((IRotate) state.getBlock()).getRotationAxis(state);
for (Direction d : Iterate.directionsInAxis(rotationAxis)) {
offset = pos.relative(d);
BlockState offsetState = world.getBlockState(offset);
if (AllBlocks.GANTRY_SHAFT.has(offsetState) && offsetState.getValue(GantryShaftBlock.FACING).getAxis() == d.getAxis())
if (!visited.contains(offset))
frontier.add(offset);
}
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class StabilizedBearingMovementBehaviour method getCounterRotationAngle.
static float getCounterRotationAngle(MovementContext context, Direction facing, float renderPartialTicks) {
float offset = 0;
Axis axis = facing.getAxis();
AbstractContraptionEntity entity = context.contraption.entity;
if (entity instanceof ControlledContraptionEntity) {
ControlledContraptionEntity controlledCE = (ControlledContraptionEntity) entity;
if (context.contraption.canBeStabilized(facing, context.localPos))
offset = -controlledCE.getAngle(renderPartialTicks);
} else if (entity instanceof OrientedContraptionEntity) {
OrientedContraptionEntity orientedCE = (OrientedContraptionEntity) entity;
if (axis.isVertical())
offset = -orientedCE.getViewYRot(renderPartialTicks);
else {
if (orientedCE.isInitialOrientationPresent() && orientedCE.getInitialOrientation().getAxis() == axis)
offset = -orientedCE.getViewXRot(renderPartialTicks);
}
}
return offset;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class ChassisTileEntity method addAttachedChasses.
public boolean addAttachedChasses(Queue<BlockPos> frontier, Set<BlockPos> visited) {
BlockState state = getBlockState();
if (!(state.getBlock() instanceof AbstractChassisBlock))
return false;
Axis axis = state.getValue(AbstractChassisBlock.AXIS);
if (isRadial()) {
// Collect chain of radial chassis
for (int offset : new int[] { -1, 1 }) {
Direction direction = Direction.get(AxisDirection.POSITIVE, axis);
BlockPos currentPos = worldPosition.relative(direction, offset);
if (!level.isLoaded(currentPos))
return false;
BlockState neighbourState = level.getBlockState(currentPos);
if (!AllBlocks.RADIAL_CHASSIS.has(neighbourState))
continue;
if (axis != neighbourState.getValue(BlockStateProperties.AXIS))
continue;
if (!visited.contains(currentPos))
frontier.add(currentPos);
}
return true;
}
// Collect group of connected linear chassis
for (Direction offset : Iterate.directions) {
BlockPos current = worldPosition.relative(offset);
if (visited.contains(current))
continue;
if (!level.isLoaded(current))
return false;
BlockState neighbourState = level.getBlockState(current);
if (!LinearChassisBlock.isChassis(neighbourState))
continue;
if (!LinearChassisBlock.sameKind(state, neighbourState))
continue;
if (neighbourState.getValue(LinearChassisBlock.AXIS) != axis)
continue;
frontier.add(current);
}
return true;
}
Aggregations