AbstractTexture .java

net.minecraft.client.renderer.texture.AbstractTexture (class, 56 lines): members: releaseTextures, getTexture, getTextureView, getSampler, sampler, close.

net.minecraft.client.renderer.textureclass56 linesclient1.6 KB

Implements

API Surface (5)

void close()
void releaseTextures()
GpuTexture getTexture()
GpuTextureView getTextureView()
GpuSampler getSampler()

Fields & Constants (3)

texture
textureView
sampler

Code Graph: Dependencies (6)

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

Full Source

AbstractTexture.java56 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.texture;
2
3
import com.mojang.blaze3d.systems.RenderSystem;
4
import com.mojang.renderpearl.api.textures.AddressMode;
5
import com.mojang.renderpearl.api.textures.FilterMode;
6
import com.mojang.renderpearl.api.textures.GpuSampler;
7
import com.mojang.renderpearl.api.textures.GpuTexture;
8
import com.mojang.renderpearl.api.textures.GpuTextureView;
9
import net.fabricmc.api.EnvType;
10
import net.fabricmc.api.Environment;
11
import org.jspecify.annotations.Nullable;
12
13
@Environment(EnvType.CLIENT)
14
public abstract class AbstractTexture implements AutoCloseable {
15
	protected @Nullable GpuTexture texture;
16
	protected @Nullable GpuTextureView textureView;
17
	protected GpuSampler sampler = RenderSystem.getSamplerCache().getSampler(AddressMode.REPEAT, AddressMode.REPEAT, FilterMode.NEAREST, FilterMode.LINEAR, false);
18
19
	@Override
20
	public void close() {
21
		this.releaseTextures();
22
	}
23
24
	protected void releaseTextures() {
25
		if (this.texture != null) {
26
			this.texture.close();
27
			this.texture = null;
28
		}
29
30
		if (this.textureView != null) {
31
			this.textureView.close();
32
			this.textureView = null;
33
		}
34
	}
35
36
	public GpuTexture getTexture() {
37
		if (this.texture == null) {
38
			throw new IllegalStateException("Texture does not exist, can't get it before something initializes it");
39
		} else {
40
			return this.texture;
41
		}
42
	}
43
44
	public GpuTextureView getTextureView() {
45
		if (this.textureView == null) {
46
			throw new IllegalStateException("Texture view does not exist, can't get it before something initializes it");
47
		} else {
48
			return this.textureView;
49
		}
50
	}
51
52
	public GpuSampler getSampler() {
53
		return this.sampler;
54
	}
55
}
56

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