Search in sources :

Example 56 with Axis

use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.

the class EncasedBeltBlock method areBlocksConnected.

public static boolean areBlocksConnected(BlockState state, BlockState other, Direction facing) {
    Part part = state.getValue(PART);
    Axis connectionAxis = getConnectionAxis(state);
    Axis otherConnectionAxis = getConnectionAxis(other);
    if (otherConnectionAxis != connectionAxis)
        return false;
    if (facing.getAxis() != connectionAxis)
        return false;
    if (facing.getAxisDirection() == AxisDirection.POSITIVE && (part == Part.MIDDLE || part == Part.START))
        return true;
    if (facing.getAxisDirection() == AxisDirection.NEGATIVE && (part == Part.MIDDLE || part == Part.END))
        return true;
    return false;
}
Also used : Axis(net.minecraft.core.Direction.Axis)

Example 57 with Axis

use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.

the class EncasedBeltBlock method getConnectionAxis.

protected static Axis getConnectionAxis(BlockState state) {
    Axis axis = state.getValue(AXIS);
    boolean connectionAlongFirst = state.getValue(CONNECTED_ALONG_FIRST_COORDINATE);
    Axis connectionAxis = connectionAlongFirst ? (axis == Axis.X ? Axis.Y : Axis.X) : (axis == Axis.Z ? Axis.Y : Axis.Z);
    return connectionAxis;
}
Also used : Axis(net.minecraft.core.Direction.Axis)

Example 58 with Axis

use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.

the class EncasedBeltGenerator method getYRotation.

@Override
protected int getYRotation(BlockState state) {
    EncasedBeltBlock.Part part = state.getValue(EncasedBeltBlock.PART);
    boolean connectedAlongFirst = state.getValue(EncasedBeltBlock.CONNECTED_ALONG_FIRST_COORDINATE);
    Axis axis = state.getValue(EncasedBeltBlock.AXIS);
    if (part == Part.NONE)
        return axis == Axis.X ? 90 : 0;
    if (axis == Axis.Z)
        return (connectedAlongFirst && part == Part.END ? 270 : 90);
    boolean flip = part == Part.END && !connectedAlongFirst || part == Part.START && connectedAlongFirst;
    if (axis == Axis.Y)
        return (connectedAlongFirst ? 90 : 0) + (flip ? 180 : 0);
    return 0;
}
Also used : Part(com.simibubi.create.content.contraptions.relays.encased.EncasedBeltBlock.Part) Axis(net.minecraft.core.Direction.Axis)

Example 59 with Axis

use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.

the class IWrenchableWithBracket method tryRemoveBracket.

default boolean tryRemoveBracket(UseOnContext context) {
    Level world = context.getLevel();
    BlockPos pos = context.getClickedPos();
    Optional<ItemStack> bracket = removeBracket(world, pos, false);
    BlockState blockState = world.getBlockState(pos);
    if (bracket.isPresent()) {
        Player player = context.getPlayer();
        if (!world.isClientSide && !player.isCreative())
            player.getInventory().placeItemBackInInventory(bracket.get());
        if (!world.isClientSide && AllBlocks.FLUID_PIPE.has(blockState)) {
            Axis preferred = FluidPropagator.getStraightPipeAxis(blockState);
            Direction preferredDirection = preferred == null ? Direction.UP : Direction.get(AxisDirection.POSITIVE, preferred);
            BlockState updated = AllBlocks.FLUID_PIPE.get().updateBlockState(blockState, preferredDirection, null, world, pos);
            if (updated != blockState)
                world.setBlockAndUpdate(pos, updated);
        }
        return true;
    }
    return false;
}
Also used : Player(net.minecraft.world.entity.player.Player) BlockState(net.minecraft.world.level.block.state.BlockState) Level(net.minecraft.world.level.Level) BlockPos(net.minecraft.core.BlockPos) ItemStack(net.minecraft.world.item.ItemStack) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection) Axis(net.minecraft.core.Direction.Axis)

Example 60 with Axis

use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.

the class ItemVaultCTBehaviour method getUpDirection.

@Override
protected Direction getUpDirection(BlockAndTintGetter reader, BlockPos pos, BlockState state, Direction face) {
    Axis vaultBlockAxis = ItemVaultBlock.getVaultBlockAxis(state);
    boolean alongX = vaultBlockAxis == Axis.X;
    if (face.getAxis().isVertical() && alongX)
        return super.getUpDirection(reader, pos, state, face).getClockWise();
    if (face.getAxis() == vaultBlockAxis || face.getAxis().isVertical())
        return super.getUpDirection(reader, pos, state, face);
    return Direction.fromAxisAndDirection(vaultBlockAxis, alongX ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE);
}
Also used : 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