ScreenDirection .java

net.minecraft.client.gui.navigation.ScreenDirection (enum): members: UP, DOWN, LEFT, RIGHT, coordinateValueComparator, isPositive, isBefore, getAxis.

net.minecraft.client.gui.navigationenum51 linesclient1.1 KB

API Surface (6)

ScreenAxis getAxis()
ScreenDirection getOpposite()
boolean isPositive()
boolean isAfter(final int a, final int b)
boolean isBefore(final int a, final int b)
IntComparator coordinateValueComparator()

Fields & Constants (3)

DOWN
RIGHT
coordinateValueComparator

Code Graph: Dependencies (1)

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

Full Source

ScreenDirection.java51 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.gui.navigation;
2
3
import it.unimi.dsi.fastutil.ints.IntComparator;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
7
@Environment(EnvType.CLIENT)
8
public enum ScreenDirection {
9
	UP,
10
	DOWN,
11
	LEFT,
12
	RIGHT;
13
14
	private final IntComparator coordinateValueComparator = (k1, k2) -> k1 == k2 ? 0 : (this.isBefore(k1, k2) ? -1 : 1);
15
16
	public ScreenAxis getAxis() {
17
		return switch (this) {
18
			case UP, DOWN -> ScreenAxis.VERTICAL;
19
			case LEFT, RIGHT -> ScreenAxis.HORIZONTAL;
20
		};
21
	}
22
23
	public ScreenDirection getOpposite() {
24
		return switch (this) {
25
			case UP -> DOWN;
26
			case DOWN -> UP;
27
			case LEFT -> RIGHT;
28
			case RIGHT -> LEFT;
29
		};
30
	}
31
32
	public boolean isPositive() {
33
		return switch (this) {
34
			case UP, LEFT -> false;
35
			case DOWN, RIGHT -> true;
36
		};
37
	}
38
39
	public boolean isAfter(final int a, final int b) {
40
		return this.isPositive() ? a > b : b > a;
41
	}
42
43
	public boolean isBefore(final int a, final int b) {
44
		return this.isPositive() ? a < b : b < a;
45
	}
46
47
	public IntComparator coordinateValueComparator() {
48
		return this.coordinateValueComparator;
49
	}
50
}
51

Decompiled Minecraft 26.3 source of ScreenDirection (net/minecraft/client/gui/navigation/ScreenDirection.java) with Mojang official mappings, stored verbatim on the site.