Search in sources :

Example 81 with Axis

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);
    }
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) Axis(net.minecraft.core.Direction.Axis)

Example 82 with 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;
    });
}
Also used : DirectionalExtenderScrollOptionSlot(com.simibubi.create.content.contraptions.components.structureMovement.DirectionalExtenderScrollOptionSlot) Axis(net.minecraft.core.Direction.Axis)

Example 83 with 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;
}
Also used : Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection) Axis(net.minecraft.core.Direction.Axis)

Example 84 with 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;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.core.BlockPos) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection) Axis(net.minecraft.core.Direction.Axis) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 85 with Axis

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));
            }
        }
    }
}
Also used : HashSet(java.util.HashSet) Axis(net.minecraft.core.Direction.Axis) List(java.util.List) Facing(team.creative.creativecore.common.util.math.base.Facing) Iterator(java.util.Iterator) BlockPos(net.minecraft.core.BlockPos) SingletonList(team.creative.creativecore.common.util.type.list.SingletonList) BlockState(net.minecraft.world.level.block.state.BlockState) CreativeLevel(team.creative.creativecore.common.level.CreativeLevel) LevelBoundsListener(team.creative.creativecore.common.level.listener.LevelBoundsListener) ArrayList(java.util.ArrayList) Facing(team.creative.creativecore.common.util.math.base.Facing) BlockState(net.minecraft.world.level.block.state.BlockState) SingletonList(team.creative.creativecore.common.util.type.list.SingletonList) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.core.BlockPos) List(java.util.List) SingletonList(team.creative.creativecore.common.util.type.list.SingletonList) ArrayList(java.util.ArrayList) Axis(net.minecraft.core.Direction.Axis)

Aggregations

Axis (net.minecraft.core.Direction.Axis)85 Direction (net.minecraft.core.Direction)43 BlockPos (net.minecraft.core.BlockPos)39 BlockState (net.minecraft.world.level.block.state.BlockState)35 AxisDirection (net.minecraft.core.Direction.AxisDirection)24 Vec3 (net.minecraft.world.phys.Vec3)14 Level (net.minecraft.world.level.Level)13 IRotate (com.simibubi.create.content.contraptions.base.IRotate)9 SuperByteBuffer (com.simibubi.create.foundation.render.SuperByteBuffer)7 Block (net.minecraft.world.level.block.Block)7 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)6 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)5 Player (net.minecraft.world.entity.player.Player)5 HashSet (java.util.HashSet)4 ItemStack (net.minecraft.world.item.ItemStack)4 KineticTileEntity (com.simibubi.create.content.contraptions.base.KineticTileEntity)3 Part (com.simibubi.create.content.contraptions.relays.encased.EncasedBeltBlock.Part)3 ArrayList (java.util.ArrayList)3 ServerLevel (net.minecraft.server.level.ServerLevel)3 StructureBlockInfo (net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo)3