use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class EncasedBeltBlock method updateShape.
@Override
public BlockState updateShape(BlockState stateIn, Direction face, BlockState neighbour, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) {
Part part = stateIn.getValue(PART);
Axis axis = stateIn.getValue(AXIS);
boolean connectionAlongFirst = stateIn.getValue(CONNECTED_ALONG_FIRST_COORDINATE);
Axis connectionAxis = connectionAlongFirst ? (axis == Axis.X ? Axis.Y : Axis.X) : (axis == Axis.Z ? Axis.Y : Axis.Z);
Axis faceAxis = face.getAxis();
boolean facingAlongFirst = axis == Axis.X ? faceAxis.isVertical() : faceAxis == Axis.X;
boolean positive = face.getAxisDirection() == AxisDirection.POSITIVE;
if (axis == faceAxis)
return stateIn;
if (!(neighbour.getBlock() instanceof EncasedBeltBlock)) {
if (facingAlongFirst != connectionAlongFirst || part == Part.NONE)
return stateIn;
if (part == Part.MIDDLE)
return stateIn.setValue(PART, positive ? Part.END : Part.START);
if ((part == Part.START) == positive)
return stateIn.setValue(PART, Part.NONE);
return stateIn;
}
Part otherPart = neighbour.getValue(PART);
Axis otherAxis = neighbour.getValue(AXIS);
boolean otherConnection = neighbour.getValue(CONNECTED_ALONG_FIRST_COORDINATE);
Axis otherConnectionAxis = otherConnection ? (otherAxis == Axis.X ? Axis.Y : Axis.X) : (otherAxis == Axis.Z ? Axis.Y : Axis.Z);
if (neighbour.getValue(AXIS) == faceAxis)
return stateIn;
if (otherPart != Part.NONE && otherConnectionAxis != faceAxis)
return stateIn;
if (part == Part.NONE) {
part = positive ? Part.START : Part.END;
connectionAlongFirst = axis == Axis.X ? faceAxis.isVertical() : faceAxis == Axis.X;
} else if (connectionAxis != faceAxis) {
return stateIn;
}
if ((part == Part.START) != positive)
part = Part.MIDDLE;
return stateIn.setValue(PART, part).setValue(CONNECTED_ALONG_FIRST_COORDINATE, connectionAlongFirst);
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class EncasedBeltBlock method getStateForPlacement.
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
Axis placedAxis = context.getNearestLookingDirection().getAxis();
Axis axis = context.getPlayer() != null && context.getPlayer().isShiftKeyDown() ? placedAxis : getPreferredAxis(context);
if (axis == null)
axis = placedAxis;
BlockState state = defaultBlockState().setValue(AXIS, axis);
for (Direction facing : Iterate.directions) {
if (facing.getAxis() == axis)
continue;
BlockPos pos = context.getClickedPos();
BlockPos offset = pos.relative(facing);
state = updateShape(state, facing, context.getLevel().getBlockState(offset), context.getLevel(), pos, offset);
}
return state;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class EncasedBeltGenerator method getModelSuffix.
protected String getModelSuffix(BlockState state) {
EncasedBeltBlock.Part part = state.getValue(EncasedBeltBlock.PART);
Axis axis = state.getValue(EncasedBeltBlock.AXIS);
if (part == Part.NONE)
return "single";
String orientation = axis == Axis.Y ? "vertical" : "horizontal";
String section = part == Part.MIDDLE ? "middle" : "end";
return section + "_" + orientation;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class EncasedBeltGenerator method getXRotation.
@Override
protected int getXRotation(BlockState state) {
EncasedBeltBlock.Part part = state.getValue(EncasedBeltBlock.PART);
boolean connectedAlongFirst = state.getValue(EncasedBeltBlock.CONNECTED_ALONG_FIRST_COORDINATE);
Axis axis = state.getValue(EncasedBeltBlock.AXIS);
if (part == Part.NONE)
return axis == Axis.Y ? 90 : 0;
if (axis == Axis.X)
return (connectedAlongFirst ? 90 : 0) + (part == Part.START ? 180 : 0);
if (axis == Axis.Z)
return (connectedAlongFirst ? 0 : (part == Part.START ? 270 : 90));
return 0;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class EncasedCogCTBehaviour method connectsTo.
@Override
public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos, Direction face) {
Axis axis = state.getValue(AXIS);
if (large || axis == face.getAxis())
return super.connectsTo(state, other, reader, pos, otherPos, face);
if (other.getBlock() == state.getBlock() && other.getValue(AXIS) == state.getValue(AXIS))
return true;
BlockState blockState = reader.getBlockState(otherPos.relative(face));
if (!ICogWheel.isLargeCog(blockState))
return false;
return ((IRotate) blockState.getBlock()).getRotationAxis(blockState) == axis;
}
Aggregations