Skip to content

Commit 877fdd7

Browse files
committed
2.0.25 #2
1 parent 7194e84 commit 877fdd7

4 files changed

Lines changed: 77 additions & 36 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Fixed biome loading
44
- Fixed crash related to loading of modded jigsaw structures
5+
- Fixed flatness check not working correctly for very small structures
56

67
## 2.0.24
78

buildSrc/src/main/kotlin/multiloader-common.gradle.kts

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,17 @@ repositories {
9191
}
9292
}
9393

94-
exclusiveContent {
95-
forRepositories(
96-
maven("https://maven.isxander.dev/releases") {
97-
name = "isXander Releases"
98-
},
99-
maven("https://maven.isxander.dev/snapshots") {
100-
name = "isXander Snapshots"
101-
}
102-
)
103-
filter {
94+
maven("https://maven.isxander.dev/releases") {
95+
name = "isXander Releases"
96+
content {
97+
includeGroupAndSubgroups("dev.isxander")
98+
}
99+
}
100+
101+
maven("https://maven.isxander.dev/snapshots") {
102+
name = "isXander Snapshots"
103+
content {
104104
includeGroupAndSubgroups("dev.isxander")
105-
includeGroupAndSubgroups("org.quiltmc.parsers")
106105
}
107106
}
108107

@@ -114,6 +113,7 @@ repositories {
114113
}
115114
filter {
116115
includeGroupAndSubgroups("org.quiltmc")
116+
includeGroupAndSubgroups("org.quiltmc.parsers")
117117
}
118118
}
119119

@@ -182,6 +182,29 @@ repositories {
182182
includeGroupByRegex(".*")
183183
}
184184
}
185+
186+
exclusiveContent {
187+
forRepository {
188+
maven("https://maven.blamejared.com") {
189+
name = "BlameJared"
190+
}
191+
}
192+
filter {
193+
includeGroupAndSubgroups("net.darkhax")
194+
includeGroupAndSubgroups("mezz.jei")
195+
}
196+
}
197+
198+
exclusiveContent {
199+
forRepository {
200+
maven("https://nexus.resourcefulbees.com/repository/telepathicgrunt/") {
201+
name = "TelepathicGrunt"
202+
}
203+
}
204+
filter {
205+
includeGroup("com.telepathicgrunt")
206+
}
207+
}
185208
}
186209

