Skip to content

Commit

Permalink
No longer allow unused registry ids when syncing.
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed May 23, 2024
1 parent 6573ed8 commit c9b48ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.VisibleForTesting;
import org.slf4j.Logger;
Expand Down Expand Up @@ -277,14 +276,10 @@ public static void apply(Map<Identifier, Object2IntMap<Identifier>> map, Remappa
continue;
}

if (registry instanceof RemappableRegistry) {
Object2IntMap<Identifier> idMap = new Object2IntOpenHashMap<>();

for (Identifier key : registryMap.keySet()) {
idMap.put(key, registryMap.getInt(key));
}

((RemappableRegistry) registry).remap(registryId.toString(), idMap, mode);
if (registry instanceof RemappableRegistry remappableRegistry) {
remappableRegistry.remap(registryId.toString(), registryMap, mode);
} else {
throw new RemapException("Registry " + registryId + " is not remappable");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,10 @@ public void remap(String name, Object2IntMap<Identifier> remoteIndexedEntries, R
for (int i = 0; i < rawIdToEntry.size(); i++) {
RegistryEntry.Reference<T> reference = rawIdToEntry.get(i);

// Unused id, skip
if (reference == null) continue;
// Unused id, can happen if there are holes in the registry.
if (reference == null) {
throw new RemapException("Unused id " + i + " in registry " + getKey().getValue());
}

Identifier id = reference.registryKey().getValue();

Expand Down

0 comments on commit c9b48ce

Please sign in to comment.