TextureContents .java

net.minecraft.client.renderer.texture.TextureContents (record): members: image, metadata, createMissing, blur, clamp, load, close. imports: Resource.

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

Implements

API Surface (5)

TextureContents load(final ResourceManager resourceManager, final Identifier location)
TextureContents createMissing()
boolean blur()
boolean clamp()
void close()

Code Graph: Dependencies (6)

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

Full Source

TextureContents.java46 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.texture;
2
3
import com.mojang.blaze3d.platform.NativeImage;
4
import java.io.Closeable;
5
import java.io.IOException;
6
import java.io.InputStream;
7
import net.fabricmc.api.EnvType;
8
import net.fabricmc.api.Environment;
9
import net.minecraft.client.resources.metadata.texture.TextureMetadataSection;
10
import net.minecraft.resources.Identifier;
11
import net.minecraft.server.packs.resources.Resource;
12
import net.minecraft.server.packs.resources.ResourceManager;
13
import org.jspecify.annotations.Nullable;
14
15
@Environment(EnvType.CLIENT)
16
public record TextureContents(NativeImage image, @Nullable TextureMetadataSection metadata) implements Closeable {
17
	public static TextureContents load(final ResourceManager resourceManager, final Identifier location) throws IOException {
18
		Resource resource = resourceManager.getResourceOrThrow(location);
19
20
		NativeImage image;
21
		try (InputStream is = resource.open()) {
22
			image = NativeImage.read(is);
23
		}
24
25
		TextureMetadataSection metadata = resource.metadata().getSection(TextureMetadataSection.TYPE).orElse(null);
26
		return new TextureContents(image, metadata);
27
	}
28
29
	public static TextureContents createMissing() {
30
		return new TextureContents(MissingTextureAtlasSprite.generateMissingImage(), null);
31
	}
32
33
	public boolean blur() {
34
		return this.metadata != null ? this.metadata.blur() : false;
35
	}
36
37
	public boolean clamp() {
38
		return this.metadata != null ? this.metadata.clamp() : false;
39
	}
40
41
	@Override
42
	public void close() {
43
		this.image.close();
44
	}
45
}
46

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