Search in sources :

Example 6 with PartialModel

use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.

the class AnimatedBlazeBurner method draw.

public void draw(PoseStack matrixStack, int xOffset, int yOffset) {
    matrixStack.pushPose();
    matrixStack.translate(xOffset, yOffset, 200);
    matrixStack.mulPose(Vector3f.XP.rotationDegrees(-15.5f));
    matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f));
    int scale = 23;
    blockElement(AllBlocks.BLAZE_BURNER.getDefaultState()).atLocal(0, 1.65, 0).scale(scale).render(matrixStack);
    float offset = (Mth.sin(AnimationTickHolder.getRenderTime() / 16f) + 0.5f) / 16f;
    PartialModel blaze = AllBlockPartials.BLAZES.get(heatLevel);
    blockElement(blaze).atLocal(1, 1.65 + offset, 1).rotate(0, 180, 0).scale(scale).render(matrixStack);
    matrixStack.popPose();
}
Also used : PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 7 with PartialModel

use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.

the class GaugeRenderer method renderSafe.

@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    if (Backend.canUseInstancing(te.getLevel()))
        return;
    super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
    BlockState gaugeState = te.getBlockState();
    GaugeTileEntity gaugeTE = (GaugeTileEntity) te;
    PartialModel partialModel = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS);
    SuperByteBuffer headBuffer = CachedBufferer.partial(partialModel, gaugeState);
    SuperByteBuffer dialBuffer = CachedBufferer.partial(AllBlockPartials.GAUGE_DIAL, gaugeState);
    float dialPivot = 5.75f / 16;
    float progress = Mth.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState);
    for (Direction facing : Iterate.directions) {
        if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getLevel(), te.getBlockPos(), gaugeState, facing))
            continue;
        VertexConsumer vb = buffer.getBuffer(RenderType.solid());
        rotateBufferTowards(dialBuffer, facing).translate(0, dialPivot, dialPivot).rotate(Direction.EAST, (float) (Math.PI / 2 * -progress)).translate(0, -dialPivot, -dialPivot).light(light).renderInto(ms, vb);
        rotateBufferTowards(headBuffer, facing).light(light).renderInto(ms, vb);
    }
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) Direction(net.minecraft.core.Direction) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 8 with PartialModel

use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.

the class EncasedCogInstance method getCogModel.

protected Instancer<RotatingData> getCogModel() {
    BlockState referenceState = blockEntity.getBlockState();
    Direction facing = Direction.fromAxisAndDirection(referenceState.getValue(BlockStateProperties.AXIS), AxisDirection.POSITIVE);
    PartialModel partial = large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL;
    return getRotatingMaterial().getModel(partial, referenceState, facing, () -> {
        PoseStack poseStack = new PoseStack();
        TransformStack.cast(poseStack).centre().rotateToFace(facing).multiply(Vector3f.XN.rotationDegrees(90)).unCentre();
        return poseStack;
    });
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) PoseStack(com.mojang.blaze3d.vertex.PoseStack) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 9 with PartialModel

use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.

the class DeployerInstance method tick.

@Override
public void tick() {
    PartialModel handPose = tile.getHandPose();
    if (currentHand != handPose) {
        currentHand = handPose;
        getOrientedMaterial().getModel(currentHand, blockState).stealInstance(hand);
    }
}
Also used : PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 10 with PartialModel

use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.

the class DeployerRenderer method renderInContraption.

public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffer) {
    VertexConsumer builder = buffer.getBuffer(RenderType.solid());
    BlockState blockState = context.state;
    Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class);
    PartialModel handPose = getHandPose(mode);
    float speed = (float) context.getAnimationSpeed();
    if (context.contraption.stalled)
        speed = 0;
    SuperByteBuffer shaft = CachedBufferer.block(AllBlocks.SHAFT.getDefaultState());
    SuperByteBuffer pole = CachedBufferer.partial(AllBlockPartials.DEPLOYER_POLE, blockState);
    SuperByteBuffer hand = CachedBufferer.partial(handPose, blockState);
    double factor;
    if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) {
        factor = Mth.sin(AnimationTickHolder.getRenderTime() * .5f) * .25f + .25f;
    } else {
        Vec3 center = VecHelper.getCenterOf(new BlockPos(context.position));
        double distance = context.position.distanceTo(center);
        double nextDistance = context.position.add(context.motion).distanceTo(center);
        factor = .5f - Mth.clamp(Mth.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1);
    }
    Vec3 offset = Vec3.atLowerCornerOf(blockState.getValue(FACING).getNormal()).scale(factor);
    PoseStack m = matrices.getModel();
    m.pushPose();
    m.pushPose();
    Axis axis = Axis.Y;
    if (context.state.getBlock() instanceof IRotate) {
        IRotate def = (IRotate) context.state.getBlock();
        axis = def.getRotationAxis(context.state);
    }
    float time = AnimationTickHolder.getRenderTime(context.world) / 20;
    float angle = (time * speed) % 360;
    TransformStack.cast(m).centre().rotateY(axis == Axis.Z ? 90 : 0).rotateZ(axis.isHorizontal() ? 90 : 0).unCentre();
    shaft.transform(m);
    shaft.rotateCentered(Direction.get(AxisDirection.POSITIVE, Axis.Y), angle);
    m.popPose();
    m.translate(offset.x, offset.y, offset.z);
    pole.transform(m);
    hand.transform(m);
    transform(pole, blockState, true);
    transform(hand, blockState, false);
    shaft.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), builder);
    pole.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), builder);
    hand.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), builder);
    m.popPose();
}
Also used : IRotate(com.simibubi.create.content.contraptions.base.IRotate) BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) PoseStack(com.mojang.blaze3d.vertex.PoseStack) Mode(com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode) Vec3(net.minecraft.world.phys.Vec3) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) BlockPos(net.minecraft.core.BlockPos) PartialModel(com.jozufozu.flywheel.core.PartialModel) Axis(net.minecraft.core.Direction.Axis)

Aggregations

PartialModel (com.jozufozu.flywheel.core.PartialModel)17 SuperByteBuffer (com.simibubi.create.foundation.render.SuperByteBuffer)11 Direction (net.minecraft.core.Direction)8 BlockState (net.minecraft.world.level.block.state.BlockState)8 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)5 PoseStack (com.mojang.blaze3d.vertex.PoseStack)4 TransformStack (com.jozufozu.flywheel.util.transform.TransformStack)2 AxisDirection (net.minecraft.core.Direction.AxisDirection)2 Block (net.minecraft.world.level.block.Block)2 Vec3 (net.minecraft.world.phys.Vec3)2 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)2 Matrix3f (com.mojang.math.Matrix3f)1 Quaternion (com.mojang.math.Quaternion)1 IRotate (com.simibubi.create.content.contraptions.base.IRotate)1 Mode (com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode)1 HeatLevel (com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel)1 BlueprintSection (com.simibubi.create.content.curiosities.tools.BlueprintEntity.BlueprintSection)1 SpriteShiftEntry (com.simibubi.create.foundation.block.render.SpriteShiftEntry)1 SmartFluidTankBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour)1 TankSegment (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)1