Skip to content

Conversation

@XiYang6666
Copy link

@XiYang6666 XiYang6666 commented Oct 25, 2025

resolve #1058

StartupEvents.registry("fluid", (event) => {
  event.create("test_fluid")
});

default LoadedTexture loadTexture(ResourceLocation id) {
return LoadedTexture.load(id);
}

public static LoadedTexture load(ResourceLocation id) {
try {
var path = KubeJSPaths.ASSETS.resolve(id.getNamespace() + "/textures/" + id.getPath() + ".png");
if (Files.exists(path)) {
try (var in = new BufferedInputStream(Files.newInputStream(path))) {
var metaPath = KubeJSPaths.ASSETS.resolve(id.getNamespace() + "/textures/" + id.getPath() + ".png.mcmeta");
return new LoadedTexture(ImageIO.read(in), Files.exists(metaPath) ? Files.readAllBytes(metaPath) : null);
}
} else if (id.getNamespace().equals(KubeJS.MOD_ID)) {
var path1 = KubeJS.thisMod.getModInfo().getOwningFile().getFile().findResource("assets", "kubejs", "textures", id.getPath() + ".png");
if (Files.exists(path1)) {
try (var in = new BufferedInputStream(Files.newInputStream(path1))) {
var metaPath = KubeJS.thisMod.getModInfo().getOwningFile().getFile().findResource("assets", "kubejs", "textures", id.getPath() + ".png.mcmeta");
return new LoadedTexture(ImageIO.read(in), Files.exists(metaPath) ? Files.readAllBytes(metaPath) : null);
}
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return EMPTY;
}

generator.loadTexture(...) always returns a non-null value
it uses LoadedTexture.EMPTY to represent an empty texture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to save texture

1 participant