use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.
the class HandCrankRenderer 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 state = te.getBlockState();
Block block = state.getBlock();
PartialModel renderedHandle = null;
if (block instanceof HandCrankBlock)
renderedHandle = ((HandCrankBlock) block).getRenderedHandle();
if (renderedHandle == null)
return;
Direction facing = state.getValue(FACING);
SuperByteBuffer handle = CachedBufferer.partialFacing(renderedHandle, state, facing.getOpposite());
HandCrankTileEntity crank = (HandCrankTileEntity) te;
kineticRotationTransform(handle, te, facing.getAxis(), (crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, light);
handle.renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.
the class SawRenderer method renderBlade.
protected void renderBlade(SawTileEntity te, PoseStack ms, MultiBufferSource buffer, int light) {
BlockState blockState = te.getBlockState();
PartialModel partial;
float speed = te.getSpeed();
boolean rotate = false;
if (SawBlock.isHorizontal(blockState)) {
if (speed > 0) {
partial = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE;
} else if (speed < 0) {
partial = AllBlockPartials.SAW_BLADE_HORIZONTAL_REVERSED;
} else {
partial = AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE;
}
} else {
if (te.getSpeed() > 0) {
partial = AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE;
} else if (speed < 0) {
partial = AllBlockPartials.SAW_BLADE_VERTICAL_REVERSED;
} else {
partial = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE;
}
if (blockState.getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE))
rotate = true;
}
SuperByteBuffer superBuffer = CachedBufferer.partialFacing(partial, blockState);
if (rotate) {
superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(90));
}
superBuffer.color(0xFFFFFF).light(light).renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped()));
}
use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.
the class EngineRenderer method renderSafe.
@Override
protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
if (Backend.canUseInstancing(te.getLevel()))
return;
Block block = te.getBlockState().getBlock();
if (block instanceof EngineBlock) {
EngineBlock engineBlock = (EngineBlock) block;
PartialModel frame = engineBlock.getFrameModel();
if (frame != null) {
Direction facing = te.getBlockState().getValue(EngineBlock.FACING);
float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing));
CachedBufferer.partial(frame, te.getBlockState()).rotateCentered(Direction.UP, angle).translate(0, 0, -1).light(light).renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
}
}
use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.
the class BlazeBurnerRenderer method renderSafe.
@Override
protected void renderSafe(BlazeBurnerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
HeatLevel heatLevel = te.getHeatLevelFromBlock();
if (heatLevel == HeatLevel.NONE)
return;
float renderTick = AnimationTickHolder.getRenderTime(te.getLevel()) + (te.hashCode() % 13) * 16f;
float offset = (Mth.sin((float) ((renderTick / 16f) % (2 * Math.PI))) + .5f) / 16f;
PartialModel blazeModel = AllBlockPartials.BLAZES.get(heatLevel);
SuperByteBuffer blazeBuffer = CachedBufferer.partial(blazeModel, te.getBlockState());
blazeBuffer.rotateCentered(Direction.UP, AngleHelper.rad(te.headAngle.getValue(partialTicks)));
blazeBuffer.translate(0, offset, 0);
blazeBuffer.light(LightTexture.FULL_BRIGHT).renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
use of com.jozufozu.flywheel.core.PartialModel 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);
}
}
Aggregations