use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class ClockworkBearingTileEntity method applyRotations.
protected void applyRotations() {
BlockState blockState = getBlockState();
Axis axis = Axis.X;
if (blockState.hasProperty(BlockStateProperties.FACING))
axis = blockState.getValue(BlockStateProperties.FACING).getAxis();
if (hourHand != null) {
hourHand.setAngle(hourAngle);
hourHand.setRotationAxis(axis);
}
if (minuteHand != null) {
minuteHand.setAngle(minuteAngle);
minuteHand.setRotationAxis(axis);
}
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class IBearingTileEntity method getMovementModeSlot.
default ValueBoxTransform getMovementModeSlot() {
return new DirectionalExtenderScrollOptionSlot((state, d) -> {
Axis axis = d.getAxis();
Axis bearingAxis = state.getValue(BearingBlock.FACING).getAxis();
return bearingAxis != axis;
});
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class StructureTransform method transformAxis.
public Axis transformAxis(Axis axisIn) {
Direction facing = Direction.get(AxisDirection.POSITIVE, axisIn);
facing = transformFacing(facing);
Axis axis = facing.getAxis();
return axis;
}
use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.
the class ChassisTileEntity method getIncludedBlockPositionsRadial.
private List<BlockPos> getIncludedBlockPositionsRadial(Direction forcedMovement, boolean visualize) {
List<BlockPos> positions = new ArrayList<>();
BlockState state = level.getBlockState(worldPosition);
Axis axis = state.getValue(AbstractChassisBlock.AXIS);
AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock();
int chassisRange = visualize ? range.scrollableValue : getRange();
for (Direction facing : Iterate.directions) {
if (facing.getAxis() == axis)
continue;
if (!state.getValue(block.getGlueableSide(state, facing)))
continue;
BlockPos startPos = worldPosition.relative(facing);
List<BlockPos> localFrontier = new LinkedList<>();
Set<BlockPos> localVisited = new HashSet<>();
localFrontier.add(startPos);
while (!localFrontier.isEmpty()) {
BlockPos searchPos = localFrontier.remove(0);
BlockState searchedState = level.getBlockState(searchPos);
if (localVisited.contains(searchPos))
continue;
if (!searchPos.closerThan(worldPosition, chassisRange + .5f))
continue;
if (!BlockMovementChecks.isMovementNecessary(searchedState, level, searchPos))
continue;
if (BlockMovementChecks.isBrittle(searchedState))
continue;
localVisited.add(searchPos);
if (!searchPos.equals(worldPosition))
positions.add(searchPos);
for (Direction offset : Iterate.directions) {
if (offset.getAxis() == axis)
continue;
if (searchPos.equals(worldPosition) && offset != facing)
continue;
if (BlockMovementChecks.isNotSupportive(searchedState, offset))
continue;
localFrontier.add(searchPos.relative(offset));
}
}
}
return positions;
}
use of net.minecraft.core.Direction.Axis in project CreativeCore by CreativeMD.
the class BlockUpdateLevelSystem method blockChanged.
public void blockChanged(BlockPos pos) {
BlockState state = level.getBlockState(pos);
if (state.isAir()) {
// Shrinking
if (allBlocks.remove(pos) && edgePositions.remove(pos)) {
for (int i = 0; i < Facing.values().length; i++) {
Facing facing = Facing.values()[i];
Axis axis = facing.axis.toVanilla();
int bound = getBound(facing);
if (bound == pos.get(axis)) {
List<BlockPos> remaining = new ArrayList<>();
for (BlockPos edge : edgePositions) if (edge.get(axis) == bound)
remaining.add(edge);
if (remaining.isEmpty()) {
int newBound = facing.positive ? Integer.MIN_VALUE : Integer.MAX_VALUE;
for (BlockPos scan : allBlocks) newBound = facing.positive ? Math.max(newBound, scan.get(axis)) : Math.min(newBound, scan.get(axis));
for (BlockPos scan : allBlocks) if (scan.get(axis) == newBound) {
remaining.add(scan);
edgePositions.add(scan);
}
setBound(facing, newBound);
}
levelBoundListeners.forEach(x -> x.rescan(level, this, facing, remaining, facing.positive ? bound + 1 : bound));
}
}
}
} else if (allBlocks.add(pos) && !isWithinBoundsNoEdge(pos)) {
// Expanding
for (int i = 0; i < Facing.values().length; i++) {
Facing facing = Facing.values()[i];
Axis axis = facing.axis.toVanilla();
int bound = getBound(facing);
if (bound == pos.get(axis)) {
List<BlockPos> remaining = new ArrayList<>();
edgePositions.add(pos);
for (BlockPos edge : edgePositions) if (edge.get(axis) == bound)
remaining.add(edge);
levelBoundListeners.forEach(x -> x.rescan(level, this, facing, remaining, facing.positive ? bound + 1 : bound));
} else if (bound > pos.get(axis)) {
for (Iterator<BlockPos> itr = edgePositions.iterator(); itr.hasNext(); ) {
BlockPos edge = itr.next();
if (edge.get(axis) == bound && !isEdgeExcept(edge, facing))
itr.remove();
}
edgePositions.add(pos);
levelBoundListeners.forEach(x -> x.rescan(level, this, facing, new SingletonList<>(pos), facing.positive ? bound + 1 : bound));
}
}
}
}
Aggregations