Search in sources :

Example 76 with Axis

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

Example 77 with Axis

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

Example 78 with Axis

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);
    }
}
Also used : IRotate(com.simibubi.create.content.contraptions.base.IRotate) BlockState(net.minecraft.world.level.block.state.BlockState) BlockPos(net.minecraft.core.BlockPos) Direction(net.minecraft.core.Direction) Axis(net.minecraft.core.Direction.Axis)

Example 79 with Axis

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

Example 80 with Axis

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