187210
tasks {

common/src/main/java/com/faboslav/structurify/common/world/level/structure/checks/StructurePieceSampler.java

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public final class StructurePieceSampler
1616
public static List<StructurePiece> getStructurePieces(StructureStart structureStart) {
1717
List<StructurePiece> structurePieces = structureStart.getPieces();
1818

19-
if (Structurify.getConfig().getDebugData().getSamplingMode() == DebugData.SamplingMode.MINIMAL) {
19+
if (Structurify.getConfig().getDebugData().isEnabled() && Structurify.getConfig().getDebugData().getSamplingMode() == DebugData.SamplingMode.MINIMAL) {
2020
return structurePieces;
2121
}
2222

@@ -32,13 +32,13 @@ public static int[][] getStructurePieceSamples(List<StructurePiece> structurePie
3232

3333
int[][] pieceSamples = getStructurePieceCorners(structurePieces);
3434

35-
if (Structurify.getConfig().getDebugData().getSamplingMode() == DebugData.SamplingMode.MINIMAL) {
35+
if (Structurify.getConfig().getDebugData().isEnabled() && Structurify.getConfig().getDebugData().getSamplingMode() == DebugData.SamplingMode.MINIMAL) {
3636
return pieceSamples;
3737
}
3838

3939
pieceSamples = mergeTouchingPositions(pieceSamples);
4040

41-
if (Structurify.getConfig().getDebugData().getSamplingMode() == DebugData.SamplingMode.MERGED_SAMPLES) {
41+
if (Structurify.getConfig().getDebugData().isEnabled() && Structurify.getConfig().getDebugData().getSamplingMode() == DebugData.SamplingMode.MERGED_SAMPLES) {
4242
return pieceSamples;
4343
}
4444

@@ -105,18 +105,22 @@ private static int[][] getStructurePieceCorners(List<StructurePiece> pieces) {
105105
private static int[][] mergeTouchingPositions(int[][] inputPositions) {
106106
Set<Long> uniqueKeys = new HashSet<>();
107107
List<int[]> uniquePositions = new ArrayList<>();
108+
108109
for (int[] position : inputPositions) {
109-
long key = ChunkPosUtil.getChunkPosAsLong( ChunkPosUtil.createChunkPos(position[0], position[1]));
110+
long key = (((long) position[0]) << 32) ^ (position[1] & 0xFFFFFFFFL);
111+
110112
if (uniqueKeys.add(key)) {
111-
uniquePositions.add(position);
113+
uniquePositions.add(new int[] { position[0], position[1] });
112114
}
113115
}
114116

115117
List<int[]> mergedPositions = new ArrayList<>();
116118
boolean[] visited = new boolean[uniquePositions.size()];
117119

118120
for (int i = 0; i < uniquePositions.size(); i++) {
119-
if (visited[i]) continue;
121+
if (visited[i]) {
122+
continue;
123+
}
120124

121125
List<int[]> group = new ArrayList<>();
122126
Queue<Integer> queue = new ArrayDeque<>();
@@ -129,39 +133,52 @@ private static int[][] mergeTouchingPositions(int[][] inputPositions) {
129133
group.add(current);
130134

131135
for (int j = 0; j < uniquePositions.size(); j++) {
132-
if (visited[j]) continue;
136+
if (visited[j]) {
137+
continue;
138+
}
139+
133140
int[] candidate = uniquePositions.get(j);
134141

135-
if (Math.abs(candidate[0] - current[0]) <= 1 &&
136-
Math.abs(candidate[1] - current[1]) <= 1) {
142+
if (Math.abs(candidate[0] - current[0]) <= 1 && Math.abs(candidate[1] - current[1]) <= 1) {
137143
visited[j] = true;
138144
queue.add(j);
139145
}
140146
}
141147
}
142148

143-
int[] best = group.get(0);
144-
double bestDistance = Double.MAX_VALUE;
149+
int minX = Integer.MAX_VALUE;
150+
int minZ = Integer.MAX_VALUE;
151+
int maxX = Integer.MIN_VALUE;
152+
int maxZ = Integer.MIN_VALUE;
153+
154+
for (int[] position : group) {
155+
minX = Math.min(minX, position[0]);
156+
minZ = Math.min(minZ, position[1]);
157+
maxX = Math.max(maxX, position[0]);
158+
maxZ = Math.max(maxZ, position[1]);
159+
}
145160

146-
double avgX = group.stream().mapToInt(p -> p[0]).average().orElse(0);
147-
double avgZ = group.stream().mapToInt(p -> p[1]).average().orElse(0);
161+
int centerX = Math.floorDiv(minX + maxX, 2);
162+
int centerZ = Math.floorDiv(minZ + maxZ, 2);
163+
164+
int[] best = group.get(0);
165+
long bestDistance = Long.MAX_VALUE;
148166

149-
for (int[] pos : group) {
150-
double dx = pos[0] - avgX;
151-
double dz = pos[1] - avgZ;
152-
double dist = dx * dx + dz * dz;
167+
for (int[] position : group) {
168+
long dx = position[0] - centerX;
169+
long dz = position[1] - centerZ;
170+
long distance = dx * dx + dz * dz;
153171

154-
if (dist < bestDistance ||
155-
(dist == bestDistance && (pos[0] < best[0] || (pos[0] == best[0] && pos[1] < best[1])))) {
156-
best = pos;
157-
bestDistance = dist;
172+
if (distance < bestDistance || distance == bestDistance && (position[0] < best[0] || position[0] == best[0] && position[1] < best[1])) {
173+
best = position;
174+
bestDistance = distance;
158175
}
159176
}
160177

161-
mergedPositions.add(best);
178+
mergedPositions.add(new int[] { best[0], best[1] });
162179
}
163180

164-
return mergedPositions.toArray(new int[mergedPositions.size()][]);
181+
return mergedPositions.toArray(new int[0][]);
165182
}
166183

167184
private static int[][] orderStructureCornersByDistance(int[][] samples, BlockPos structureCenter) {

common/src/main/java/com/faboslav/structurify/common/world/level/structure/checks/debug/StructureFlatnessCheckOverview.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public record StructureFlatnessCheckOverview(
1414
int minHeight,
1515
int maxHeight,
1616
int flatnessCheckThreshold,
17-
int nonSolidChecks,
17+
int totalFlatnessChecks,
1818
int failedNonSolidChecks,
1919
int nonSolidFlatnessChecksThreshold,
2020
boolean result
@@ -25,7 +25,7 @@ public String toString() {
2525
return structureId + "\n" +
2626
"Pieces: " + structurePieces.size() + " (area: " + structureArea + ")\n" +
2727
"Height threshold: " + flatnessCheckThreshold + " (min Y: " + minHeight + ", max Y: " + maxHeight + ", diff: " + (maxHeight - minHeight) +")\n" +
28-
"Non solid checks: " + nonSolidChecks + "\n" +
28+
"Total checks: " + totalFlatnessChecks + "\n" +
2929
"Failed checks: " + failedNonSolidChecks + "/" + nonSolidFlatnessChecksThreshold + "\n" +
3030
"Result: " + (result ? "success":"fail");
3131
}

0 commit comments

Comments
 (0)