Search in sources :

Example 11 with IIndividual

use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.

the class FilterLogic method isValid.

public boolean isValid(EnumFacing facing, ItemStack itemStack, IFilterData filterData) {
    IFilterRuleType rule = getRule(facing);
    if (rule == DefaultFilterRuleType.CLOSED) {
        return false;
    }
    if (rule == DefaultFilterRuleType.ITEM && !filterData.isPresent()) {
        return true;
    }
    String requiredRoot = rule.getRootUID();
    if (requiredRoot != null && (!filterData.isPresent() || !filterData.getRoot().getUID().equals(requiredRoot))) {
        return false;
    }
    if (rule == DefaultFilterRuleType.ANYTHING || rule.isValid(itemStack, filterData)) {
        if (filterData.isPresent()) {
            IIndividual ind = filterData.getIndividual();
            IGenome genome = ind.getGenome();
            IAllele active = genome.getPrimary();
            IAllele inactive = genome.getSecondary();
            if (!isValidAllelePair(facing, active.getUID(), inactive.getUID())) {
                return false;
            }
        }
        return true;
    }
    return false;
}
Also used : IAllele(forestry.api.genetics.IAllele) IFilterRuleType(forestry.api.genetics.IFilterRuleType) IGenome(forestry.api.genetics.IGenome) IIndividual(forestry.api.genetics.IIndividual)

Example 12 with IIndividual

use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.

the class EscritoireGameBoard method initialize.

public boolean initialize(ItemStack specimen) {
    IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen);
    if (individual == null) {
        return false;
    }
    IGenome genome = individual.getGenome();
    ISpeciesRoot root = genome.getPrimary().getRoot();
    tokenCount = getTokenCount(genome);
    for (int i = 0; i < tokenCount / 2; i++) {
        IAllele[] randomTemplate = root.getRandomTemplate(rand);
        String speciesUid = randomTemplate[root.getSpeciesChromosomeType().ordinal()].getUID();
        gameTokens.add(new EscritoireGameToken(speciesUid));
        gameTokens.add(new EscritoireGameToken(speciesUid));
    }
    Collections.shuffle(gameTokens);
    return true;
}
Also used : IAllele(forestry.api.genetics.IAllele) IGenome(forestry.api.genetics.IGenome) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual)

Example 13 with IIndividual

use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.

the class TileEscritoire method processTurnResult.

private void processTurnResult(GameProfile gameProfile) {
    if (getGame().getStatus() != EscritoireGame.Status.SUCCESS) {
        return;
    }
    IIndividual individual = AlleleManager.alleleRegistry.getIndividual(getStackInSlot(InventoryEscritoire.SLOT_ANALYZE));
    if (individual == null) {
        return;
    }
    IAlleleSpecies species = individual.getGenome().getPrimary();
    for (ItemStack itemstack : species.getResearchBounty(world, gameProfile, individual, game.getBountyLevel())) {
        InventoryUtil.addStack(getInternalInventory(), itemstack, InventoryEscritoire.SLOT_RESULTS_1, InventoryEscritoire.SLOTS_RESULTS_COUNT, true);
    }
}
Also used : IIndividual(forestry.api.genetics.IIndividual) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ItemStack(net.minecraft.item.ItemStack)

Example 14 with IIndividual

use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.

the class ModuleArboriculture method registerErsatzGenomes.

