use of net.minecraft.client.renderer.texture.ITextureMapPopulator in project MinecraftForge by MinecraftForge.
the class ModelLoader method setupModelRegistry.
@Override
public IRegistry<ModelResourceLocation, IBakedModel> setupModelRegistry() {
isLoading = true;
loadBlocks();
loadVariantItemModels();
missingModel = ModelLoaderRegistry.getMissingModel();
stateModels.put(MODEL_MISSING, missingModel);
final Set<ResourceLocation> textures = Sets.newHashSet(ModelLoaderRegistry.getTextures());
textures.remove(TextureMap.LOCATION_MISSING_TEXTURE);
textures.addAll(LOCATIONS_BUILTIN_TEXTURES);
textureMap.loadSprites(resourceManager, new ITextureMapPopulator() {
public void registerSprites(TextureMap map) {
for (ResourceLocation t : textures) {
map.registerSprite(t);
}
}
});
IBakedModel missingBaked = missingModel.bake(missingModel.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE);
Map<IModel, IBakedModel> bakedModels = Maps.newHashMap();
HashMultimap<IModel, ModelResourceLocation> models = HashMultimap.create();
Multimaps.invertFrom(Multimaps.forMap(stateModels), models);
if (firstLoad) {
firstLoad = false;
for (ModelResourceLocation mrl : stateModels.keySet()) {
bakedRegistry.putObject(mrl, missingBaked);
}
return bakedRegistry;
}
ProgressBar bakeBar = ProgressManager.push("ModelLoader: baking", models.keySet().size());
for (IModel model : models.keySet()) {
bakeBar.step("[" + Joiner.on(", ").join(models.get(model)) + "]");
if (model == getMissingModel()) {
bakedModels.put(model, missingBaked);
} else {
bakedModels.put(model, model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE));
}
}
ProgressManager.pop(bakeBar);
for (Entry<ModelResourceLocation, IModel> e : stateModels.entrySet()) {
bakedRegistry.putObject(e.getKey(), bakedModels.get(e.getValue()));
}
return bakedRegistry;
}
Aggregations