public IModel getMissingModel() { if (missingModel == null) { try { missingModel = getModel( new ResourceLocation( MODEL_MISSING.getResourceDomain(), MODEL_MISSING.getResourcePath())); } catch (IOException e) { // If this ever happens things are bad. Should never NOT be able to load the missing model. Throwables.propagate(e); } } return missingModel; }
@Override public IRegistry<ModelResourceLocation, IBakedModel> setupModelRegistry() { isLoading = true; loadBlocks(); loadItems(); try { missingModel = getModel( new ResourceLocation( MODEL_MISSING.getResourceDomain(), MODEL_MISSING.getResourcePath())); } catch (IOException e) { // If this ever happens things are bad. Should never NOT be able to load the missing model. Throwables.propagate(e); } stateModels.put(MODEL_MISSING, missingModel); textures.remove(TextureMap.LOCATION_MISSING_TEXTURE); textures.addAll(LOCATIONS_BUILTIN_TEXTURES); textureMap.loadSprites( resourceManager, new IIconCreator() { public void registerSprites(TextureMap map) { for (ResourceLocation t : textures) { map.registerSprite(t); } } }); Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() { public TextureAtlasSprite apply(ResourceLocation location) { return Minecraft.getMinecraft() .getTextureMapBlocks() .getAtlasSprite(location.toString()); } }; IFlexibleBakedModel missingBaked = missingModel.bake(missingModel.getDefaultState(), DefaultVertexFormats.ITEM, textureGetter); for (Entry<ModelResourceLocation, IModel> e : stateModels.entrySet()) { if (e.getValue() == getMissingModel()) { bakedRegistry.putObject(e.getKey(), missingBaked); } else { bakedRegistry.putObject( e.getKey(), e.getValue() .bake(e.getValue().getDefaultState(), DefaultVertexFormats.ITEM, textureGetter)); } } return bakedRegistry; }