private void compileTextureList() { for (Element cuboid : manager.getAllElements()) { for (Face face : cuboid.getAllFaces()) { System.out.println(face.getTextureLocation() + " " + face.getTextureName()); if (face.getTextureName() != null && !face.getTextureName().equals("null")) { if (!textureList.contains(face.getTextureLocation() + face.getTextureName())) { textureList.add(face.getTextureLocation() + face.getTextureName()); } } } } }
private void writeFaces(BufferedWriter writer, Element cuboid) throws IOException { writer.write(space(3) + "\"faces\": {"); writer.newLine(); for (Face face : cuboid.getAllFaces()) { if (face.isEnabled()) { writer.write(space(4) + "\"" + Face.getFaceName(face.getSide()) + "\": { "); writer.write( "\"texture\": \"#" + textureList.indexOf(face.getTextureLocation() + face.getTextureName()) + "\""); writer.write( ", \"uv\": [ " + numToString(face.getStartU()) + ", " + numToString(face.getStartV()) + ", " + numToString(face.getEndU()) + ", " + numToString(face.getEndV()) + " ]"); if (face.getRotation() > 0) writer.write(", \"rotation\": " + numToString(face.getRotation() * 90)); if (face.isCullfaced()) writer.write(", \"cullface\": \"" + Face.getFaceName(face.getSide()) + "\""); writer.write(" }"); if (face.getSide() != cuboid.getLastValidFace()) { writer.write(","); writer.newLine(); } } } writer.newLine(); writer.write(space(3) + "}"); }