use of net.minecraft.client.resources.data.TextureMetadataSection in project ACsGuis by AymericBdy.
the class ThreadedTexture method loadTexture.
public void loadTexture(IResourceManager resourceManager) throws IOException {
IResource iresource = null;
try {
iresource = resourceManager.getResource(this.textureLocation);
BufferedImage bufferedimage = TextureUtil.readBufferedImage(iresource.getInputStream());
flag = false;
flag1 = false;
if (iresource.hasMetadata()) {
try {
TextureMetadataSection texturemetadatasection = iresource.getMetadata("texture");
if (texturemetadatasection != null) {
flag = texturemetadatasection.getTextureBlur();
flag1 = texturemetadatasection.getTextureClamp();
}
} catch (RuntimeException runtimeexception) {
LOGGER.warn("Failed reading metadata of: {}", this.textureLocation, runtimeexception);
}
}
imageData = bufferedimage;
} finally {
IOUtils.closeQuietly(iresource);
}
}
use of net.minecraft.client.resources.data.TextureMetadataSection 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;
}
}
Aggregations