Implements PoolAliasBinding
API Surface (3) void forEachResolved(final RandomSource random, final BiConsumer<ResourceKey<StructureTemplatePool>, ResourceKey<StructureTemplatePool>> aliasAndTargetConsumer)
Stream<ResourceKey<StructureTemplatePool>> allTargets()
MapCodec<RandomGroupPoolAlias> codec()
Code Graph: Dependencies (5) Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.
Full Source
RandomGroupPoolAlias.java 37 lines · Minecraft 26.3 · verbatim Copy
1 package net.minecraft.world.level.levelgen.structure.pools.alias;
2
3 import com.mojang.serialization.Codec;
4 import com.mojang.serialization.MapCodec;
5 import com.mojang.serialization.codecs.RecordCodecBuilder;
6 import java.util.List;
7 import java.util.function.BiConsumer;
8 import java.util.stream.Stream;
9 import net.minecraft.resources.ResourceKey;
10 import net.minecraft.util.RandomSource;
11 import net.minecraft.util.random.WeightedList;
12 import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
13
14 public record RandomGroupPoolAlias(WeightedList<List<PoolAliasBinding>> groups) implements PoolAliasBinding {
15 public static final MapCodec<RandomGroupPoolAlias> CODEC = RecordCodecBuilder.mapCodec(
16 i -> i.group(WeightedList.nonEmptyCodec(Codec.list(PoolAliasBinding.CODEC)).fieldOf("groups").forGetter(RandomGroupPoolAlias::groups))
17 .apply(i, RandomGroupPoolAlias::new)
18 );
19
20 @Override
21 public void forEachResolved(
22 final RandomSource random, final BiConsumer<ResourceKey<StructureTemplatePool>, ResourceKey<StructureTemplatePool>> aliasAndTargetConsumer
23 ) {
24 this.groups.getRandomOrThrow(random).forEach(binding -> binding.forEachResolved(random, aliasAndTargetConsumer));
25 }
26
27 @Override
28 public Stream<ResourceKey<StructureTemplatePool>> allTargets() {
29 return this.groups.unwrap().stream().flatMap(weightedEntry -> weightedEntry.value().stream()).flatMap(PoolAliasBinding::allTargets);
30 }
31
32 @Override
33 public MapCodec<RandomGroupPoolAlias> codec() {
34 return CODEC;
35 }
36 }
37
Decompiled Minecraft 26.3 source of RandomGroupPoolAlias (net/minecraft/world/level/levelgen/structure/pools/alias/RandomGroupPoolAlias.java) with Mojang official mappings, stored verbatim on the site.