Search in sources :

Example 11 with Axis

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;
}
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)

Example 12 with Axis

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

Example 13 with Axis

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

Example 14 with Axis

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;
}
Also used : 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 15 with Axis

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