Skip to content

Commit 8ba8ae4

Browse files
committed
Fix: stronghold seed field detection could match levelSeed instead of concentricRingsSeed
1 parent 14ee7f7 commit 8ba8ae4

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/main/java/com/seedshield/SeedShieldPlugin.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ private void recalculateStrongholdPositions(Object structureState, List<?> holde
165165
return;
166166
}
167167
seedField.setAccessible(true);
168+
long oldSeed = seedField.getLong(structureState);
168169
long secureSeed = deriveLongSeed(worldSeed, "stronghold_rings");
169170
seedField.setLong(structureState, secureSeed);
171+
getLogger().info(" Modified " + seedField.getName() + ": " + oldSeed + " → " + secureSeed);
170172

171173
// Find generateRingPositions(Holder, ConcentricRingsStructurePlacement) method
172174
Method generateRings = findGenerateRingPositionsMethod(structureState);
@@ -294,10 +296,22 @@ private Field findRingPositionsCacheField(Object structureState) throws Exceptio
294296

295297
/** Find the concentricRingsSeed long field */
296298
private Field findConcentricRingsSeedField(Object structureState, long worldSeed) throws Exception {
299+
// First pass: find by name containing "ring" (most reliable)
297300
for (Field f : getAllFields(structureState.getClass())) {
298301
if (f.getType() == long.class) {
299302
f.setAccessible(true);
300-
if (f.getName().toLowerCase().contains("ring") || f.getLong(structureState) == worldSeed) {
303+
if (f.getName().toLowerCase().contains("ring")) {
304+
getLogger().info(" Found concentricRingsSeed field: " + f.getName() + " = " + f.getLong(structureState));
305+
return f;
306+
}
307+
}
308+
}
309+
// Second pass: find long field matching worldSeed but NOT named "levelSeed"
310+
for (Field f : getAllFields(structureState.getClass())) {
311+
if (f.getType() == long.class) {
312+
f.setAccessible(true);
313+
if (f.getLong(structureState) == worldSeed && !f.getName().toLowerCase().contains("level")) {
314+
getLogger().info(" Found concentricRingsSeed field (by value): " + f.getName() + " = " + f.getLong(structureState));
301315
return f;
302316
}
303317
}

0 commit comments

Comments
 (0)