ScreenPosition .java

net.minecraft.client.gui.navigation.ScreenPosition (record, 31 lines): record with 2 components. members: getCoordinate, step. imports: EnvType.

net.minecraft.client.gui.navigationrecord31 linesclient944 B

API Surface (4)

record ScreenPosition(int x, int y)
ScreenPosition of(final ScreenAxis axis, final int primaryValue, final int secondaryValue)
ScreenPosition step(final ScreenDirection direction)
int getCoordinate(final ScreenAxis axis)

Code Graph: Dependencies (2)

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

Full Source

ScreenPosition.java31 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.gui.navigation;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
6
@Environment(EnvType.CLIENT)
7
public record ScreenPosition(int x, int y) {
8
	public static ScreenPosition of(final ScreenAxis axis, final int primaryValue, final int secondaryValue) {
9
		return switch (axis) {
10
			case HORIZONTAL -> new ScreenPosition(primaryValue, secondaryValue);
11
			case VERTICAL -> new ScreenPosition(secondaryValue, primaryValue);
12
		};
13
	}
14
15
	public ScreenPosition step(final ScreenDirection direction) {
16
		return switch (direction) {
17
			case DOWN -> new ScreenPosition(this.x, this.y + 1);
18
			case UP -> new ScreenPosition(this.x, this.y - 1);
19
			case LEFT -> new ScreenPosition(this.x - 1, this.y);
20
			case RIGHT -> new ScreenPosition(this.x + 1, this.y);
21
		};
22
	}
23
24
	public int getCoordinate(final ScreenAxis axis) {
25
		return switch (axis) {
26
			case HORIZONTAL -> this.x;
27
			case VERTICAL -> this.y;
28
		};
29
	}
30
}
31

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