use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class ChassisTileEntity method getIncludedBlockPositionsLinear.
private List<BlockPos> getIncludedBlockPositionsLinear(Direction forcedMovement, boolean visualize) {
List<BlockPos> positions = new ArrayList<>();
BlockState state = getBlockState();
AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock();
Axis axis = state.getValue(AbstractChassisBlock.AXIS);
Direction facing = Direction.get(AxisDirection.POSITIVE, axis);
int chassisRange = visualize ? range.scrollableValue : getRange();
for (int offset : new int[] { 1, -1 }) {
if (offset == -1)
facing = facing.getOpposite();
boolean sticky = state.getValue(block.getGlueableSide(state, facing));
for (int i = 1; i <= chassisRange; i++) {
BlockPos current = worldPosition.relative(facing, i);
BlockState currentState = level.getBlockState(current);
if (forcedMovement != facing && !sticky)
break;
// Ignore replaceable Blocks and Air-like
if (!BlockMovementChecks.isMovementNecessary(currentState, level, current))
break;
if (BlockMovementChecks.isBrittle(currentState))
break;
positions.add(current);
if (BlockMovementChecks.isNotSupportive(currentState, facing))
break;
}
}
return positions;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class GantryCarriageBlock method getValidGantryShaftAxis.
public static Axis getValidGantryShaftAxis(BlockState state) {
if (!(state.getBlock() instanceof GantryCarriageBlock))
return Axis.Y;
IRotate block = (IRotate) state.getBlock();
Axis rotationAxis = block.getRotationAxis(state);
Axis facingAxis = state.getValue(FACING).getAxis();
for (Axis axis : Iterate.axes) if (axis != rotationAxis && axis != facingAxis)
return axis;
return Axis.Y;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class GantryCarriageTileEntity method getGantryPinionModifier.
public static float getGantryPinionModifier(Direction shaft, Direction pinionDirection) {
Axis shaftAxis = shaft.getAxis();
float directionModifier = shaft.getAxisDirection().getStep();
if (shaftAxis == Axis.Y)
if (pinionDirection == Direction.NORTH || pinionDirection == Direction.EAST)
return -directionModifier;
if (shaftAxis == Axis.X)
if (pinionDirection == Direction.DOWN || pinionDirection == Direction.SOUTH)
return -directionModifier;
if (shaftAxis == Axis.Z)
if (pinionDirection == Direction.UP || pinionDirection == Direction.WEST)
return -directionModifier;
return directionModifier;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class CrushingWheelBlock method canSurvive.
@Override
public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) {
for (Direction direction : Iterate.directions) {
BlockPos neighbourPos = pos.relative(direction);
BlockState neighbourState = worldIn.getBlockState(neighbourPos);
Axis stateAxis = state.getValue(AXIS);
if (AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(neighbourState) && direction.getAxis() != stateAxis)
return false;
if (!AllBlocks.CRUSHING_WHEEL.has(neighbourState))
continue;
if (neighbourState.getValue(AXIS) != stateAxis || stateAxis != direction.getAxis())
return false;
}
return true;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class CrushingWheelControllerBlock method entityInside.
public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity entityIn) {
if (!state.getValue(VALID))
return;
Direction facing = state.getValue(FACING);
Axis axis = facing.getAxis();
checkEntityForProcessing(worldIn, pos, entityIn);
withTileEntityDo(worldIn, pos, te -> {
if (te.processingEntity == entityIn)
entityIn.makeStuckInBlock(state, new Vec3(axis == Axis.X ? (double) 0.05F : 0.25D, axis == Axis.Y ? (double) 0.05F : 0.25D, axis == Axis.Z ? (double) 0.05F : 0.25D));
});
}
Aggregations