Fixed missing model error reporting, made block and item variants sort before loading, to make the splash screen info more useful.
This commit is contained in:
parent
90d1abebd4
commit
accf6cf218
2 changed files with 78 additions and 63 deletions
|
@ -9,15 +9,7 @@
|
|||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
@@ -160,6 +160,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+ catch (FileNotFoundException e) {}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
throw new RuntimeException("Encountered an exception when loading model definition of model " + resourcelocation.toString(), ioexception);
|
||||
@@ -294,6 +295,7 @@
|
||||
@@ -294,6 +294,7 @@
|
||||
|
||||
protected void func_177592_e()
|
||||
{
|
||||
|
@ -25,7 +17,7 @@
|
|||
this.field_177613_u.put(Item.func_150898_a(Blocks.field_150348_b), Lists.newArrayList(new String[] {"stone", "granite", "granite_smooth", "diorite", "diorite_smooth", "andesite", "andesite_smooth"}));
|
||||
this.field_177613_u.put(Item.func_150898_a(Blocks.field_150346_d), Lists.newArrayList(new String[] {"dirt", "coarse_dirt", "podzol"}));
|
||||
this.field_177613_u.put(Item.func_150898_a(Blocks.field_150344_f), Lists.newArrayList(new String[] {"oak_planks", "spruce_planks", "birch_planks", "jungle_planks", "acacia_planks", "dark_oak_planks"}));
|
||||
@@ -336,6 +338,10 @@
|
||||
@@ -336,6 +337,10 @@
|
||||
this.field_177613_u.put(Item.func_150898_a(Blocks.field_180390_bo), Lists.newArrayList(new String[] {"oak_fence_gate"}));
|
||||
this.field_177613_u.put(Item.func_150898_a(Blocks.field_180407_aO), Lists.newArrayList(new String[] {"oak_fence"}));
|
||||
this.field_177613_u.put(Items.field_179570_aq, Lists.newArrayList(new String[] {"oak_door"}));
|
||||
|
@ -36,7 +28,7 @@
|
|||
}
|
||||
|
||||
protected List<String> func_177596_a(Item p_177596_1_)
|
||||
@@ -352,7 +358,7 @@
|
||||
@@ -352,7 +357,7 @@
|
||||
|
||||
protected ResourceLocation func_177583_a(String p_177583_1_)
|
||||
{
|
||||
|
@ -45,7 +37,7 @@
|
|||
return new ResourceLocation(resourcelocation.func_110624_b(), "item/" + resourcelocation.func_110623_a());
|
||||
}
|
||||
|
||||
@@ -395,7 +401,7 @@
|
||||
@@ -395,7 +400,7 @@
|
||||
for (Entry<String, ResourceLocation> entry : this.field_177615_s.entrySet())
|
||||
{
|
||||
ResourceLocation resourcelocation = (ResourceLocation)entry.getValue();
|
||||
|
@ -54,7 +46,7 @@
|
|||
ModelBlock modelblock1 = (ModelBlock)this.field_177611_h.get(resourcelocation);
|
||||
|
||||
if (modelblock1 != null && modelblock1.func_178303_d())
|
||||
@@ -453,6 +459,11 @@
|
||||
@@ -453,6 +458,11 @@
|
||||
|
||||
private IBakedModel func_177578_a(ModelBlock p_177578_1_, ModelRotation p_177578_2_, boolean p_177578_3_)
|
||||
{
|
||||
|
@ -66,7 +58,7 @@
|
|||
TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.field_177599_g.get(new ResourceLocation(p_177578_1_.func_178308_c("particle")));
|
||||
SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(p_177578_1_)).func_177646_a(textureatlassprite);
|
||||
|
||||
@@ -463,13 +474,13 @@
|
||||
@@ -463,13 +473,13 @@
|
||||
BlockPartFace blockpartface = (BlockPartFace)blockpart.field_178240_c.get(enumfacing);
|
||||
TextureAtlasSprite textureatlassprite1 = (TextureAtlasSprite)this.field_177599_g.get(new ResourceLocation(p_177578_1_.func_178308_c(blockpartface.field_178242_d)));
|
||||
|
||||
|
@ -83,7 +75,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -479,9 +490,14 @@
|
||||
@@ -479,9 +489,14 @@
|
||||
|
||||
private BakedQuad func_177589_a(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, ModelRotation p_177589_5_, boolean p_177589_6_)
|
||||
{
|
||||
|
@ -99,7 +91,7 @@
|
|||
private void func_177597_h()
|
||||
{
|
||||
this.func_177574_i();
|
||||
@@ -722,4 +738,35 @@
|
||||
@@ -722,4 +737,35 @@
|
||||
field_177617_q.field_178317_b = "class generation marker";
|
||||
field_177616_r.field_178317_b = "block entity marker";
|
||||
}
|
||||
|
|
|
@ -3,13 +3,12 @@ package net.minecraftforge.client.model;
|
|||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -78,10 +77,11 @@ import com.google.common.collect.Sets;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class ModelLoader extends ModelBakery
|
||||
{
|
||||
private final Map<ModelResourceLocation, IModel> stateModels = new HashMap<ModelResourceLocation, IModel>();
|
||||
private final Set<ResourceLocation> textures = new HashSet<ResourceLocation>();
|
||||
private final Set<ResourceLocation> loadingModels = new HashSet<ResourceLocation>();
|
||||
private final Map<ModelResourceLocation, IModel> stateModels = Maps.newHashMap();
|
||||
private final Set<ResourceLocation> textures = Sets.newHashSet();
|
||||
private final Set<ResourceLocation> loadingModels = Sets.newHashSet();
|
||||
private final Set<ModelResourceLocation> missingVariants = Sets.newHashSet();
|
||||
private final Map<ModelResourceLocation, Exception> loadingExceptions = Maps.newHashMap();
|
||||
private IModel missingModel = null;
|
||||
private IModel itemModel = new ItemLayerModel(MODEL_GENERATED);
|
||||
|
||||
|
@ -151,28 +151,31 @@ public class ModelLoader extends ModelBakery
|
|||
return bakedRegistry;
|
||||
}
|
||||
|
||||
private ArrayDeque<ModelResourceLocation> loadingBlockModels = new ArrayDeque<ModelResourceLocation>();
|
||||
|
||||
private void loadBlocks()
|
||||
{
|
||||
Map<IBlockState, ModelResourceLocation> stateMap = blockModelShapes.getBlockStateMapper().putAllStateModelLocations();
|
||||
Collection<ModelResourceLocation> variants = Lists.newArrayList(stateMap.values());
|
||||
List<ModelResourceLocation> variants = Lists.newArrayList(stateMap.values());
|
||||
variants.add(new ModelResourceLocation("minecraft:item_frame", "normal")); //Vanilla special cases item_frames so must we
|
||||
variants.add(new ModelResourceLocation("minecraft:item_frame", "map"));
|
||||
Collections.sort(variants, new Comparator<ModelResourceLocation>()
|
||||
{
|
||||
public int compare(ModelResourceLocation v1, ModelResourceLocation v2)
|
||||
{
|
||||
return v1.toString().compareTo(v2.toString());
|
||||
}
|
||||
});
|
||||
blockBar = ProgressManager.push("ModelLoader: blocks", variants.size());
|
||||
loadingBlockModels.addAll(variants);
|
||||
loadVariants(variants);
|
||||
for(ModelResourceLocation variant : variants)
|
||||
{
|
||||
loadVariants(ImmutableList.of(variant));
|
||||
blockBar.step(variant.toString());
|
||||
}
|
||||
ProgressManager.pop(blockBar);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerVariant(ModelBlockDefinition definition, ModelResourceLocation location)
|
||||
{
|
||||
if(!loadingBlockModels.isEmpty() && loadingBlockModels.peekFirst() == location)
|
||||
{
|
||||
blockBar.step(location.toString());
|
||||
loadingBlockModels.removeFirst();
|
||||
}
|
||||
Variants variants = null;
|
||||
try
|
||||
{
|
||||
|
@ -195,20 +198,22 @@ public class ModelLoader extends ModelBakery
|
|||
}
|
||||
}
|
||||
|
||||
private void storeException(ModelResourceLocation location, Exception exception)
|
||||
{
|
||||
loadingExceptions.put(location, exception);
|
||||
}
|
||||
|
||||
private void loadItems()
|
||||
{
|
||||
registerVariantNames();
|
||||
int size = 0;
|
||||
ImmutableList<Item> items = ImmutableList.copyOf(GameData.getItemRegistry().typeSafeIterable());
|
||||
for(Item item : items)
|
||||
List<String> itemVariants = Lists.newArrayList();
|
||||
for(Item item : GameData.getItemRegistry().typeSafeIterable())
|
||||
{
|
||||
size += getVariantNames(item).size();
|
||||
itemVariants.addAll(getVariantNames(item));
|
||||
}
|
||||
itemBar = ProgressManager.push("ModelLoader: items", size);
|
||||
for(Item item : items)
|
||||
{
|
||||
// default loading
|
||||
for(String s : (List<String>)getVariantNames(item))
|
||||
Collections.sort(itemVariants);
|
||||
itemBar = ProgressManager.push("ModelLoader: items", itemVariants.size());
|
||||
for(String s : itemVariants)
|
||||
{
|
||||
ResourceLocation file = getItemLocation(s);
|
||||
ModelResourceLocation memory = getInventoryVariant(s);
|
||||
|
@ -216,16 +221,17 @@ public class ModelLoader extends ModelBakery
|
|||
IModel model = null;
|
||||
try
|
||||
{
|
||||
// default loading
|
||||
model = getModel(file);
|
||||
if (model == null)
|
||||
{
|
||||
model = getMissingModel();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Handled by our finally block.
|
||||
stateModels.put(memory, model);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (model == null || model == getMissingModel())
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
|
@ -233,11 +239,12 @@ public class ModelLoader extends ModelBakery
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
FMLLog.getLogger().warn("Unable to load definition " + memory, exception);
|
||||
storeException(memory, new Exception("Could not load item model either from the normal location " + file + " or from the blockstate", exception));
|
||||
}
|
||||
}
|
||||
else stateModels.put(memory, model);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
storeException(memory, exception);
|
||||
}
|
||||
}
|
||||
ProgressManager.pop(itemBar);
|
||||
|
@ -850,6 +857,18 @@ public class ModelLoader extends ModelBakery
|
|||
public void onPostBakeEvent(IRegistry<ModelResourceLocation, IBakedModel> modelRegistry)
|
||||
{
|
||||
IBakedModel missingModel = modelRegistry.getObject(MODEL_MISSING);
|
||||
for(Map.Entry<ModelResourceLocation, Exception> entry : loadingExceptions.entrySet())
|
||||
{
|
||||
IBakedModel model = modelRegistry.getObject(entry.getKey());
|
||||
if(model == null || model == missingModel)
|
||||
{
|
||||
FMLLog.getLogger().error("Exception loading model for variant " + entry.getKey(), entry.getValue());
|
||||
}
|
||||
if(model == null)
|
||||
{
|
||||
modelRegistry.putObject(entry.getKey(), missingModel);
|
||||
}
|
||||
}
|
||||
for(ModelResourceLocation missing : missingVariants)
|
||||
{
|
||||
IBakedModel model = modelRegistry.getObject(missing);
|
||||
|
@ -857,6 +876,10 @@ public class ModelLoader extends ModelBakery
|
|||
{
|
||||
FMLLog.severe("Model definition for location %s not found", missing);
|
||||
}
|
||||
if(model == null)
|
||||
{
|
||||
modelRegistry.putObject(missing, missingModel);
|
||||
}
|
||||
}
|
||||
isLoading = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue