public Object load(AssetInfo info) throws IOException { this.assetManager = info.getManager(); InputStream in = info.openStream(); try { key = info.getKey(); if (key.getExtension().equals("j3m") && !(key instanceof MaterialKey)) { throw new IOException("Material instances must be loaded via MaterialKey"); } else if (key.getExtension().equals("j3md") && key instanceof MaterialKey) { throw new IOException("Material definitions must be loaded via AssetKey"); } loadFromRoot(BlockLanguageParser.parse(in)); } finally { if (in != null) { in.close(); } } if (material != null) { // material implementation return material; } else { // material definition return materialDef; } }
public Object load(AssetInfo info) throws IOException { if (!(info.getKey() instanceof TextureKey)) { throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey"); } boolean flip = ((TextureKey) info.getKey()).isFlipY(); InputStream in = null; try { in = info.openStream(); Image img = load(in, flip); return img; } finally { if (in != null) { in.close(); } } }
@SuppressWarnings("empty-statement") public Object load(AssetInfo info) throws IOException { reset(); this.key = info.getKey(); this.assetManager = info.getManager(); if (info.getKey() instanceof EnhancedAssetKey) { folderName = ((EnhancedAssetKey) info.getKey()).getMaterialsPath(); } else { folderName = info.getKey().getFolder(); } matList = new MaterialList(); InputStream in = null; try { in = info.openStream(); scan = new Scanner(in); scan.useLocale(Locale.US); while (readLine()) ; } finally { if (in != null) { in.close(); } } if (matName != null) { // still have a material in the vars createMaterial(); resetMaterial(); } MaterialList list = matList; return list; }
@Override public Object load(final AssetInfo assetInfo) throws IOException { try (final Reader reader = new InputStreamReader(assetInfo.openStream())) { return process(gson.fromJson(reader, assetDefinitionType), assetInfo.getManager()); } }