TranslucencyPointOfView .java

net.minecraft.client.renderer.chunk.TranslucencyPointOfView (class, 52 lines): members: isAxisAligned, set, hashCode, equals. imports: SectionPos.

net.minecraft.client.renderer.chunkclass52 linesclient1.5 KB

API Surface (5)

TranslucencyPointOfView of(final Vec3 cameraPos, final long sectionNode)
TranslucencyPointOfView set(final Vec3 cameraPos, final long sectionPos)
boolean isAxisAligned()
boolean equals(final Object other)
int hashCode()

Fields & Constants (3)

x
y
z

Code Graph: Dependencies (3)

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

Full Source

TranslucencyPointOfView.java52 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.chunk;
2
3
import java.util.Objects;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.core.SectionPos;
7
import net.minecraft.util.Mth;
8
import net.minecraft.world.phys.Vec3;
9
10
@Environment(EnvType.CLIENT)
11
public final class TranslucencyPointOfView {
12
	private int x;
13
	private int y;
14
	private int z;
15
16
	public static TranslucencyPointOfView of(final Vec3 cameraPos, final long sectionNode) {
17
		return new TranslucencyPointOfView().set(cameraPos, sectionNode);
18
	}
19
20
	public TranslucencyPointOfView set(final Vec3 cameraPos, final long sectionPos) {
21
		this.x = getCoordinate(cameraPos.x(), SectionPos.x(sectionPos));
22
		this.y = getCoordinate(cameraPos.y(), SectionPos.y(sectionPos));
23
		this.z = getCoordinate(cameraPos.z(), SectionPos.z(sectionPos));
24
		return this;
25
	}
26
27
	private static int getCoordinate(final double cameraCoordinate, final int section) {
28
		int relativeSection = SectionPos.blockToSectionCoord(cameraCoordinate) - section;
29
		return Mth.clamp(relativeSection, -1, 1);
30
	}
31
32
	public boolean isAxisAligned() {
33
		return this.x == 0 || this.y == 0 || this.z == 0;
34
	}
35
36
	@Override
37
	public boolean equals(final Object other) {
38
		if (other == this) {
39
			return true;
40
		} else {
41
			return !(other instanceof TranslucencyPointOfView otherPerspective)
42
				? false
43
				: this.x == otherPerspective.x && this.y == otherPerspective.y && this.z == otherPerspective.z;
44
		}
45
	}
46
47
	@Override
48
	public int hashCode() {
49
		return Objects.hash(this.x, this.y, this.z);
50
	}
51
}
52

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