ContextFloatProvider .java

net.minecraft.world.level.storage.loot.providers.number.floats.ContextFloatProvider (interface): members: getFloatOrThrow, intToFloatSafe, getFloat, codec.

net.minecraft.world.level.storage.loot.providers.number.floatsinterface37 linescommonextends Validatable978 B

API Surface (0)

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

String literals (1)

"Invalid value: "

Code Graph: Dependencies (2)

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

Full Source

ContextFloatProvider.java37 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.storage.loot.providers.number.floats;
2
3
import com.mojang.serialization.MapCodec;
4
import net.minecraft.world.level.storage.loot.LootContext;
5
import net.minecraft.world.level.storage.loot.Validatable;
6
7
public interface ContextFloatProvider extends Validatable {
8
	float getFloatUnsafe(LootContext context) throws ArithmeticException;
9
10
	default float getFloat(final LootContext context) {
11
		try {
12
			float result = this.getFloatUnsafe(context);
13
			if (Float.isFinite(result)) {
14
				return result;
15
			}
16
		} catch (ArithmeticException var3) {
17
		}
18
19
		return 0.0F;
20
	}
21
22
	default float getFloatOrThrow(final LootContext context) throws ArithmeticException {
23
		float value = this.getFloatUnsafe(context);
24
		if (!Float.isFinite(value)) {
25
			throw new ArithmeticException("Invalid value: " + value);
26
		} else {
27
			return value;
28
		}
29
	}
30
31
	MapCodec<? extends ContextFloatProvider> codec();
32
33
	static float intToFloatSafe(final int value) {
34
		return value;
35
	}
36
}
37

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