Search in sources :

Example 1 with IItemTranslator

use of forestry.api.genetics.IItemTranslator 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)

Aggregations

Preconditions (com.google.common.base.Preconditions)1 EnumForestryWoodType (forestry.api.arboriculture.EnumForestryWoodType)1 EnumGermlingType (forestry.api.arboriculture.EnumGermlingType)1 EnumVanillaWoodType (forestry.api.arboriculture.EnumVanillaWoodType)1 IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)1 ITree (forestry.api.arboriculture.ITree)1 IWoodType (forestry.api.arboriculture.IWoodType)1 TreeManager (forestry.api.arboriculture.TreeManager)1 WoodBlockKind (forestry.api.arboriculture.WoodBlockKind)1 ForestryAPI (forestry.api.core.ForestryAPI)1 IArmorNaturalist (forestry.api.core.IArmorNaturalist)1 AlleleManager (forestry.api.genetics.AlleleManager)1 IBlockTranslator (forestry.api.genetics.IBlockTranslator)1 IIndividual (forestry.api.genetics.IIndividual)1 IItemTranslator (forestry.api.genetics.IItemTranslator)1 ForestryModule (forestry.api.modules.ForestryModule)1 RecipeManagers (forestry.api.recipes.RecipeManagers)1 ICrateRegistry (forestry.api.storage.ICrateRegistry)1 StorageManager (forestry.api.storage.StorageManager)1 BlockArbLog (forestry.arboriculture.blocks.BlockArbLog)1