Add support in Techne models for the TextureSize tag. Closes #856
This commit is contained in:
parent
b917d48cff
commit
28f7f523ee
1 changed files with 24 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
package net.minecraftforge.client.model.techne;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -49,6 +50,7 @@ public class TechneModel extends ModelBase implements IModelCustom {
|
|||
|
||||
private Map<String, ModelRenderer> parts = new LinkedHashMap<String, ModelRenderer>();
|
||||
private String texture = null;
|
||||
private Dimension textureDims = null;
|
||||
private int textureName;
|
||||
private boolean textureNameSet = false;
|
||||
|
||||
|
@ -120,6 +122,23 @@ public class TechneModel extends ModelBase implements IModelCustom {
|
|||
texture = modelTexture.getTextContent();
|
||||
}
|
||||
|
||||
NodeList textureDim = document.getElementsByTagName("TextureSize");
|
||||
if (textureDim.getLength() > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] tmp = textureDim.item(0).getTextContent().split(",");
|
||||
if (tmp.length == 2)
|
||||
{
|
||||
this.textureDims = new Dimension(Integer.parseInt(tmp[0]), Integer.parseInt(tmp[1]));
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new ModelFormatException("Model " + fileName + " contains a TextureSize tag with invalid data");
|
||||
}
|
||||
}
|
||||
|
||||
NodeList shapes = document.getElementsByTagName("Shape");
|
||||
for (int i = 0; i < shapes.getLength(); i++)
|
||||
{
|
||||
|
@ -210,6 +229,11 @@ public class TechneModel extends ModelBase implements IModelCustom {
|
|||
cube.rotateAngleY = (float)Math.toRadians(Float.parseFloat(rotation[1]));
|
||||
cube.rotateAngleZ = (float)Math.toRadians(Float.parseFloat(rotation[2]));
|
||||
|
||||
if (this.textureDims != null)
|
||||
{
|
||||
cube.setTextureSize((int)textureDims.getWidth(), (int)textureDims.getHeight());
|
||||
}
|
||||
|
||||
parts.put(shapeName, cube);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
|
|
Loading…
Reference in a new issue