Fix crash when remapping registries with unused raw ids.

This commit is contained in:
modmuss50 2022-02-11 18:14:32 +00:00
parent cd333a0bb8
commit 682a9b7c63
3 changed files with 14 additions and 7 deletions
fabric-registry-sync-v0/src
main/java/net/fabricmc/fabric/mixin/registry/sync
testmod/java/net/fabricmc/fabric/test/registry/sync
gradle.properties

View file

@ -310,13 +310,17 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab
Int2IntMap idMap = new Int2IntOpenHashMap();
for (RegistryEntry.Reference<T> o : rawIdToEntry) {
Identifier id = getId(o.value());
int rid = getRawId(o.value());
for (int i = 0; i < rawIdToEntry.size(); i++) {
RegistryEntry.Reference<T> reference = rawIdToEntry.get(i);
// Unused id, skip
if (reference == null) continue;
Identifier id = reference.registryKey().getValue();
// see above note
if (remoteIndexedEntries.containsKey(id)) {
idMap.put(rid, remoteIndexedEntries.getInt(id));
idMap.put(i, remoteIndexedEntries.getInt(id));
}
}

View file

@ -114,6 +114,9 @@ public class RegistrySyncTest implements ModInitializer {
System.out.println(id);
});
});
// Vanilla status effects don't have an entry for the int id 0, test we can handle this.
RegistryAttributeHolder.get(Registry.STATUS_EFFECT).addAttribute(RegistryAttribute.MODDED);
}
private static void registerBlocks(String namespace, int amount, int startingId) {

View file

@ -1,6 +1,6 @@
org.gradle.jvmargs=-Xmx2560M
version=0.47.0
version=0.47.1
minecraft_version=22w06a
yarn_version=+build.8
loader_version=0.13.2
@ -17,7 +17,7 @@ fabric-commands-v0-version=0.2.7
fabric-containers-v0-version=0.1.20
fabric-content-registries-v0-version=2.0.0
fabric-crash-report-info-v1-version=0.1.10
fabric-data-generation-api-v1-version=2.0.0
fabric-data-generation-api-v1-version=2.0.1
fabric-dimensions-v1-version=2.1.12
fabric-entity-events-v1-version=1.4.7
fabric-events-interaction-v0-version=0.4.18
@ -36,7 +36,7 @@ fabric-networking-api-v1-version=1.0.20
fabric-networking-v0-version=0.3.7
fabric-object-builder-api-v1-version=2.0.0
fabric-particles-v1-version=0.2.11
fabric-registry-sync-v0-version=0.9.3
fabric-registry-sync-v0-version=0.9.4
fabric-renderer-api-v1-version=0.4.12
fabric-renderer-indigo-version=0.4.16
fabric-renderer-registries-v1-version=3.2.10