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

CyclopsMC / IntegratedDynamics / 20210191346

14 Dec 2025 03:32PM UTC coverage: 19.514% (-33.5%) from 53.061%
20210191346

push

github

rubensworks
Remove deprecations

663 of 8728 branches covered (7.6%)

Branch coverage included in aggregate %.

6786 of 29445 relevant lines covered (23.05%)

1.09 hits per line

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

75.47
/src/main/java/org/cyclops/integrateddynamics/api/part/PartRenderPosition.java
1
package org.cyclops.integrateddynamics.api.part;
2

3
import net.minecraft.core.Direction;
4
import net.minecraft.world.phys.AABB;
5
import net.minecraft.world.phys.shapes.CollisionContext;
6
import net.minecraft.world.phys.shapes.Shapes;
7
import net.minecraft.world.phys.shapes.VoxelShape;
8
import org.cyclops.cyclopscore.datastructure.EnumFacingMap;
9
import org.cyclops.cyclopscore.helper.MatrixHelpers;
10
import org.cyclops.integrateddynamics.block.shapes.CollisionContextBlockSupport;
11
import org.cyclops.integrateddynamics.client.model.CableModel;
12

13
import java.util.Arrays;
14

15
/**
16
 * Render position definition of a part.
17
 * @author rubensworks
18
 */
19
public class PartRenderPosition {
20

21
    public static final PartRenderPosition NONE = new PartRenderPosition(-1, -1, -1, -1);
9✔
22

23
    private final float depthFactor;
24
    private final float widthFactor;
25
    private final float heightFactor;
26
    private final float widthFactorSide;
27
    private final float heightFactorSide;
28
    private final EnumFacingMap<VoxelShape> sidedCableCollisionBoxes;
29
    private final EnumFacingMap<VoxelShape> collisionBoxes;
30
    private final EnumFacingMap<VoxelShape> collisionBoxesBlockSupport;
31

32
    public PartRenderPosition(float selectionDepthFactor, float depthFactor, float widthFactor, float heightFactor) {
33
        this(selectionDepthFactor, depthFactor, widthFactor, heightFactor, widthFactor, heightFactor);
8✔
34
    }
1✔
35

36
    public PartRenderPosition(float selectionDepthFactor, float depthFactor, float widthFactor, float heightFactor,
37
                              float widthFactorSide, float heightFactorSide) {
2✔
38
        this.depthFactor = depthFactor;
3✔
39
        this.widthFactor = widthFactor;
3✔
40
        this.heightFactor = heightFactor;
3✔
41
        this.widthFactorSide = widthFactorSide;
3✔
42
        this.heightFactorSide = heightFactorSide;
3✔
43
        float[][] sidedCableCollisionBoxesRaw = new float[][]{
183✔
44
                {CableModel.MIN, selectionDepthFactor, CableModel.MIN, CableModel.MAX, CableModel.MIN, CableModel.MAX}, // DOWN
45
                {CableModel.MIN, CableModel.MAX, CableModel.MIN, CableModel.MAX, 1 - selectionDepthFactor, CableModel.MAX}, // UP
46
                {CableModel.MIN, CableModel.MIN, selectionDepthFactor, CableModel.MAX, CableModel.MAX, CableModel.MIN}, // NORTH
47
                {CableModel.MIN, CableModel.MAX, CableModel.MAX, CableModel.MAX, CableModel.MIN, 1 - selectionDepthFactor}, // SOUTH
48
                {selectionDepthFactor, CableModel.MIN, CableModel.MIN, CableModel.MIN, CableModel.MAX, CableModel.MAX}, // WEST
49
                {CableModel.MAX, CableModel.MIN, CableModel.MIN, 1 - selectionDepthFactor, CableModel.MAX, CableModel.MAX}, // EAST
50
        };
51

52
        sidedCableCollisionBoxes = EnumFacingMap.newMap();
3✔
53
        for (Direction side : Direction.values()) {
16✔
54
            float[] b = sidedCableCollisionBoxesRaw[side.ordinal()];
5✔
55
            sidedCableCollisionBoxes.put(side, Shapes.create(new AABB(b[0], b[1], b[2], b[3], b[4], b[5])));
33✔
56
        }
57

58
        float min = (1 - widthFactor) / 2 + 0.0025F;
8✔
59
        float max = (1 - widthFactor) / 2 + widthFactor - 0.0025F;
10✔
60
        float[][] collisionBoxesRaw = new float[][]{
42✔
61
                {min, max}, {0.005F, selectionDepthFactor}, {min, max}
62
        };
63
        float[][] collisionBoxesBlockSupportRaw = new float[][]{
42✔
64
                {0, 1}, {0, selectionDepthFactor}, {0, 1}
65
        };
66
        collisionBoxes = EnumFacingMap.newMap();
3✔
67
        collisionBoxesBlockSupport = EnumFacingMap.newMap();
3✔
68
        for (Direction side : Direction.values()) {
16✔
69
            // Copy bounds
70
            float[][] bounds = new float[collisionBoxesRaw.length][collisionBoxesRaw[0].length];
8✔
71
            for (int i = 0; i < bounds.length; i++)
8✔
72
                bounds[i] = Arrays.copyOf(collisionBoxesRaw[i], collisionBoxesRaw[i].length);
11✔
73

74
            // Transform bounds
75
            MatrixHelpers.transform(bounds, side);
3✔
76
            collisionBoxes.put(side, Shapes.create(new AABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1])));
45✔
77

78
            // Copy bounds block support
79
            float[][] boundsBS = new float[collisionBoxesBlockSupportRaw.length][collisionBoxesBlockSupportRaw[0].length];
8✔
80
            for (int i = 0; i < boundsBS.length; i++)
8✔
81
                boundsBS[i] = Arrays.copyOf(collisionBoxesBlockSupportRaw[i], collisionBoxesBlockSupportRaw[i].length);
11✔
82

83
            // Transform bounds block support
84
            MatrixHelpers.transform(boundsBS, side);
3✔
85
            collisionBoxesBlockSupport.put(side, Shapes.create(new AABB(boundsBS[0][0], boundsBS[1][0], boundsBS[2][0], boundsBS[0][1], boundsBS[1][1], boundsBS[2][1])));
45✔
86
        }
