Code/net/minecraft/core/IdMap.java

32 lines
730 B
Java
Raw Normal View History

2025-07-01 06:20:03 +00:00
package net.minecraft.core;
import javax.annotation.Nullable;
public interface IdMap<T> extends Iterable<T> {
int DEFAULT = -1;
int getId(T p_122652_);
@Nullable
T byId(int p_122651_);
default T byIdOrThrow(int p_200958_) {
T t = this.byId(p_200958_);
if (t == null) {
throw new IllegalArgumentException("No value with id " + p_200958_);
} else {
return t;
}
}
default int getIdOrThrow(T p_329088_) {
int i = this.getId(p_329088_);
if (i == -1) {
throw new IllegalArgumentException("Can't find id for '" + p_329088_ + "' in map " + this);
} else {
return i;
}
}
int size();
}