IdMap .java

net.minecraft.core.IdMap (interface): members: getIdOrThrow, byIdOrThrow, byId, DEFAULT, getId, size. strings: "Can't find id for '", "No value with id ".

net.minecraft.coreinterface32 linescommonextends Iterable<T>613 B

API Surface (0)

No public/protected methods detected (fields or constants only).

Fields & Constants (1)

DEFAULT

String literals (3)

"No value with id "
"Can't find id for '"
"' in map "

Full Source

IdMap.java32 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.core;
2
3
import org.jspecify.annotations.Nullable;
4
5
public interface IdMap<T> extends Iterable<T> {
6
	int DEFAULT = -1;
7
8
	int getId(T thing);
9
10
	@Nullable T byId(int id);
11
12
	default T byIdOrThrow(final int id) {
13
		T result = this.byId(id);
14
		if (result == null) {
15
			throw new IllegalArgumentException("No value with id " + id);
16
		} else {
17
			return result;
18
		}
19
	}
20
21
	default int getIdOrThrow(final T value) {
22
		int id = this.getId(value);
23
		if (id == -1) {
24
			throw new IllegalArgumentException("Can't find id for '" + value + "' in map " + this);
25
		} else {
26
			return id;
27
		}
28
	}
29
30
	int size();
31
}
32

Decompiled Minecraft 26.3 source of IdMap (net/minecraft/core/IdMap.java) with Mojang official mappings, stored verbatim on the site.