private static void registerErsatzGenomes() {
    TreeManager.treeRoot.registerTranslator(Blocks.LEAVES, new IBlockTranslator<ITree>() {

        @Nullable
        @Override
        public ITree getIndividualFromObject(IBlockState blockState) {
            if (!blockState.getValue(BlockLeaves.DECAYABLE)) {
                return null;
            }
            switch(blockState.getValue(BlockOldLeaf.VARIANT)) {
                case OAK:
                    return TreeDefinition.Oak.getIndividual();
                case SPRUCE:
                    return TreeDefinition.Spruce.getIndividual();
                case BIRCH:
                    return TreeDefinition.Birch.getIndividual();
                case JUNGLE:
                    return TreeDefinition.Jungle.getIndividual();
            }
            return null;
        }
    });
    TreeManager.treeRoot.registerTranslator(Blocks.LEAVES2, new IBlockTranslator<ITree>() {

        @Nullable
        @Override
        public ITree getIndividualFromObject(IBlockState blockState) {
            if (!blockState.getValue(BlockLeaves.DECAYABLE)) {
                return null;
            }
            switch(blockState.getValue(BlockNewLeaf.VARIANT)) {
                case ACACIA:
                    return TreeDefinition.AcaciaVanilla.getIndividual();
                case DARK_OAK:
                    return TreeDefinition.DarkOak.getIndividual();
            }
            return null;
        }
    });
    TreeManager.treeRoot.registerTranslator(Item.getItemFromBlock(Blocks.SAPLING), new IItemTranslator<ITree>() {

        @Nullable
        @Override
        public ITree getIndividualFromObject(ItemStack itemStack) {
            switch(itemStack.getMetadata()) {
                case 0:
                    return TreeDefinition.Oak.getIndividual();
                case 1:
                    return TreeDefinition.Spruce.getIndividual();
                case 2:
                    return TreeDefinition.Birch.getIndividual();
                case 3:
                    return TreeDefinition.Jungle.getIndividual();
                case 4:
                    return TreeDefinition.AcaciaVanilla.getIndividual();
                case 5:
                    return TreeDefinition.DarkOak.getIndividual();
            }
            return null;
        }
    });
    for (BlockDefaultLeaves leaves : getBlocks().leavesDefault) {
        TreeManager.treeRoot.registerTranslator(leaves, (IBlockTranslator<IIndividual>) blockState -> {
            TreeDefinition treeDefinition = leaves.getTreeDefinition(blockState);
            if (treeDefinition != null) {
                return treeDefinition.getIndividual();
            } else {
                return null;
            }
        });
    }
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) ModelBakeEvent(net.minecraftforge.client.event.ModelBakeEvent) Arrays(java.util.Arrays) ForestryModule(forestry.api.modules.ForestryModule) BlockRegistryArboriculture(forestry.arboriculture.blocks.BlockRegistryArboriculture) NullStorage(forestry.core.capabilities.NullStorage) Item(net.minecraft.item.Item) PacketRegistryArboriculture(forestry.arboriculture.network.PacketRegistryArboriculture) EnumHand(net.minecraft.util.EnumHand) CapabilityManager(net.minecraftforge.common.capabilities.CapabilityManager) IPacketRegistry(forestry.core.network.IPacketRegistry) Random(java.util.Random) TreeDecorator(forestry.arboriculture.worldgen.TreeDecorator) IMCUtil(forestry.core.utils.IMCUtil) ITree(forestry.api.arboriculture.ITree) BlockDefaultLeaves(forestry.arboriculture.blocks.BlockDefaultLeaves) IArmorNaturalist(forestry.api.core.IArmorNaturalist) Config(forestry.core.config.Config) Block(net.minecraft.block.Block) OreDictionary(net.minecraftforge.oredict.OreDictionary) Side(net.minecraftforge.fml.relauncher.Side) BlockArbLog(forestry.arboriculture.blocks.BlockArbLog) WoodTextureManager(forestry.arboriculture.models.WoodTextureManager) SidedProxy(net.minecraftforge.fml.common.SidedProxy) WoodBlockKind(forestry.api.arboriculture.WoodBlockKind) CommandTree(forestry.arboriculture.commands.CommandTree) BlockNewLeaf(net.minecraft.block.BlockNewLeaf) IBlockTranslator(forestry.api.genetics.IBlockTranslator) BlockEvent(net.minecraftforge.event.world.BlockEvent) AlleleFruits(forestry.arboriculture.genetics.alleles.AlleleFruits) RecipeUtil(forestry.core.recipes.RecipeUtil) Set(java.util.Set) TreeRoot(forestry.arboriculture.genetics.TreeRoot) BlockLeaves(net.minecraft.block.BlockLeaves) List(java.util.List) ArmorNaturalist(forestry.arboriculture.capabilities.ArmorNaturalist) ItemStackUtil(forestry.core.utils.ItemStackUtil) BlankForestryModule(forestry.modules.BlankForestryModule) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Entry(java.util.Map.Entry) EnumVanillaWoodType(forestry.api.arboriculture.EnumVanillaWoodType) TileFruitPod(forestry.arboriculture.tiles.TileFruitPod) IIndividual(forestry.api.genetics.IIndividual) BlockForestryLeaves(forestry.arboriculture.blocks.BlockForestryLeaves) ItemRegistryArboriculture(forestry.arboriculture.items.ItemRegistryArboriculture) ItemRegistryCore(forestry.core.items.ItemRegistryCore) Blocks(net.minecraft.init.Blocks) RecipeManagers(forestry.api.recipes.RecipeManagers) ProxyArboriculture(forestry.arboriculture.proxy.ProxyArboriculture) VillagerTradeLists(forestry.core.utils.VillagerTradeLists) TileSapling(forestry.arboriculture.tiles.TileSapling) GameRegistry(net.minecraftforge.fml.common.registry.GameRegistry) TreeMutationFactory(forestry.arboriculture.genetics.TreeMutationFactory) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) ProxyArboricultureClient(forestry.arboriculture.proxy.ProxyArboricultureClient) TextureManagerForestry(forestry.core.render.TextureManagerForestry) IItemTranslator(forestry.api.genetics.IItemTranslator) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) EnumForestryWoodType(forestry.api.arboriculture.EnumForestryWoodType) Nullable(javax.annotation.Nullable) IMCMessage(net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage) ICrateRegistry(forestry.api.storage.ICrateRegistry) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit) TreeFactory(forestry.arboriculture.genetics.TreeFactory) ItemGrafter(forestry.arboriculture.items.ItemGrafter) EnumFruit(forestry.core.items.ItemFruit.EnumFruit) TileLeaves(forestry.arboriculture.tiles.TileLeaves) StorageManager(forestry.api.storage.StorageManager) Items(net.minecraft.init.Items) World(net.minecraft.world.World) ForestryModuleUids(forestry.modules.ForestryModuleUids) TreeManager(forestry.api.arboriculture.TreeManager) AlleleLeafEffects(forestry.arboriculture.genetics.alleles.AlleleLeafEffects) BlockOldLeaf(net.minecraft.block.BlockOldLeaf) ModuleCore(forestry.core.ModuleCore) TreekeepingMode(forestry.arboriculture.genetics.TreekeepingMode) IBlockState(net.minecraft.block.state.IBlockState) MinecraftForge(net.minecraftforge.common.MinecraftForge) Fluids(forestry.core.fluids.Fluids) ForestryAPI(forestry.api.core.ForestryAPI) Constants(forestry.core.config.Constants) ModuleManager(forestry.modules.ModuleManager) AlleleManager(forestry.api.genetics.AlleleManager) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) Preconditions(com.google.common.base.Preconditions) VillagerRegistry(net.minecraftforge.fml.common.registry.VillagerRegistry) EnumGermlingType(forestry.api.arboriculture.EnumGermlingType) TreeDefinition(forestry.arboriculture.genetics.TreeDefinition) TreeBranchDefinition(forestry.arboriculture.genetics.TreeBranchDefinition) Collections(java.util.Collections) EntityVillager(net.minecraft.entity.passive.EntityVillager) TextureLeaves(forestry.arboriculture.models.TextureLeaves) IBlockState(net.minecraft.block.state.IBlockState) IIndividual(forestry.api.genetics.IIndividual) ITree(forestry.api.arboriculture.ITree) TreeDefinition(forestry.arboriculture.genetics.TreeDefinition) ItemStack(net.minecraft.item.ItemStack) Nullable(javax.annotation.Nullable) BlockDefaultLeaves(forestry.arboriculture.blocks.BlockDefaultLeaves)

