1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-04 23:53:01 +00:00

Make our registry wrapper implement IdMap

This allows us to use some of the byte-buffer helper methods directly
with our registries, rather than rolling our own helpers.
This commit is contained in:
Jonathan Coates
2023-07-19 20:17:24 +01:00
parent eef05b9854
commit 1b88213eca
5 changed files with 28 additions and 35 deletions

View File

@@ -359,9 +359,7 @@ public class PlatformHelperImpl implements PlatformHelper {
) implements RegistryWrappers.RegistryWrapper<T> {
@Override
public int getId(T object) {
var id = registry.getID(object);
if (id == -1) throw new IllegalStateException(object + " was not registered in " + name);
return id;
return registry.getID(object);
}
@Override
@@ -385,10 +383,13 @@ public class PlatformHelperImpl implements PlatformHelper {
}
@Override
public T get(int id) {
var object = registry.getValue(id);
if (object == null) throw new IllegalStateException(id + " was not registered in " + name);
return object;
public @Nullable T byId(int id) {
return registry.getValue(id);
}
@Override
public int size() {
return registry.getKeys().size();
}
@Override