RandomlySelectedPlacement .java

net.minecraft.world.level.levelgen.placement.RandomlySelectedPlacement (record, 32 lines): members: placements, modify, codec, CODEC. imports: ExtraCodecs.

net.minecraft.world.level.levelgen.placementrecord32 linescommon1.2 KB

Implements

API Surface (2)

void modify(final PlacementContext context, final RandomSource random, final BlockPos origin, final Consumer<BlockPos> output)
MapCodec<RandomlySelectedPlacement> codec()

Fields & Constants (1)

CODEC

String literals (1)

"placements"

Code Graph: Dependencies (6)

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

Full Source

RandomlySelectedPlacement.java32 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.placement;
2
3
import com.mojang.serialization.MapCodec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import java.util.List;
6
import java.util.function.Consumer;
7
import net.minecraft.core.BlockPos;
8
import net.minecraft.util.ExtraCodecs;
9
import net.minecraft.util.RandomSource;
10
import net.minecraft.util.Util;
11
12
public record RandomlySelectedPlacement(List<PlacementModifier> placements) implements PlacementModifier {
13
	public static final MapCodec<RandomlySelectedPlacement> CODEC = RecordCodecBuilder.mapCodec(
14
		i -> i.group(ExtraCodecs.nonEmptyList(PlacementModifier.CODEC.listOf()).fieldOf("placements").forGetter(RandomlySelectedPlacement::placements))
15
			.apply(i, RandomlySelectedPlacement::new)
16
	);
17
18
	public RandomlySelectedPlacement(final PlacementModifier... placements) {
19
		this(List.of(placements));
20
	}
21
22
	@Override
23
	public void modify(final PlacementContext context, final RandomSource random, final BlockPos origin, final Consumer<BlockPos> output) {
24
		Util.getRandom(this.placements, random).modify(context, random, origin, output);
25
	}
26
27
	@Override
28
	public MapCodec<RandomlySelectedPlacement> codec() {
29
		return CODEC;
30
	}
31
}
32

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