Example 15 with IIndividual

use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.

the class GuiAlyzer method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
    widgetManager.clear();
    int specimenSlot = getSpecimenSlot();
    if (specimenSlot < ItemInventoryAlyzer.SLOT_ANALYZE_1) {
        drawAnalyticsOverview();
        return;
    }
    ItemStack stackInSlot = itemInventory.getStackInSlot(specimenSlot);
    ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(stackInSlot);
    if (speciesRoot == null) {
        return;
    }
    switch(specimenSlot) {
        case ItemInventoryAlyzer.SLOT_ANALYZE_1:
            {
                speciesRoot.getAlyzerPlugin().drawAnalyticsPage1(this, stackInSlot);
                break;
            }
        case ItemInventoryAlyzer.SLOT_ANALYZE_2:
            {
                speciesRoot.getAlyzerPlugin().drawAnalyticsPage2(this, stackInSlot);
                break;
            }
        case ItemInventoryAlyzer.SLOT_ANALYZE_3:
            {
                speciesRoot.getAlyzerPlugin().drawAnalyticsPage3(this, stackInSlot);
                break;
            }
        case ItemInventoryAlyzer.SLOT_ANALYZE_4:
            {
                IIndividual individual = speciesRoot.getMember(stackInSlot);
                drawAnalyticsPageMutations(individual);
                break;
            }
        case ItemInventoryAlyzer.SLOT_ANALYZE_5:
            {
                IIndividual individual = speciesRoot.getMember(stackInSlot);
                drawAnalyticsPageClassification(individual);
                break;
            }
        default:
            drawAnalyticsOverview();
    }
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IIndividual (forestry.api.genetics.IIndividual)49 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)30 ItemStack (net.minecraft.item.ItemStack)29 IAllele (forestry.api.genetics.IAllele)14 IGenome (forestry.api.genetics.IGenome)10 ISpeciesType (forestry.api.genetics.ISpeciesType)8 Nullable (javax.annotation.Nullable)7 Gene (binnie.core.genetics.Gene)6 IChromosomeType (forestry.api.genetics.IChromosomeType)6 ArrayList (java.util.ArrayList)6 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)5 Random (java.util.Random)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 IGene (binnie.core.api.genetics.IGene)4 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 IBreedingTracker (forestry.api.genetics.IBreedingTracker)3 IFilterData (forestry.api.genetics.IFilterData)3 Tolerance (binnie.core.genetics.Tolerance)2 Point (binnie.core.gui.geometry.Point)2 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)2