Search in sources :

Example 1 with Axis

use of net.minecraft.core.Direction.Axis in project createaddition by mrh0.

the class RollingMillRenderer method renderSafe.

@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
    if (Backend.canUseInstancing(te.getLevel()))
        return;
    BlockState blockState = te.getBlockState();
    BlockPos pos = te.getBlockPos();
    VertexConsumer vb = buffer.getBuffer(RenderType.solid());
    int packedLightmapCoords = LevelRenderer.getLightColor(te.getLevel(), pos);
    // SuperByteBuffer shaft = AllBlockPartials.SHAFT_HALF.renderOn(blockState);
    SuperByteBuffer shaft = CachedBufferer.partial(AllBlockPartials.SHAFT_HALF, blockState);
    Axis axis = getRotationAxisOf(te);
    shaft.rotateCentered(Direction.UP, axis == Axis.Z ? 0 : 90 * (float) Math.PI / 180f).translate(0, 4f / 16f, 0).rotateCentered(Direction.NORTH, getAngleForTe(te, pos, axis)).light(packedLightmapCoords).renderInto(ms, vb);
    shaft.rotateCentered(Direction.UP, axis == Axis.Z ? 180 * (float) Math.PI / 180f : 270 * (float) Math.PI / 180f).translate(0, 4f / 16f, 0).rotateCentered(Direction.NORTH, -getAngleForTe(te, pos, axis)).light(packedLightmapCoords).renderInto(ms, vb);
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) BlockPos(net.minecraft.core.BlockPos) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) Axis(net.minecraft.core.Direction.Axis)

Example 2 with Axis

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

the class BracketBlock method getSuitableBracket.

private Optional<BlockState> getSuitableBracket(Axis targetBlockAxis, Direction direction, BracketType type) {
    Axis axis = direction.getAxis();
    if (targetBlockAxis == null || targetBlockAxis == axis)
        return Optional.empty();
    boolean alongFirst = axis != Axis.Z ? targetBlockAxis == Axis.Z : targetBlockAxis == Axis.Y;
    return Optional.of(defaultBlockState().setValue(TYPE, type).setValue(FACING, direction).setValue(AXIS_ALONG_FIRST_COORDINATE, !alongFirst));
}
Also used : Axis(net.minecraft.core.Direction.Axis)

Example 3 with Axis

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

the class SmartFluidPipeBlock method getStateForPlacement.

@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
    BlockState stateForPlacement = super.getStateForPlacement(ctx);
    Axis prefferedAxis = null;
    BlockPos pos = ctx.getClickedPos();
    Level world = ctx.getLevel();
    for (Direction side : Iterate.directions) {
        if (!prefersConnectionTo(world, pos, side))
            continue;
        if (prefferedAxis != null && prefferedAxis != side.getAxis()) {
            prefferedAxis = null;
            break;
        }
        prefferedAxis = side.getAxis();
    }
    if (prefferedAxis == Axis.Y)
        stateForPlacement = stateForPlacement.setValue(FACE, AttachFace.WALL).setValue(FACING, stateForPlacement.getValue(FACING).getOpposite());
    else if (prefferedAxis != null) {
        if (stateForPlacement.getValue(FACE) == AttachFace.WALL)
            stateForPlacement = stateForPlacement.setValue(FACE, AttachFace.FLOOR);
        for (Direction direction : ctx.getNearestLookingDirections()) {
            if (direction.getAxis() != prefferedAxis)
                continue;
            stateForPlacement = stateForPlacement.setValue(FACING, direction.getOpposite());
        }
    }
    return stateForPlacement;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) BlockPos(net.minecraft.core.BlockPos) ServerLevel(net.minecraft.server.level.ServerLevel) Level(net.minecraft.world.level.Level) Direction(net.minecraft.core.Direction) Axis(net.minecraft.core.Direction.Axis)

Example 4 with Axis

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

the class FluidValveBlock method getPipeAxis.

@Nonnull
public static Axis getPipeAxis(BlockState state) {
    if (!(state.getBlock() instanceof FluidValveBlock))
        throw new IllegalStateException("Provided BlockState is for a different block.");
    Direction facing = state.getValue(FACING);
    boolean alongFirst = !state.getValue(AXIS_ALONG_FIRST_COORDINATE);
    for (Axis axis : Iterate.axes) {
        if (axis == facing.getAxis())
            continue;
        if (!alongFirst) {
            alongFirst = true;
            continue;
        }
        return axis;
    }
    throw new IllegalStateException("Impossible axis.");
}
Also used : Direction(net.minecraft.core.Direction) Axis(net.minecraft.core.Direction.Axis) Nonnull(javax.annotation.Nonnull)

Example 5 with Axis

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

the class ControlledContraptionEntity method doLocalTransforms.

@Override
@OnlyIn(Dist.CLIENT)
public void doLocalTransforms(float partialTicks, PoseStack[] matrixStacks) {
    float angle = getAngle(partialTicks);
    Axis axis = getRotationAxis();
    for (PoseStack stack : matrixStacks) TransformStack.cast(stack).nudge(getId()).centre().rotate(angle, axis).unCentre();
}
Also used : PoseStack(com.mojang.blaze3d.vertex.PoseStack) Axis(net.minecraft.core.Direction.Axis) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

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