Search in sources :

Example 1 with RegFood

use of cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegFood in project FoodCraft-Reloaded by LasmGratel.

the class PropertiedFoodLoader method registerOreDict.

@Load(LoaderState.AVAILABLE)
public void registerOreDict() {
    for (Field field : FCRFoods.class.getFields()) {
        field.setAccessible(true);
        try {
            RegFood anno = field.getDeclaredAnnotation(RegFood.class);
            if (anno == null) {
                continue;
            }
            ItemPFood item = (ItemPFood) field.get(null);
            Arrays.asList(anno.oreDict()).forEach(s -> OreDictionary.registerOre(s, item));
            OreDictionary.registerOre("listAllfoods", item);
        } catch (IllegalAccessException | NullPointerException e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register food " + field.toGenericString(), e);
        }
    }
}
Also used : Field(java.lang.reflect.Field) ItemPFood(cc.lasmgratel.foodcraftreloaded.minecraft.common.item.food.ItemPFood) RegFood(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegFood) Load(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load)

Aggregations

ItemPFood (cc.lasmgratel.foodcraftreloaded.minecraft.common.item.food.ItemPFood)1 Load (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load)1 RegFood (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegFood)1 Field (java.lang.reflect.Field)1