Skip to content

Circuit output nameplates don't render for circuits on Create: Aeronautics assemblies #123

@Da-Technomancer

Description

@Da-Technomancer

The little nameplates that render over circuits when you hold a circuit wrench don't show up for circuits on Create: Aeronautics (and Sable more generally) assemblies.

Nameplate rendering code:

@SuppressWarnings("unused")
public static void renderRedsOutput(RenderLevelStageEvent e){
if(e.getStage() != RenderLevelStageEvent.Stage.AFTER_PARTICLES){
return;
}
LocalPlayer player = Minecraft.getInstance().player;
//If the player is holding a CircuitWrench (or subclass for addons)
if(player != null && (player.getMainHandItem().getItem() instanceof CircuitWrench || player.getOffhandItem().getItem() instanceof CircuitWrench)){
final int RANGE = 64;
Vec3 eyePos = e.getCamera().getPosition();
PoseStack matrix = e.getPoseStack();
matrix.pushPose();
MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource();
matrix.translate(-eyePos.x, -eyePos.y, -eyePos.z);
for(BlockEntity te : BlockUtil.getAllLoadedBlockEntitiesRange(player.level(), player.blockPosition(), RANGE)){
IRedstoneHandler handler;
if(te instanceof CircuitTileEntity circuit && ((handler = circuit.getRedstoneHandler(null)) == null || !handler.shouldMuteOutput())){
float output = circuit.getOutput();
float[] relPos = {te.getBlockPos().getX() + 0.5F, te.getBlockPos().getY() + 0.5F, te.getBlockPos().getZ() + 0.5F};
if(RANGE * RANGE > Minecraft.getInstance().getEntityRenderDispatcher().distanceToSqr(relPos[0], relPos[1], relPos[2])){
renderNameplate(e.getPoseStack(), buffer, relPos, ConfigUtil.formatNumberClient(output));
}
}
}
matrix.popPose();
}
}
private static void renderNameplate(PoseStack matrix, MultiBufferSource.BufferSource buffer, float[] relPos, String nameplate){
matrix.pushPose();
matrix.translate(relPos[0], relPos[1], relPos[2]);
matrix.mulPose(Minecraft.getInstance().getEntityRenderDispatcher().cameraOrientation());
// matrix.mulPose(Axis.YP.rotationDegrees(180));
matrix.scale(0.025F, -0.025F, -0.025F);
Matrix4f matrix4f = matrix.last().pose();
Font fontrenderer = Minecraft.getInstance().font;
float xSt = -fontrenderer.width(nameplate) / 2F;
fontrenderer.drawInBatch(nameplate, xSt, 0, -1, false, matrix4f, buffer, Font.DisplayMode.NORMAL, 0, 0xf000f0);
buffer.endBatch();
matrix.popPose();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions