|
11 | 11 | import net.minecraft.client.renderer.block.model.BakedQuad; |
12 | 12 | import net.minecraft.client.resources.model.BakedModel; |
13 | 13 | import net.minecraft.core.Direction; |
| 14 | +import net.minecraft.util.Mth; |
14 | 15 | import net.minecraft.util.RandomSource; |
15 | 16 | import net.minecraft.world.level.block.state.BlockState; |
16 | 17 | import net.minecraft.world.phys.Vec3; |
@@ -89,10 +90,28 @@ private void addLine(double x1, double y1, double z1, double x2, double y2, doub |
89 | 90 | nY = nY / nLen; |
90 | 91 | nZ = nZ / nLen; |
91 | 92 |
|
92 | | - lines.add(new Line((float) x1, (float) y1, (float) z1, (float) x2, (float) y2, (float) z2, (float) nX, (float) nY, (float) nZ)); |
| 93 | + Line line = new Line((float) x1, (float) y1, (float) z1, (float) x2, (float) y2, (float) z2, (float) nX, (float) nY, (float) nZ); |
| 94 | + if (!lines.contains(line)) { |
| 95 | + lines.add(line); |
| 96 | + } |
93 | 97 | } |
94 | 98 |
|
95 | 99 | } |
96 | 100 |
|
97 | | - public record Line(float x1, float y1, float z1, float x2, float y2, float z2, float nX, float nY, float nZ) {} |
| 101 | + public record Line(float x1, float y1, float z1, float x2, float y2, float z2, float nX, float nY, float nZ) { |
| 102 | + |
| 103 | + @SuppressWarnings("SuspiciousNameCombination") |
| 104 | + @Override |
| 105 | + public boolean equals(Object obj) { |
| 106 | + if (obj == this) { |
| 107 | + return true; |
| 108 | + } |
| 109 | + if (obj == null || obj.getClass() != Line.class) { |
| 110 | + return false; |
| 111 | + } |
| 112 | + Line other = (Line) obj; |
| 113 | + return (Mth.equal(x1, other.x1) && Mth.equal(y1, other.y1) && Mth.equal(z1, other.z1) && Mth.equal(x2, other.x2) && Mth.equal(y2, other.y2) && Mth.equal(z2, other.z2)) || |
| 114 | + (Mth.equal(x1, other.x2) && Mth.equal(y1, other.y2) && Mth.equal(z1, other.z2) && Mth.equal(x2, other.x1) && Mth.equal(y2, other.y1) && Mth.equal(z2, other.z1)); |
| 115 | + } |
| 116 | + } |
98 | 117 | } |
0 commit comments