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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user