Fix bucket replacement not loading the bucket model by itself if replacing buckets.

This happens when no other mod that uses the bucket model is present.
Also added a simple method for registering the bucket model, should give
modders an idea on how to use the general model.
This commit is contained in:
Bernhard Bonigl 2015-12-29 13:20:36 +01:00
parent 7f52bc6547
commit 509cc79112
2 changed files with 25 additions and 10 deletions

View File

@ -213,6 +213,14 @@ public class ModelLoader extends ModelBakery
// 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
ModelResourceLocation memory = getInventoryVariant("forge:dynbucket");
registerVariant(getModelBlockDefinition(memory), memory);
}
// empty bucket
for(String s : getVariantNames(Items.bucket))
{
@ -269,9 +277,12 @@ public class ModelLoader extends ModelBakery
{
ModelResourceLocation memory = getInventoryVariant(s);
IModel model = stateModels.get(ModelDynBucket.LOCATION);
if(model != null)
{
stateModels.put(memory, model);
}
}
}
public static ModelResourceLocation getInventoryVariant(String s)
{
@ -902,6 +913,18 @@ public class ModelLoader extends ModelBakery
customMeshDefinitions.put(item.delegate, meshDefinition);
}
public static void setBucketModelDefinition(Item item) {
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
{
@Override
public ModelResourceLocation getModelLocation(ItemStack stack)
{
return ModelDynBucket.LOCATION;
}
});
ModelBakery.registerItemVariants(item, ModelDynBucket.LOCATION);
}
public static void onRegisterItems(ItemModelMesher mesher)
{
for (Map.Entry<RegistryDelegate<Item>, ItemMeshDefinition> e : customMeshDefinitions.entrySet())

View File

@ -47,15 +47,7 @@ public class DynBucketTest
@Override
void setupModels()
{
ModelLoader.setCustomMeshDefinition(dynBucket, new ItemMeshDefinition()
{
@Override
public ModelResourceLocation getModelLocation(ItemStack stack)
{
return ModelDynBucket.LOCATION;
}
});
ModelBakery.registerItemVariants(dynBucket, new ResourceLocation("forge", "dynbucket"));
ModelLoader.setBucketModelDefinition(dynBucket);
final ModelResourceLocation bottle = new ModelResourceLocation(new ResourceLocation("forge", "dynbottle"), "inventory");
ModelLoader.setCustomMeshDefinition(dynBottle, new ItemMeshDefinition()