Rect2i .java

net.minecraft.client.renderer.Rect2i (class): members: intersect, yPos, xPos, setPosition, setHeight, setWidth, setX, setY, getY, getX, contains, getWidth.

net.minecraft.client.rendererclass77 linesclient1.5 KB

API Surface (11)

Rect2i intersect(final Rect2i other)
int getX()
int getY()
void setX(final int x)
void setY(final int y)
int getWidth()
int getHeight()
void setWidth(final int width)
void setHeight(final int height)
void setPosition(final int x, final int y)
boolean contains(final int x, final int y)

Fields & Constants (4)

xPos
yPos
width
height

Full Source

Rect2i.java77 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
6
@Environment(EnvType.CLIENT)
7
public class Rect2i {
8
	private int xPos;
9
	private int yPos;
10
	private int width;
11
	private int height;
12
13
	public Rect2i(final int x, final int y, final int width, final int height) {
14
		this.xPos = x;
15
		this.yPos = y;
16
		this.width = width;
17
		this.height = height;
18
	}
19
20
	public Rect2i intersect(final Rect2i other) {
21
		int x0 = this.xPos;
22
		int y0 = this.yPos;
23
		int x1 = this.xPos + this.width;
24
		int y1 = this.yPos + this.height;
25
		int x2 = other.getX();
26
		int y2 = other.getY();
27
		int x3 = x2 + other.getWidth();
28
		int y3 = y2 + other.getHeight();
29
		this.xPos = Math.max(x0, x2);
30
		this.yPos = Math.max(y0, y2);
31
		this.width = Math.max(0, Math.min(x1, x3) - this.xPos);
32
		this.height = Math.max(0, Math.min(y1, y3) - this.yPos);
33
		return this;
34
	}
35
36
	public int getX() {
37
		return this.xPos;
38
	}
39
40
	public int getY() {
41
		return this.yPos;
42
	}
43
44
	public void setX(final int x) {
45
		this.xPos = x;
46
	}
47
48
	public void setY(final int y) {
49
		this.yPos = y;
50
	}
51
52
	public int getWidth() {
53
		return this.width;
54
	}
55
56
	public int getHeight() {
57
		return this.height;
58
	}
59
60
	public void setWidth(final int width) {
61
		this.width = width;
62
	}
63
64
	public void setHeight(final int height) {
65
		this.height = height;
66
	}
67
68
	public void setPosition(final int x, final int y) {
69
		this.xPos = x;
70
		this.yPos = y;
71
	}
72
73
	public boolean contains(final int x, final int y) {
74
		return x >= this.xPos && x <= this.xPos + this.width && y >= this.yPos && y <= this.yPos + this.height;
75
	}
76
}
77

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