ConstantValue .java

net.minecraft.world.level.storage.loot.providers.number.ints.ConstantValue (record, 29 lines): members: value, INLINE_CODEC, getIntUnsafe, validate, codec.

net.minecraft.world.level.storage.loot.providers.number.intsrecord29 linescommon956 B

Implements

API Surface (3)

MapCodec<ConstantValue> codec()
void validate(final ValidationContext context)
int getIntUnsafe(final LootContext random)

Fields & Constants (2)

MAP_CODEC
INLINE_CODEC

Code Graph: Dependencies (3)

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

Full Source

ConstantValue.java29 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.storage.loot.providers.number.ints;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.MapCodec;
5
import com.mojang.serialization.codecs.RecordCodecBuilder;
6
import net.minecraft.world.level.storage.loot.LootContext;
7
import net.minecraft.world.level.storage.loot.ValidationContext;
8
9
public record ConstantValue(int value) implements ContextIntProvider {
10
	public static final MapCodec<ConstantValue> MAP_CODEC = RecordCodecBuilder.mapCodec(
11
		i -> i.group(Codec.INT.fieldOf("value").forGetter(ConstantValue::value)).apply(i, ConstantValue::new)
12
	);
13
	public static final Codec<ConstantValue> INLINE_CODEC = Codec.INT.xmap(ConstantValue::new, ConstantValue::value);
14
15
	@Override
16
	public MapCodec<ConstantValue> codec() {
17
		return MAP_CODEC;
18
	}
19
20
	@Override
21
	public void validate(final ValidationContext context) {
22
	}
23
24
	@Override
25
	public int getIntUnsafe(final LootContext random) {
26
		return this.value;
27
	}
28
}
29

Decompiled Minecraft 26.3 source of ConstantValue (net/minecraft/world/level/storage/loot/providers/number/ints/ConstantValue.java) with Mojang official mappings, stored verbatim on the site.