use of net.minecraft.client.renderer.texture.NativeImage in project MCMOD-Industria by M-Marvin.
the class AnimatedTexture method load.
public void load(IResourceManager manager) throws IOException {
SimpleTexture.TextureData simpletexture$texturedata = this.getTextureImage(manager);
simpletexture$texturedata.throwIfError();
TextureMetadataSection texturemetadatasection = simpletexture$texturedata.getTextureMetadata();
boolean flag;
boolean flag1;
if (texturemetadatasection != null) {
flag = texturemetadatasection.isBlur();
flag1 = texturemetadatasection.isClamp();
} else {
flag = false;
flag1 = false;
}
NativeImage nativeimage = simpletexture$texturedata.getImage();
if (!RenderSystem.isOnRenderThreadOrInit()) {
RenderSystem.recordRenderCall(() -> {
this.loadImage(nativeimage, flag, flag1);
});
} else {
this.loadImage(nativeimage, flag, flag1);
}
this.size = simpletexture$texturedata.getImage().getWidth();
this.textureHeight = simpletexture$texturedata.getImage().getHeight();
ResourceLocation metadataFile = new ResourceLocation(this.location.getNamespace(), this.location.getPath() + ".mcmeta");
try {
IResource metadataResource = manager.getResource(metadataFile);
InputStreamReader inputStreamReader = new InputStreamReader(metadataResource.getInputStream());
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuffer stringBuffer = new StringBuffer();
String string;
while ((string = bufferedReader.readLine()) != null) {
stringBuffer.append(string);
}
CompoundNBT metadataNBT = JsonToNBT.parseTag(stringBuffer.toString());
CompoundNBT animation = metadataNBT.getCompound("animation");
this.frameTime = animation.getInt("frametime");
if (animation.contains("frames")) {
ListNBT arr = animation.getList("frames", 3);
frames = new int[arr.size()];
for (int i = 0; i < arr.size(); i++) {
this.frames[i] = arr.getInt(i);
}
} else {
int height = simpletexture$texturedata.getImage().getHeight();
int frameCount = height / size;
frames = new int[frameCount];
for (int i = 0; i < frameCount; i++) {
this.frames[i] = i;
}
}
} catch (CommandSyntaxException | FileNotFoundException e) {
this.frames = new int[] { 0 };
this.frameTime = 1;
}
}
use of net.minecraft.client.renderer.texture.NativeImage in project RGBBlocks by PlatinPython.
the class RGBBlocksPack method gatherTextureData.
protected void gatherTextureData(IResourceManager manager, IProfiler profiler) {
Map<ResourceLocation, Callable<InputStream>> resourceStreams = new HashMap<>();
textures.forEach((modLocation, vanillaLocation) -> {
generateImage(modLocation, vanillaLocation, Minecraft.getInstance().getResourceManager()).ifPresent(pair -> {
NativeImage image = pair.getFirst();
ResourceLocation textureID = makeTextureID(modLocation);
resourceStreams.put(textureID, () -> new ByteArrayInputStream(image.asByteArray()));
pair.getSecond().ifPresent(metadataGetter -> resourceStreams.put(getMetadataLocation(textureID), metadataGetter));
});
});
this.resources = resourceStreams;
}
Aggregations