• 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

0.0
/src/main/java/org/cyclops/integrateddynamics/api/part/PartTarget.java
1
package org.cyclops.integrateddynamics.api.part;
2

3
import net.minecraft.core.BlockPos;
4
import net.minecraft.core.Direction;
5
import net.minecraft.core.Vec3i;
6
import net.minecraft.world.level.Level;
7
import org.cyclops.cyclopscore.datastructure.DimPos;
8

9
import javax.annotation.Nullable;
10

11
/**
12
 * Object holder to refer to another block side and its origin.
13
 * @author rubensworks
14
 */
15
public class PartTarget {
16

17
    private final PartPos center;
18
    private final PartPos target;
19

20
    /**
21
     * Get the target from a center block that is targeted at another block.
22
     * @param pos The central position that is referring to the target.
23
     * @param side The side on the central position that points to the target.
24
     * @return The target referral.
25
     */
26
    public static PartTarget fromCenter(DimPos pos, @Nullable Direction side) {
27
        return PartTarget.of(
×
28
                PartPos.of(pos, side),
×
29
                PartPos.of(DimPos.of(pos.getLevelKey(), side == null ? pos.getBlockPos() : pos.getBlockPos().relative(side)), side == null ? null : side.getOpposite())
×
30
        );
31
    }
32

33
    /**
34
     * Get the target from a center block that is targeted at another block.
35
     * @param pos The central position that is referring to the target.
36
     * @return The target referral.
37
     */
38
    public static PartTarget fromCenter(PartPos pos) {
39
        return fromCenter(pos.getPos(), pos.getSide());
×
40
    }
41

42
    /**
43
     * Get the target from a center block that is targeted at another block.
44
     * @param world The world.
45
     * @param pos The central position that is referring to the target.
46
     * @param side The side on the central position that points to the target.
47
     * @return The target referral.
48
     */
49
    public static PartTarget fromCenter(Level world, BlockPos pos, Direction side) {
50
        return PartTarget.fromCenter(DimPos.of(world, pos), side);
×
51
    }
52

53
    /**
54
     * Create a new instance.
55
     * @param center The center position.
56
     * @param target The target position.
57
     * @return The target.
58
     */
59
    public static PartTarget of(PartPos center, PartPos target) {
60
        return new PartTarget(center, target);
×
61
    }
62

63
    public PartPos getCenter() {
64
        return center;
×
65
    }
66

67
    public PartPos getTarget() {
68
        return target;
×
69
    }
70

71
    public boolean isDefaultTarget() {
72
        return getCenter().getPos().getBlockPos().relative(getCenter().getSide()).equals(getTarget().getPos().getBlockPos());
×
73
    }
74

75
    private PartTarget(PartPos center, PartPos target) {
×
76
        this.center = center;
×
77
        this.target = target;
×
78
    }
×
79

80
    /**
81
     * Create a new instance with the given target side.
82
     * @param targetSide The side of the target.
83
     * @return A new {@link PartTarget} instance.
84
     */
85
    public PartTarget forTargetSide(Direction targetSide) {
86
        return new PartTarget(center, PartPos.of(target.getPos(), targetSide));
×
87
    }
88

89
    /**
90
     * Create a new instance with the given target offset.
91
     * @param offset The offset of the target.
92
     * @return A new {@link PartTarget} instance.
93
     */
94
    public PartTarget forOffset(Vec3i offset) {
95
        return new PartTarget(center, PartPos.of(target.getPos().withPosition(target.getPos().getBlockPos().offset(offset)), target.getSide()));
×
96
    }
97

98
    @Override
99
    public boolean equals(Object o) {
100
        if (this == o) return true;
×
101
        if (!(o instanceof PartTarget)) return false;
×
102

103
        PartTarget that = (PartTarget) o;
×
104

105
        if (!center.equals(that.center)) return false;
×
106
        return target.equals(that.target);
×
107

108
    }
109

110
    @Override
111
    public int hashCode() {
112
        int result = center.hashCode();
×
113
        result = 31 * result + target.hashCode();
×
114
        return result;
×
115
    }
116

117
    @Override
118
    public String toString() {
119
        return "PartTarget{" +
×
120
                "center=" + center +
121
                ", target=" + target +
122
                '}';
123
    }
124
}
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