use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class CuckooClockRenderer 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 (!(te instanceof CuckooClockTileEntity))
return;
CuckooClockTileEntity clock = (CuckooClockTileEntity) te;
BlockState blockState = te.getBlockState();
Direction direction = blockState.getValue(CuckooClockBlock.HORIZONTAL_FACING);
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
// Render Hands
SuperByteBuffer hourHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_HOUR_HAND, blockState);
SuperByteBuffer minuteHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState);
float hourAngle = clock.hourHand.get(partialTicks);
float minuteAngle = clock.minuteHand.get(partialTicks);
rotateHand(hourHand, hourAngle, direction).light(light).renderInto(ms, vb);
rotateHand(minuteHand, minuteAngle, direction).light(light).renderInto(ms, vb);
// Doors
SuperByteBuffer leftDoor = CachedBufferer.partial(AllBlockPartials.CUCKOO_LEFT_DOOR, blockState);
SuperByteBuffer rightDoor = CachedBufferer.partial(AllBlockPartials.CUCKOO_RIGHT_DOOR, blockState);
float angle = 0;
float offset = 0;
if (clock.animationType != null) {
float value = clock.animationProgress.get(partialTicks);
int step = clock.animationType == Animation.SURPRISE ? 3 : 15;
for (int phase = 30; phase <= 60; phase += step) {
float local = value - phase;
if (local < -step / 3)
continue;
else if (local < 0)
angle = Mth.lerp(((value - (phase - 5)) / 5), 0, 135);
else if (local < step / 3)
angle = 135;
else if (local < 2 * step / 3)
angle = Mth.lerp(((value - (phase + 5)) / 5), 135, 0);
}
}
rotateDoor(leftDoor, angle, true, direction).light(light).renderInto(ms, vb);
rotateDoor(rightDoor, angle, false, direction).light(light).renderInto(ms, vb);
// Figure
if (clock.animationType != Animation.NONE) {
offset = -(angle / 135) * 1 / 2f + 10 / 16f;
PartialModel partialModel = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER);
SuperByteBuffer figure = CachedBufferer.partial(partialModel, blockState);
figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise())));
figure.translate(offset, 0, 0);
figure.light(light).renderInto(ms, vb);
}
}
use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class DrillRenderer method renderInContraption.
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffer) {
BlockState state = context.state;
SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.DRILL_HEAD, state);
Direction facing = state.getValue(DrillBlock.FACING);
float speed = (float) (context.contraption.stalled || !VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite()) ? context.getAnimationSpeed() : 0);
float time = AnimationTickHolder.getRenderTime() / 20;
float angle = (float) (((time * speed) % 360));
superBuffer.transform(matrices.getModel()).centre().rotateY(AngleHelper.horizontalAngle(facing)).rotateX(AngleHelper.verticalAngle(facing)).rotateZ(angle).unCentre().light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid()));
}
use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class HarvesterRenderer method renderSafe.
@Override
protected void renderSafe(HarvesterTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
BlockState blockState = te.getBlockState();
SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.HARVESTER_BLADE, blockState);
transform(te.getLevel(), blockState.getValue(HarvesterBlock.FACING), superBuffer, te.getAnimatedSpeed());
superBuffer.light(light).renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped()));
}
use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class HarvesterRenderer method renderInContraption.
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffers) {
BlockState blockState = context.state;
Direction facing = blockState.getValue(HORIZONTAL_FACING);
SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.HARVESTER_BLADE, blockState);
float speed = (float) (!VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite()) ? context.getAnimationSpeed() : 0);
if (context.contraption.stalled)
speed = 0;
superBuffer.transform(matrices.getModel());
transform(context.world, facing, superBuffer, speed);
superBuffer.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), buffers.getBuffer(RenderType.cutoutMipped()));
}
use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class BeltTunnelRenderer method renderSafe.
@Override
protected void renderSafe(BeltTunnelTileEntity 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;
SuperByteBuffer flapBuffer = CachedBufferer.partial(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState());
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
Vec3 pivot = VecHelper.voxelSpace(0, 10, 1f);
TransformStack msr = TransformStack.cast(ms);
for (Direction direction : Iterate.directions) {
if (!te.flaps.containsKey(direction))
continue;
float horizontalAngle = AngleHelper.horizontalAngle(direction.getOpposite());
float f = te.flaps.get(direction).get(partialTicks);
ms.pushPose();
msr.centre().rotateY(horizontalAngle).unCentre();
for (int segment = 0; segment <= 3; segment++) {
ms.pushPose();
float intensity = segment == 3 ? 1.5f : segment + 1;
float abs = Math.abs(f);
float flapAngle = Mth.sin((float) ((1 - abs) * Math.PI * intensity)) * 30 * f * (direction.getAxis() == Axis.X ? 1 : -1);
if (f > 0)
flapAngle *= .5f;
msr.translate(pivot).rotateX(flapAngle).translateBack(pivot);
flapBuffer.light(light).renderInto(ms, vb);
ms.popPose();
ms.translate(-3 / 16f, 0, 0);
}
ms.popPose();
}
}
Aggregations