use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class GearboxRenderer method renderSafe.
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
if (Backend.canUseInstancing(te.getLevel()))
return;
final Axis boxAxis = te.getBlockState().getValue(BlockStateProperties.AXIS);
final BlockPos pos = te.getBlockPos();
float time = AnimationTickHolder.getRenderTime(te.getLevel());
for (Direction direction : Iterate.directions) {
final Axis axis = direction.getAxis();
if (boxAxis == axis)
continue;
SuperByteBuffer shaft = CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction);
float offset = getRotationOffsetForPosition(te, pos, axis);
float angle = (time * te.getSpeed() * 3f / 10) % 360;
if (te.getSpeed() != 0 && te.hasSource()) {
BlockPos source = te.source.subtract(te.getBlockPos());
Direction sourceFacing = Direction.getNearest(source.getX(), source.getY(), source.getZ());
if (sourceFacing.getAxis() == direction.getAxis())
angle *= sourceFacing == direction ? 1 : -1;
else if (sourceFacing.getAxisDirection() == direction.getAxisDirection())
angle *= -1;
}
angle += offset;
angle = angle / 180f * (float) Math.PI;
kineticRotationTransform(shaft, te, axis, angle, light);
shaft.renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
}
use of com.simibubi.create.foundation.render.SuperByteBuffer 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();
}
use of com.simibubi.create.foundation.render.SuperByteBuffer 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.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class MechanicalMixerRenderer method renderSafe.
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
if (Backend.canUseInstancing(te.getLevel()))
return;
BlockState blockState = te.getBlockState();
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks);
float speed = mixer.getRenderedHeadRotationSpeed(partialTicks);
float time = AnimationTickHolder.getRenderTime(te.getLevel());
float angle = ((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI;
SuperByteBuffer poleRender = CachedBufferer.partial(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState);
poleRender.translate(0, -renderedHeadOffset, 0).light(light).renderInto(ms, vb);
SuperByteBuffer headRender = CachedBufferer.partial(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState);
headRender.rotateCentered(Direction.UP, angle).translate(0, -renderedHeadOffset, 0).light(light).renderInto(ms, vb);
}
use of com.simibubi.create.foundation.render.SuperByteBuffer 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()));
}
Aggregations