OverlayTexture .java

net.minecraft.client.renderer.texture.OverlayTexture (class): members: WHITE_OVERLAY_V, RED_OVERLAY_V, NO_OVERLAY, NO_WHITE_U, getTextureView, SIZE, pack.

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

Implements

API Surface (6)

void close()
int u(final float whiteOverlayProgress)
int v(final boolean hurtOverlay)
int pack(final int u, final int v)
int pack(final float whiteOverlayProgress, final boolean redOverlay)
GpuTextureView getTextureView()

Fields & Constants (6)

SIZE
NO_WHITE_U
RED_OVERLAY_V
WHITE_OVERLAY_V
NO_OVERLAY
texture

String literals (1)

"Entity Color Overlay"

Code Graph: Dependencies (4)

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

Full Source

OverlayTexture.java60 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.texture;
2
3
import com.mojang.blaze3d.platform.NativeImage;
4
import com.mojang.renderpearl.api.textures.GpuTextureView;
5
import net.fabricmc.api.EnvType;
6
import net.fabricmc.api.Environment;
7
import net.minecraft.util.ARGB;
8
9
@Environment(EnvType.CLIENT)
10
public class OverlayTexture implements AutoCloseable {
11
	private static final int SIZE = 16;
12
	public static final int NO_WHITE_U = 0;
13
	public static final int RED_OVERLAY_V = 3;
14
	public static final int WHITE_OVERLAY_V = 10;
15
	public static final int NO_OVERLAY = pack(0, 10);
16
	private final DynamicTexture texture = new DynamicTexture("Entity Color Overlay", 16, 16, false);
17
18
	public OverlayTexture() {
19
		NativeImage pixels = this.texture.getPixels();
20
21
		for (int y = 0; y < 16; y++) {
22
			for (int x = 0; x < 16; x++) {
23
				if (y < 8) {
24
					pixels.setPixel(x, y, -1291911168);
25
				} else {
26
					int a = (int)((1.0F - x / 15.0F * 0.75F) * 255.0F);
27
					pixels.setPixel(x, y, ARGB.white(a));
28
				}
29
			}
30
		}
31
32
		this.texture.upload();
33
	}
34
35
	@Override
36
	public void close() {
37
		this.texture.close();
38
	}
39
40
	public static int u(final float whiteOverlayProgress) {
41
		return (int)(whiteOverlayProgress * 15.0F);
42
	}
43
44
	public static int v(final boolean hurtOverlay) {
45
		return hurtOverlay ? 3 : 10;
46
	}
47
48
	public static int pack(final int u, final int v) {
49
		return u | v << 16;
50
	}
51
52
	public static int pack(final float whiteOverlayProgress, final boolean redOverlay) {
53
		return pack(u(whiteOverlayProgress), v(redOverlay));
54
	}
55
56
	public GpuTextureView getTextureView() {
57
		return this.texture.getTextureView();
58
	}
59
}
60

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