• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / IntegratedDynamics / 16552051255

27 Jul 2025 01:58PM UTC coverage: 53.206% (+8.0%) from 45.161%
16552051255

push

github

rubensworks
Resolve minor TODOs

2888 of 8740 branches covered (33.04%)

Branch coverage included in aggregate %.

17341 of 29280 relevant lines covered (59.22%)

3.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/cyclops/integrateddynamics/client/render/part/DisplayPartOverlayRenderer.java
1
package org.cyclops.integrateddynamics.client.render.part;
2

3
import com.mojang.blaze3d.vertex.PoseStack;
4
import com.mojang.math.Axis;
5
import net.minecraft.client.Minecraft;
6
import net.minecraft.client.renderer.MultiBufferSource;
7
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
8
import net.minecraft.core.BlockPos;
9
import net.minecraft.core.Direction;
10
import net.minecraft.world.entity.Entity;
11
import org.cyclops.cyclopscore.client.gui.image.Images;
12
import org.cyclops.integrateddynamics.api.client.render.valuetype.IValueTypeWorldRenderer;
13
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
14
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
15
import org.cyclops.integrateddynamics.api.part.IPartContainer;
16
import org.cyclops.integrateddynamics.api.part.IPartState;
17
import org.cyclops.integrateddynamics.api.part.IPartType;
18
import org.cyclops.integrateddynamics.client.render.valuetype.ValueTypeWorldRenderers;
19
import org.cyclops.integrateddynamics.part.PartTypePanelDisplay;
20

21
/**
22
 * Overlay renderer for the display part to display values on the part.
23
 * @author rubensworks
24
 */
25
public class DisplayPartOverlayRenderer extends PartOverlayRendererBase {
×
26

27
    public static final float MAX = 12.5F;
28
    protected static final float pixel = 0.0625F;  // 0.0625 == 1/16
29

30
    @Override
31
    protected void setMatrixOrientation(PoseStack matrixStack, Direction direction) {
32
        super.setMatrixOrientation(matrixStack, direction);
×
33
        float translateX = -1F - direction.getStepX() + 4 * pixel;
×
34
        float translateY = 1F - direction.getStepY() - 4 * pixel;
×
35
        float translateZ = direction.getStepZ() - pixel + 0.0025F;
×
36
        if (direction == Direction.NORTH) {
×
37
            translateZ += 1F;
×
38
        } else if (direction == Direction.EAST) {
×
39
            translateX += 1F;
×
40
            translateZ += 1F;
×
41
        } else if (direction == Direction.SOUTH) {
×
42
            translateX += 1F;
×
43
        } else if (direction == Direction.UP) {
×
44
            translateX += 1F;
×
45
            translateZ += 1F;
×
46
        } else if (direction == Direction.DOWN) {
×
47
            translateX += 1F;
×
48
            translateY -= 1F;
×
49
        }
50
        matrixStack.translate(translateX, translateY, translateZ);
×
51
    }
×
52

53
    @Override
54
    public void renderPartOverlay(BlockEntityRendererProvider.Context context, IPartContainer partContainer,
55
                                  Direction direction, IPartType partType, float partialTicks, PoseStack matrixStack,
56
                                  MultiBufferSource renderTypeBuffer, int combinedLight, int combinedOverlay) {
57
        BlockPos pos = partContainer.getPosition().getBlockPos();
×
58
        if(!shouldRender(pos)) return;
×
59

60
        // Calculate the alpha to be used when the player is almost out of rendering bounds.
61
        Entity renderEntity = Minecraft.getInstance().player;
×
62
        float distanceFactor = (float) ((getMaxRenderDistance() - renderEntity.distanceToSqr(pos.getX(), pos.getY(), pos.getZ())) / 5);
×
63
        float distanceAlpha = Math.min(1.0F, distanceFactor);
×
64
        if(distanceAlpha < 0.05F) distanceAlpha = 0.05F; // Can't be 0 because the MC font renderer doesn't handle 0 alpha's properly.
×
65

66
        matrixStack.pushPose();
×
67

68
        float scale = 0.04F;
×
69
        setMatrixOrientation(matrixStack, direction);
×
70
        matrixStack.scale(scale, scale, scale);
×
71
        matrixStack.scale(1, -1, 1);
×
72

73
        IPartState partStateUnsafe = partContainer.getPartState(direction);
×
74
        if(!(partStateUnsafe instanceof PartTypePanelDisplay.State)) {
×
75
            drawError(context, matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, distanceAlpha);
×
76
        } else {
77
            PartTypePanelDisplay.State partState = (PartTypePanelDisplay.State) partStateUnsafe;
×
78
            if (partState.getFacingRotation() == null) {
×
79
                drawError(context, matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, distanceAlpha);
×
80
                return;
×
81
            }
82
            int rotation = partState.getFacingRotation().ordinal() - 2;
×
83
            matrixStack.translate(6, 6, 0);
×
84
            matrixStack.mulPose(Axis.ZP.rotationDegrees(rotation * 90));
×
85
            matrixStack.translate(-6, -6, 0);
×
86

87
            IValue value = partState.getDisplayValue();
×
88
            if (value != null && partState.isEnabled()) {
×
89
                IValueType<?> valueType = value.getType();
×
90
                IValueTypeWorldRenderer renderer = ValueTypeWorldRenderers.REGISTRY.getRenderer(valueType);
×
91
                if (renderer == null) {
×
92
                    renderer = ValueTypeWorldRenderers.DEFAULT;
×
93
                }
94
                renderer.renderValue(context, partContainer, direction, partType, value, partialTicks, matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, distanceAlpha);
×
95
            } else if (!partState.getInventory().isEmpty()) {
×
96
                drawError(context, matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, distanceAlpha);
×
97
            }
98
        }
99

100
        matrixStack.popPose();
×
101
    }
×
102

103
    protected void drawError(BlockEntityRendererProvider.Context context, PoseStack matrixStack, MultiBufferSource renderTypeBuffer,
104
                             int combinedLight, int combinedOverlay, float distanceAlpha) {
105
        Images.ERROR.drawWorldWithAlpha(Minecraft.getInstance().getTextureManager(), matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, 12.5F, 12.5F, distanceAlpha);
×
106
    }
×
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc