AddValue .java

net.minecraft.world.item.enchantment.effects.AddValue (record, 23 lines): members: value, process, codec, CODEC. imports: LevelBasedValue, RandomSource.

net.minecraft.world.item.enchantment.effectsrecord23 linescommon777 B

Implements

API Surface (2)

float process(final int enchantmentLevel, final RandomSource random, final float inputValue)
MapCodec<AddValue> codec()

Fields & Constants (1)

CODEC

Code Graph: Dependencies (3)

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

Full Source

AddValue.java23 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.item.enchantment.effects;
2
3
import com.mojang.serialization.MapCodec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import net.minecraft.util.RandomSource;
6
import net.minecraft.world.item.enchantment.LevelBasedValue;
7
8
public record AddValue(LevelBasedValue value) implements EnchantmentValueEffect {
9
	public static final MapCodec<AddValue> CODEC = RecordCodecBuilder.mapCodec(
10
		i -> i.group(LevelBasedValue.CODEC.fieldOf("value").forGetter(AddValue::value)).apply(i, AddValue::new)
11
	);
12
13
	@Override
14
	public float process(final int enchantmentLevel, final RandomSource random, final float inputValue) {
15
		return inputValue + this.value.calculate(enchantmentLevel);
16
	}
17
18
	@Override
19
	public MapCodec<AddValue> codec() {
20
		return CODEC;
21
	}
22
}
23

Decompiled Minecraft 26.3 source of AddValue (net/minecraft/world/item/enchantment/effects/AddValue.java) with Mojang official mappings, stored verbatim on the site.