From af2b5eb6f60efbf1e3243ad6585856c245cfb8fa Mon Sep 17 00:00:00 2001 From: James Date: Wed, 19 Jun 2013 15:57:44 -0600 Subject: [PATCH] Add an InputStream constructor to WavefrontObject It is said that Resource Packs will return InputStreams. And I like putting my models into texture packs which, obviously, give InputStreams rather than URLs. --- .../client/model/obj/WavefrontObject.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/client/net/minecraftforge/client/model/obj/WavefrontObject.java b/client/net/minecraftforge/client/model/obj/WavefrontObject.java index 55603fbbb..d80a1cff5 100644 --- a/client/net/minecraftforge/client/model/obj/WavefrontObject.java +++ b/client/net/minecraftforge/client/model/obj/WavefrontObject.java @@ -49,20 +49,32 @@ public class WavefrontObject implements IModelCustom public WavefrontObject(String fileName, URL resource) throws ModelFormatException { this.fileName = fileName; - loadObjModel(resource); + + try + { + loadObjModel(resource.openStream()); + } + catch (IOException e) + { + throw new ModelFormatException("IO Exception reading model format", e); + } + } + + public WavefrontObject(String filename, InputStream inputStream) throws ModelFormatException + { + this.fileName = filename; + loadObjModel(inputStream); } - private void loadObjModel(URL fileURL) throws ModelFormatException + private void loadObjModel(InputStream inputStream) throws ModelFormatException { BufferedReader reader = null; - InputStream inputStream = null; String currentLine = null; int lineCount = 0; try { - inputStream = fileURL.openStream(); reader = new BufferedReader(new InputStreamReader(inputStream)); while ((currentLine = reader.readLine()) != null)