BoundedFloatFunction .java

net.minecraft.util.BoundedFloatFunction (interface, 51 lines): interface declaring 4 methods. members: comap, constant, IDENTITY, range, apply.

net.minecraft.utilinterface51 linescommon1.0 KB

API Surface (6)

float apply(final Float value)
Interval range()
float apply(final C c)
Interval range()
float apply(final C2 c2)
Interval range()

Fields & Constants (1)

IDENTITY

Code Graph: Dependencies (1)

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

Full Source

BoundedFloatFunction.java51 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util;
2
3
import java.util.function.Function;
4
5
public interface BoundedFloatFunction<C> {
6
	BoundedFloatFunction<Float> IDENTITY = new BoundedFloatFunction<Float>() {
7
		public float apply(final Float value) {
8
			return value;
9
		}
10
11
		@Override
12
		public Interval range() {
13
			return Interval.INFINITE;
14
		}
15
	};
16
17
	float apply(final C c);
18
19
	Interval range();
20
21
	static <C> BoundedFloatFunction<C> constant(final float value) {
22
		final Interval range = Interval.ofExact(value);
23
		return new BoundedFloatFunction<C>() {
24
			@Override
25
			public float apply(final C c) {
26
				return value;
27
			}
28
29
			@Override
30
			public Interval range() {
31
				return range;
32
			}
33
		};
34
	}
35
36
	default <C2> BoundedFloatFunction<C2> comap(final Function<C2, C> function) {
37
		final BoundedFloatFunction<C> outer = this;
38
		return new BoundedFloatFunction<C2>() {
39
			@Override
40
			public float apply(final C2 c2) {
41
				return outer.apply(function.apply(c2));
42
			}
43
44
			@Override
45
			public Interval range() {
46
				return outer.range();
47
			}
48
		};
49
	}
50
}
51

Decompiled Minecraft 26.3 source of BoundedFloatFunction (net/minecraft/util/BoundedFloatFunction.java) with Mojang official mappings, stored verbatim on the site.