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