forked from war-monger/Flan-s-Mod-Plus-War_Monger
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from SecretAgent12/Unknown025-Ultimate
Unknown025 ultimate
- Loading branch information
Showing
16 changed files
with
2,618 additions
and
2,673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,54 @@ | ||
package com.flansmod.client.tmt; | ||
|
||
import com.flansmod.common.FlansMod; | ||
import cpw.mods.fml.common.Loader; | ||
|
||
import java.io.File; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.flansmod.common.FlansMod; | ||
|
||
import cpw.mods.fml.common.Loader; | ||
public class ModelPool { | ||
public static final Class<ModelPoolObjEntry> OBJ = ModelPoolObjEntry.class; | ||
private static final Map<String, ModelPoolEntry> modelMap = new HashMap<>(); | ||
private static final String[] resourceDir = new String[]{ | ||
"/resources/models/", | ||
"/resources/mod/models/", | ||
"/Flan/" | ||
}; | ||
|
||
public class ModelPool | ||
{ | ||
public static ModelPoolEntry addFile(String file, Class modelClass, Map<String, TransformGroup> group, Map<String, TextureGroup> textureGroup) | ||
{ | ||
ModelPoolEntry entry = null; | ||
if(modelMap.containsKey(file)) | ||
{ | ||
entry = modelMap.get(file); | ||
entry.applyGroups(group, textureGroup); | ||
return entry; | ||
} | ||
try | ||
{ | ||
entry = (ModelPoolEntry)modelClass.newInstance(); | ||
} | ||
catch(Exception e) | ||
{ | ||
FlansMod.log("A new " + entry.getClass().getName() + " could not be initialized."); | ||
FlansMod.log(e.getMessage()); | ||
return null; | ||
} | ||
File modelFile = null; | ||
for(int i = 0; i < resourceDir.length && (modelFile == null || !modelFile.exists()); i++) | ||
{ | ||
String absPath = new File(Loader.instance().getConfigDir().getParent(), resourceDir[i]).getAbsolutePath(); | ||
if(!absPath.endsWith("/") || !absPath.endsWith("\\")) | ||
absPath+= "/"; | ||
modelFile = entry.checkValidPath(absPath + file); | ||
} | ||
if(modelFile == null || !modelFile.exists()) | ||
{ | ||
FlansMod.log("The model with the name " + file + " does not exist."); | ||
return null; | ||
} | ||
entry.groups = new HashMap<String, TransformGroupBone>(); | ||
entry.textures = new HashMap<String, TextureGroup>(); | ||
entry.name = file; | ||
entry.setGroup("0"); | ||
entry.setTextureGroup("0"); | ||
entry.getModel(modelFile); | ||
entry.applyGroups(group, textureGroup); | ||
modelMap.put(file, entry); | ||
return entry; | ||
} | ||
|
||
private static Map<String, ModelPoolEntry> modelMap = new HashMap<String, ModelPoolEntry>(); | ||
private static String[] resourceDir = new String[] { | ||
"/resources/models/", | ||
"/resources/mod/models/", | ||
"/Flan/" | ||
}; | ||
public static final Class OBJ = ModelPoolObjEntry.class; | ||
public static ModelPoolEntry addFile(String file, Class<?> modelClass, Map<String, TransformGroup> group, Map<String, TextureGroup> textureGroup) { | ||
ModelPoolEntry entry = null; | ||
if (modelMap.containsKey(file)) { | ||
entry = modelMap.get(file); | ||
entry.applyGroups(group, textureGroup); | ||
return entry; | ||
} | ||
try { | ||
entry = (ModelPoolEntry) modelClass.newInstance(); | ||
} catch (Exception e) { | ||
FlansMod.log("A new " + entry.getClass().getName() + " could not be initialized."); | ||
FlansMod.log(e.getMessage()); | ||
return null; | ||
} | ||
File modelFile = null; | ||
for (int i = 0; i < resourceDir.length && (modelFile == null || !modelFile.exists()); i++) { | ||
String absPath = new File(Loader.instance().getConfigDir().getParent(), resourceDir[i]).getAbsolutePath(); | ||
if (!absPath.endsWith("/") || !absPath.endsWith("\\")) | ||
absPath += "/"; | ||
modelFile = entry.checkValidPath(absPath + file); | ||
} | ||
if (modelFile == null || !modelFile.exists()) { | ||
FlansMod.log("The model with the name " + file + " does not exist."); | ||
return null; | ||
} | ||
entry.groups = new HashMap<>(); | ||
entry.textures = new HashMap<>(); | ||
entry.name = file; | ||
entry.setGroup("0"); | ||
entry.setTextureGroup("0"); | ||
entry.getModel(modelFile); | ||
entry.applyGroups(group, textureGroup); | ||
modelMap.put(file, entry); | ||
return entry; | ||
} | ||
} |
Oops, something went wrong.