Search in sources :

Example 1 with EnumBeeType

use of forestry.api.apiculture.EnumBeeType in project Railcraft by Railcraft.

the class FilterBeesGenomeRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting grid) {
    if (!matches(grid, null))
        return InvTools.emptyStack();
    InventoryComposite inv = InventoryComposite.of(grid);
    ItemStack filter = grid.getStackInRowAndColumn(1, 1);
    ItemStack type = grid.getStackInRowAndColumn(1, 0);
    ItemStack active = grid.getStackInRowAndColumn(0, 1);
    ItemStack inactive = grid.getStackInRowAndColumn(2, 1);
    if (InvTools.isEmpty(filter))
        return InvTools.emptyStack();
    try {
        EnumBeeType beeType = BeeManager.beeRoot.getType(type);
        String typeName = "";
        if (beeType != null)
            typeName = beeType.name();
        return ItemFilterBeeGenome.setBeeFilter(filter, typeName, active, inactive);
    } catch (Throwable error) {
        Game.logErrorAPI(Mod.FORESTRY.modId, error, BeeManager.class);
        return InvTools.emptyStack();
    }
}
Also used : InventoryComposite(mods.railcraft.common.util.inventory.wrappers.InventoryComposite) ItemStack(net.minecraft.item.ItemStack) BeeManager(forestry.api.apiculture.BeeManager) EnumBeeType(forestry.api.apiculture.EnumBeeType)

Example 2 with EnumBeeType

use of forestry.api.apiculture.EnumBeeType in project Railcraft by Railcraft.

the class ItemFilterBeeGenome method getBeeFilter.

@Nullable
public static BeeFilter getBeeFilter(ItemStack stack) {
    NBTTagCompound nbt = InvTools.getItemDataRailcraft(stack, "filter");
    if (nbt != null) {
        try {
            String typeName = nbt.getString("type");
            EnumBeeType type = null;
            try {
                type = EnumBeeType.valueOf(typeName);
            } catch (IllegalArgumentException ignored) {
            }
            EnumBeeChromosome chromosome = EnumBeeChromosome.SPECIES;
            try {
                chromosome = EnumBeeChromosome.valueOf(nbt.getString("chromosome"));
            } catch (IllegalArgumentException ignored) {
            }
            ItemStack active = NBTPlugin.readItemStack(nbt, "active");
            ItemStack inactive = NBTPlugin.readItemStack(nbt, "inactive");
            return new BeeFilter(type, chromosome, active, inactive);
        } catch (Throwable ignored) {
        }
    }
    return new BeeFilter(null, EnumBeeChromosome.SPECIES, null, null);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) EnumBeeType(forestry.api.apiculture.EnumBeeType) EnumBeeChromosome(forestry.api.apiculture.EnumBeeChromosome) Nullable(javax.annotation.Nullable)

Aggregations

EnumBeeType (forestry.api.apiculture.EnumBeeType)2 ItemStack (net.minecraft.item.ItemStack)2 BeeManager (forestry.api.apiculture.BeeManager)1 EnumBeeChromosome (forestry.api.apiculture.EnumBeeChromosome)1 Nullable (javax.annotation.Nullable)1 InventoryComposite (mods.railcraft.common.util.inventory.wrappers.InventoryComposite)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1