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);
}
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));
}
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;
}
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.");
}
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();
}
Aggregations