| 45 | import static net.minecraftforge.fml.Logging.MODELLOADING; |
| 46 | |
| 47 | public final class ModelLoader extends ModelBakery |
| 48 | { |
| 49 | private static final Logger LOGGER = LogManager.getLogger(); |
| 50 | private final Map<ResourceLocation, Exception> loadingExceptions = Maps.newHashMap(); |
| 51 | private IUnbakedModel missingModel = null; |
| 52 | |
| 53 | private boolean isLoading = false; |
| 54 | |
| 55 | private static ModelLoader instance; |
| 56 | |
| 57 | @Nullable |
| 58 | public static ModelLoader instance() |
| 59 | { |
| 60 | return instance; |
| 61 | } |
| 62 | |
| 63 | public boolean isLoading() |
| 64 | { |
| 65 | return isLoading; |
| 66 | } |
| 67 | |
| 68 | public ModelLoader(IResourceManager manager, BlockColors colours, IProfiler profiler, int maxMipmapLevel) |
| 69 | { |
| 70 | super(manager, colours, false); |
| 71 | instance = this; |
| 72 | processLoading(profiler, maxMipmapLevel); |
| 73 | } |
| 74 | |
| 75 | private static Set<ResourceLocation> specialModels = new HashSet<>(); |
| 76 | |
| 77 | /** |
| 78 | * Indicate to vanilla that it should load and bake the given model, even if no blocks or |
| 79 | * items use it. This is useful if e.g. you have baked models only for entity renderers. |
| 80 | * Call during {@link net.minecraftforge.client.event.ModelRegistryEvent} |
| 81 | * @param rl The model, either {@link ModelResourceLocation} to point to a blockstate variant, |
| 82 | * or plain {@link ResourceLocation} to point directly to a json in the models folder. |
| 83 | */ |
| 84 | public static void addSpecialModel(ResourceLocation rl) { |
| 85 | specialModels.add(rl); |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public Set<ResourceLocation> getSpecialModels() { |
| 90 | return specialModels; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Hooked from ModelBakery, allows using MRLs that don't end with "inventory" for items. |
| 95 | */ |
| 96 | public static ModelResourceLocation getInventoryVariant(String s) |
| 97 | { |
| 98 | if(s.contains("#")) |
| 99 | { |
| 100 | return new ModelResourceLocation(s); |
| 101 | } |
| 102 | return new ModelResourceLocation(s, "inventory"); |
| 103 | } |
| 104 |
nothing calls this directly
no test coverage detected