87
    }
1✔
88

89
    public float getDepthFactor() {
90
        return depthFactor;
×
91
    }
92

93
    public float getWidthFactor() {
94
        return widthFactor;
×
95
    }
96

97
    public float getHeightFactor() {
98
        return heightFactor;
×
99
    }
100

101
    public VoxelShape getSidedCableBoundingBox(Direction side) {
102
        return sidedCableCollisionBoxes.get(side);
×
103
    }
104

105
    public VoxelShape getBoundingBox(Direction side, CollisionContext context) {
106
        if (context instanceof CollisionContextBlockSupport) {
×
107
            return collisionBoxesBlockSupport.get(side);
×
108
        }
109
        return collisionBoxes.get(side);
×
110
    }
111

112
    public float getWidthFactorSide() {
113
        return widthFactorSide;
×
114
    }
115

116
    public float getHeightFactorSide() {
117
        return heightFactorSide;
×
118
    }
119

120
    @Override
121
    public String toString() {
122
        return "PartRenderPosition{" +
×
123
                "depthFactor=" + depthFactor +
124
                ", widthFactor=" + widthFactor +
125
                ", heightFactor=" + heightFactor +
126
                ", widthFactorSide=" + widthFactorSide +
127
                ", heightFactorSide=" + heightFactorSide +
128
                '}';
129
    }
130

131
    public String toCompactString() {
132
        return "df=" + depthFactor +
×
133
                ",wf=" + widthFactor +
134
                ",hf=" + heightFactor +
135
                ",wfs=" + widthFactorSide +
136
                ",hfs=" + heightFactorSide;
137
    }
138
}
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