PoolAliasLookup .java

net.minecraft.world.level.levelgen.structure.pools.alias.PoolAliasLookup (interface, 33 lines): members: lookup, EMPTY, create. strings: "alias ".

net.minecraft.world.level.levelgen.structure.pools.aliasinterface33 linescommon1.4 KB

API Surface (0)

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

Fields & Constants (1)

EMPTY

String literals (2)

"alias "
" was mapped to null value"

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

PoolAliasLookup.java33 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.structure.pools.alias;
2
3
import com.google.common.collect.ImmutableMap;
4
import com.google.common.collect.ImmutableMap.Builder;
5
import java.util.List;
6
import java.util.Map;
7
import java.util.Objects;
8
import net.minecraft.core.BlockPos;
9
import net.minecraft.resources.ResourceKey;
10
import net.minecraft.util.RandomSource;
11
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
12
13
@FunctionalInterface
14
public interface PoolAliasLookup {
15
	PoolAliasLookup EMPTY = key -> key;
16
17
	ResourceKey<StructureTemplatePool> lookup(final ResourceKey<StructureTemplatePool> alias);
18
19
	static PoolAliasLookup create(final List<PoolAliasBinding> poolAliasBindings, final BlockPos pos, final long seed) {
20
		if (poolAliasBindings.isEmpty()) {
21
			return EMPTY;
22
		}
23
24
		RandomSource random = RandomSource.create(seed).forkPositional().at(pos);
25
		Builder<ResourceKey<StructureTemplatePool>, ResourceKey<StructureTemplatePool>> builder = ImmutableMap.builder();
26
		poolAliasBindings.forEach(binding -> binding.forEachResolved(random, builder::put));
27
		Map<ResourceKey<StructureTemplatePool>, ResourceKey<StructureTemplatePool>> aliasMappings = builder.build();
28
		return resourceKey -> Objects.requireNonNull(
29
			aliasMappings.getOrDefault(resourceKey, resourceKey), () -> "alias " + resourceKey.identifier() + " was mapped to null value"
30
		);
31
	}
32
}
33

Decompiled Minecraft 26.3 source of PoolAliasLookup (net/minecraft/world/level/levelgen/structure/pools/alias/PoolAliasLookup.java) with Mojang official mappings, stored verbatim on the site.