mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Provide a IModel for "builtin/generated", fixes #2147
This commit is contained in:
1 parent
b75593b0c6
commit
da19eda51e
2 files changed
+35
-18
No files matched your search
@@ -69,6 +69,7 @@ public class ModelLoader extends ModelBakery
|
||||
private final Set<ResourceLocation> loadingModels = new HashSet<ResourceLocation>();
|
||||
private final Set<ModelResourceLocation> missingVariants = Sets.newHashSet();
|
||||
private IModel missingModel = null;
|
||||
private IModel itemModel = new ItemLayerModel(MODEL_GENERATED);
|
||||
|
||||
private boolean isLoading = false;
|
||||
public boolean isLoading()
|
||||
@@ -255,29 +256,36 @@ public class ModelLoader extends ModelBakery
|
||||
// setting parent here to make textures resolve properly
|
||||
if(model.getParentLocation() != null)
|
||||
{
|
||||
try
|
||||
if(model.getParentLocation().getResourcePath().equals("builtin/generated"))
|
||||
{
|
||||
IModel parent = getModel(model.getParentLocation());
|
||||
if(parent instanceof VanillaModelWrapper)
|
||||
{
|
||||
model.parent = ((VanillaModelWrapper) parent).model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("vanilla model '" + model + "' can't have non-vanilla parent");
|
||||
}
|
||||
model.parent = MODEL_GENERATED;
|
||||
}
|
||||
catch (IOException e)
|
||||
else
|
||||
{
|
||||
FMLLog.warning("Could not load vanilla model parent '" + model.getParentLocation() + "' for '" + model + "': " + e.toString());
|
||||
IModel missing = ModelLoader.this.getMissingModel();
|
||||
if (missing instanceof VanillaModelWrapper)
|
||||
try
|
||||
{
|
||||
model.parent = ((VanillaModelWrapper)missing).model;
|
||||
IModel parent = getModel(model.getParentLocation());
|
||||
if(parent instanceof VanillaModelWrapper)
|
||||
{
|
||||
model.parent = ((VanillaModelWrapper) parent).model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("vanilla model '" + model + "' can't have non-vanilla parent");
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new IllegalStateException("vanilla model '" + model + "' has missing parent, and missing model is not a vanilla model");
|
||||
FMLLog.warning("Could not load vanilla model parent '" + model.getParentLocation() + "' for '" + model + "': " + e.toString());
|
||||
IModel missing = ModelLoader.this.getMissingModel();
|
||||
if (missing instanceof VanillaModelWrapper)
|
||||
{
|
||||
model.parent = ((VanillaModelWrapper)missing).model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("vanilla model '" + model + "' has missing parent, and missing model is not a vanilla model");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -630,6 +638,11 @@ public class ModelLoader extends ModelBakery
|
||||
return missingModel;
|
||||
}
|
||||
|
||||
public IModel getItemModel()
|
||||
{
|
||||
return itemModel;
|
||||
}
|
||||
|
||||
static enum VanillaLoader implements ICustomModelLoader
|
||||
{
|
||||
instance;
|
||||
|
||||
@@ -64,8 +64,8 @@ public class ModelLoaderRegistry
|
||||
|
||||
public static IModel getModel(ResourceLocation location) throws IOException
|
||||
{
|
||||
ResourceLocation actual = getActualLocation(location);
|
||||
if(cache.containsKey(location)) return cache.get(location);
|
||||
ResourceLocation actual = getActualLocation(location);
|
||||
ICustomModelLoader accepted = null;
|
||||
for(ICustomModelLoader loader : loaders)
|
||||
{
|
||||
@@ -127,5 +127,9 @@ public class ModelLoaderRegistry
|
||||
public static void clearModelCache()
|
||||
{
|
||||
cache.clear();
|
||||
// putting the builtin models in
|
||||
cache.put(new ResourceLocation("minecraft:builtin/generated"), ModelLoader.VanillaLoader.instance.getLoader().getItemModel());
|
||||
cache.put(new ResourceLocation("minecraft:block/builtin/generated"), ModelLoader.VanillaLoader.instance.getLoader().getItemModel());
|
||||
cache.put(new ResourceLocation("minecraft:item/builtin/generated"), ModelLoader.VanillaLoader.instance.getLoader().getItemModel());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user