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:
parent
7f52bc6547
commit
509cc79112
|
@ -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,7 +277,10 @@ public class ModelLoader extends ModelBakery
|
|||
{
|
||||
ModelResourceLocation memory = getInventoryVariant(s);
|
||||
IModel model = stateModels.get(ModelDynBucket.LOCATION);
|
||||
stateModels.put(memory, model);
|
||||
if(model != null)
|
||||
{
|
||||
stateModels.put(memory, model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue