From b7a8575b20876bd5c313360030bc216bb391705a Mon Sep 17 00:00:00 2001 From: Cat Core Date: Thu, 6 Jun 2024 22:48:44 +0200 Subject: [PATCH] Fix entry count in IdsHolder --- .../mixin/registry/sync/versioned/OtherIdListMixin.java | 6 +++--- .../legacyfabric/fabric/impl/registry/IdsHolderImpl.java | 2 +- .../legacyfabric/fabric/impl/registry/RegistryRemapper.java | 2 +- .../fabric/mixin/registry/sync/IdListMixinV2.java | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/legacy-fabric-registry-sync-api-v2/1.12.2/src/main/java/net/legacyfabric/fabric/mixin/registry/sync/versioned/OtherIdListMixin.java b/legacy-fabric-registry-sync-api-v2/1.12.2/src/main/java/net/legacyfabric/fabric/mixin/registry/sync/versioned/OtherIdListMixin.java index f6faa63d7..08d5ed10d 100644 --- a/legacy-fabric-registry-sync-api-v2/1.12.2/src/main/java/net/legacyfabric/fabric/mixin/registry/sync/versioned/OtherIdListMixin.java +++ b/legacy-fabric-registry-sync-api-v2/1.12.2/src/main/java/net/legacyfabric/fabric/mixin/registry/sync/versioned/OtherIdListMixin.java @@ -35,10 +35,10 @@ public abstract class OtherIdListMixin implements IdsHolder { public abstract void add(T value, int id); @Shadow - private T[] field_14375; + public abstract int getId(T value); @Shadow - public abstract int getId(T value); + public abstract int size(); @Override public IdsHolder fabric$new() { @@ -61,7 +61,7 @@ public abstract class OtherIdListMixin implements IdsHolder { @Override public int fabric$size() { - return this.field_14375.length; + return this.size(); } @Override diff --git a/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/impl/registry/IdsHolderImpl.java b/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/impl/registry/IdsHolderImpl.java index c83167389..da31e5450 100644 --- a/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/impl/registry/IdsHolderImpl.java +++ b/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/impl/registry/IdsHolderImpl.java @@ -69,7 +69,7 @@ public IdsHolderImpl() { @Override public int fabric$size() { - return values.size(); + return this.valueToId.size(); } @Override diff --git a/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/impl/registry/RegistryRemapper.java b/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/impl/registry/RegistryRemapper.java index 166c5624b..382757f25 100644 --- a/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/impl/registry/RegistryRemapper.java +++ b/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/impl/registry/RegistryRemapper.java @@ -132,7 +132,7 @@ private IntSupplier normalizeEntryList(IdsHolder ids) { addNewEntries(ids); if (currentSize.getAsInt() != previousSize.getAsInt() && this.missingMap.isEmpty()) { - throw new IllegalStateException("An error occured during remapping"); + throw new IllegalStateException("An error occurred during remapping"); } return previousSize; diff --git a/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/mixin/registry/sync/IdListMixinV2.java b/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/mixin/registry/sync/IdListMixinV2.java index a7c3ac826..8a7d3f42a 100644 --- a/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/mixin/registry/sync/IdListMixinV2.java +++ b/legacy-fabric-registry-sync-api-v2/common/src/main/java/net/legacyfabric/fabric/mixin/registry/sync/IdListMixinV2.java @@ -17,6 +17,7 @@ package net.legacyfabric.fabric.mixin.registry.sync; +import java.util.IdentityHashMap; import java.util.List; import org.spongepowered.asm.mixin.Final; @@ -40,7 +41,7 @@ public abstract class IdListMixinV2 implements IdsHolder { @Shadow @Final - private List list; + private IdentityHashMap idMap; @Override public IdsHolder fabric$new() { @@ -63,7 +64,7 @@ public abstract class IdListMixinV2 implements IdsHolder { @Override public int fabric$size() { - return list.size(); + return idMap.size(); } @Override