Add variant alias for item models not loaded via blockstate (#5025)

This commit is contained in:
Ben Staddon authored and LexManos committed 2018-08-16 13:21:21 -07:00
1 parent f6b3893a05
commit 69233f1bbf
2 files changed
+17 -1

No files matched your search

@@ -300,6 +300,7 @@ public final class ModelLoader extends ModelBakery
try
{
model = ModelLoaderRegistry.getModel(file);
ModelLoaderRegistry.addAlias(memory, file);
}
catch (Exception normalException)
{
@@ -52,6 +52,8 @@ public class ModelLoaderRegistry
private static final Map<ResourceLocation, IModel> cache = Maps.newHashMap();
private static final Deque<ResourceLocation> loadingModels = Queues.newArrayDeque();
private static final Set<ResourceLocation> textures = Sets.newHashSet();
private static final Map<ResourceLocation, ResourceLocation> aliases = Maps.newHashMap();
private static IResourceManager manager;
// Forge built-in loaders
@@ -95,7 +97,10 @@ public class ModelLoaderRegistry
public static IModel getModel(ResourceLocation location) throws Exception
{
IModel model;
if(cache.containsKey(location)) return cache.get(location);
IModel cached = cache.get(location);
if (cached != null) return cached;
for(ResourceLocation loading : loadingModels)
{
if(location.getClass() == loading.getClass() && location.equals(loading))
@@ -106,6 +111,9 @@ public class ModelLoaderRegistry
loadingModels.addLast(location);
try
{
ResourceLocation aliased = aliases.get(location);
if (aliased != null) return getModel(aliased);
ResourceLocation actual = getActualLocation(location);
ICustomModelLoader accepted = null;
for(ICustomModelLoader loader : loaders)
@@ -227,9 +235,16 @@ public class ModelLoaderRegistry
return model;
}
static void addAlias(ResourceLocation from, ResourceLocation to)
{
aliases.put(from, to);
}
public static void clearModelCache(IResourceManager manager)
{
ModelLoaderRegistry.manager = manager;
aliases.clear();
textures.clear();
cache.clear();
// putting the builtin models in
cache.put(new ResourceLocation("minecraft:builtin/generated"), ItemLayerModel.INSTANCE);