Java Code Examples for net.minecraftforge.common.IPlantable#getPlantMetadata()

The following examples show how to use net.minecraftforge.common.IPlantable#getPlantMetadata() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlantItem.java    From GardenCollection with MIT License 6 votes vote down vote up
public static PlantItem getForItem (IBlockAccess blockAccess, ItemStack itemStack) {
    if (itemStack == null || itemStack.getItem() == null)
        return null;

    IPlantable plantable = PlantRegistry.getPlantable(itemStack);
    if (plantable == null)
        return getForItem(itemStack);

    Block block = plantable.getPlant(blockAccess, 0, -1, 0);
    if (block == null)
        return getForItem(itemStack);

    int meta = plantable.getPlantMetadata(blockAccess, 0, -1, 0);
    if (meta == 0)
        meta = itemStack.getItemDamage();

    return new PlantItem(itemStack, block, meta);
}
 
Example 2
Source File: PlantUtil.java    From GardenCollection with MIT License 5 votes vote down vote up
private static int getPlantMetadata (IBlockAccess world, int x, int y, int z, IPlantable plant, int defaultMeta) {
    if (plant == null)
        return 0;

    Block itemBlock = plant.getPlant(world, x, y, z);
    int itemMeta = defaultMeta;

    if (itemBlock != null) {
        int plantMeta = plant.getPlantMetadata(world, x, y, z);
        if (plantMeta > 0)
            itemMeta = plantMeta;
    }

    return itemMeta;
}
 
Example 3
Source File: PlantRegistry.java    From GardenCollection with MIT License 4 votes vote down vote up
public IPlantInfo getPlantInfo (IBlockAccess world, IPlantable plant) {
    Block block = plant.getPlant(world, 0, 0, 0);
    int meta = plant.getPlantMetadata(world, 0, 0, 0);

    return  getPlantInfo(block, meta);
}