Skip to content

Commit

Permalink
Fix entry count in IdsHolder
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Jun 6, 2024
1 parent b1ff8b8 commit b7a8575
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public abstract class OtherIdListMixin<T> implements IdsHolder<T> {
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<T> fabric$new() {
Expand All @@ -61,7 +61,7 @@ public abstract class OtherIdListMixin<T> implements IdsHolder<T> {

@Override
public int fabric$size() {
return this.field_14375.length;
return this.size();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public IdsHolderImpl() {

@Override
public int fabric$size() {
return values.size();
return this.valueToId.size();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private IntSupplier normalizeEntryList(IdsHolder<T> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -40,7 +41,7 @@ public abstract class IdListMixinV2<T> implements IdsHolder<T> {

@Shadow
@Final
private List<T> list;
private IdentityHashMap<T, Integer> idMap;

@Override
public IdsHolder<T> fabric$new() {
Expand All @@ -63,7 +64,7 @@ public abstract class IdListMixinV2<T> implements IdsHolder<T> {

@Override
public int fabric$size() {
return list.size();
return idMap.size();
}

@Override
Expand Down

0 comments on commit b7a8575

Please sign in to comment.