use of net.minecraftforge.fml.common.ProgressManager.ProgressBar in project MinecraftForge by MinecraftForge.
the class ModelLoader method loadItemModels.
@Override
protected void loadItemModels() {
// register model for the universal bucket, if it exists
if (FluidRegistry.isUniversalBucketEnabled()) {
setBucketModelDefinition(ForgeModContainer.getInstance().universalBucket);
}
registerVariantNames();
List<Item> items = Lists.newArrayList(Iterables.filter(Item.REGISTRY, new Predicate<Item>() {
public boolean apply(Item item) {
return item.getRegistryName() != null;
}
}));
Collections.sort(items, new Comparator<Item>() {
public int compare(Item i1, Item i2) {
return i1.getRegistryName().toString().compareTo(i2.getRegistryName().toString());
}
});
ProgressBar itemBar = ProgressManager.push("ModelLoader: items", items.size());
for (Item item : items) {
itemBar.step(item.getRegistryName().toString());
for (String s : getVariantNames(item)) {
ResourceLocation file = getItemLocation(s);
ModelResourceLocation memory = getInventoryVariant(s);
IModel model = ModelLoaderRegistry.getMissingModel();
Exception exception = null;
try {
model = ModelLoaderRegistry.getModel(file);
} catch (Exception normalException) {
// try blockstate json if the item model is missing
FMLLog.fine("Item json isn't found for '" + memory + "', trying to load the variant from the blockstate json");
try {
model = ModelLoaderRegistry.getModel(memory);
} catch (Exception blockstateException) {
exception = new ItemLoadingException("Could not load item model either from the normal location " + file + " or from the blockstate", normalException, blockstateException);
}
}
if (exception != null) {
storeException(memory, exception);
model = ModelLoaderRegistry.getMissingModel(memory, exception);
}
stateModels.put(memory, model);
}
}
ProgressManager.pop(itemBar);
// replace vanilla bucket models if desired. done afterwards for performance reasons
if (ForgeModContainer.replaceVanillaBucketModel) {
// ensure the bucket model is loaded
if (!stateModels.containsKey(ModelDynBucket.LOCATION)) {
// load forges blockstate json for it
try {
registerVariant(getModelBlockDefinition(ModelDynBucket.LOCATION), ModelDynBucket.LOCATION);
} catch (Exception exception) {
FMLLog.getLogger().error("Could not load the forge bucket model from the blockstate", exception);
return;
}
}
// empty bucket
for (String s : getVariantNames(Items.BUCKET)) {
ModelResourceLocation memory = getInventoryVariant(s);
IModel model = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation(ForgeVersion.MOD_ID, "item/bucket"));
// only on successful load, otherwise continue using the old model
if (model != getMissingModel()) {
stateModels.put(memory, model);
}
}
setBucketModel(Items.WATER_BUCKET);
setBucketModel(Items.LAVA_BUCKET);
// milk bucket only replaced if some mod adds milk
if (FluidRegistry.isFluidRegistered("milk")) {
// can the milk be put into a bucket?
Fluid milk = FluidRegistry.getFluid("milk");
FluidStack milkStack = new FluidStack(milk, Fluid.BUCKET_VOLUME);
IFluidHandler bucketHandler = FluidUtil.getFluidHandler(new ItemStack(Items.BUCKET));
if (bucketHandler != null && bucketHandler.fill(milkStack, false) == Fluid.BUCKET_VOLUME) {
setBucketModel(Items.MILK_BUCKET);
}
} else {
// milk bucket if no milk fluid is present
for (String s : getVariantNames(Items.MILK_BUCKET)) {
ModelResourceLocation memory = getInventoryVariant(s);
IModel model = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation(ForgeVersion.MOD_ID, "item/bucket_milk"));
// only on successful load, otherwise continue using the old model
if (model != getMissingModel()) {
stateModels.put(memory, model);
}
}
}
}
}
use of net.minecraftforge.fml.common.ProgressManager.ProgressBar 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;
}
use of net.minecraftforge.fml.common.ProgressManager.ProgressBar in project MinecraftForge by MinecraftForge.
the class LoadController method propogateStateMessage.
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent) {
if (stateEvent instanceof FMLPreInitializationEvent) {
modObjectList = buildModObjectList();
}
ProgressBar bar = ProgressManager.push(stateEvent.description(), activeModList.size(), true);
for (ModContainer mc : activeModList) {
bar.step(mc.getName());
sendEventToModContainer(stateEvent, mc);
}
ProgressManager.pop(bar);
}
use of net.minecraftforge.fml.common.ProgressManager.ProgressBar in project BiomeTweaker by superckl.
the class BiomeTweaker method onPostInit.
@EventHandler
public void onPostInit(final FMLPostInitializationEvent e) {
final ProgressBar bar = ProgressManager.push("BiomeTweaker PostInitialization", 2, true);
bar.step("Post-Initializing Integration");
IntegrationManager.INSTANCE.postInit();
bar.step("Applying scripts");
this.commandManager.applyCommandsFor(ApplicationStage.POST_INIT);
ProgressManager.pop(bar);
}
use of net.minecraftforge.fml.common.ProgressManager.ProgressBar in project BiomeTweaker by superckl.
the class BiomeTweaker method onInit.
@EventHandler
public void onInit(final FMLInitializationEvent e) throws InterruptedException {
final ProgressBar bar = ProgressManager.push("BiomeTweaker Initialization", 2, true);
bar.step("Initializing Integration");
IntegrationManager.INSTANCE.init();
bar.step("Applying scripts");
this.commandManager.applyCommandsFor(ApplicationStage.INIT);
ProgressManager.pop(bar);
}
Aggregations