Search in sources :

Example 1 with TreeDefinition

use of forestry.arboriculture.genetics.TreeDefinition in project ForestryMC by ForestryMC.

the class ItemBlockDecorativeLeaves method getColorFromItemstack.

@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemstack(ItemStack itemStack, int renderPass) {
    int meta = itemStack.getMetadata();
    BlockDecorativeLeaves block = getBlock();
    TreeDefinition treeDefinition = block.getTreeType(meta);
    ITreeGenome genome = treeDefinition.getGenome();
    if (renderPass == BlockAbstractLeaves.FRUIT_COLOR_INDEX) {
        IFruitProvider fruitProvider = genome.getFruitProvider();
        return fruitProvider.getDecorativeColor();
    }
    return genome.getPrimary().getLeafSpriteProvider().getColor(false);
}
Also used : BlockDecorativeLeaves(forestry.arboriculture.blocks.BlockDecorativeLeaves) TreeDefinition(forestry.arboriculture.genetics.TreeDefinition) ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with TreeDefinition

use of forestry.arboriculture.genetics.TreeDefinition 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 3 with TreeDefinition

use of forestry.arboriculture.genetics.TreeDefinition in project ForestryMC by ForestryMC.

the class BlockDecorativeLeaves method colorMultiplier.

@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
    TreeDefinition treeDefinition = state.getValue(getVariant());
    ITreeGenome genome = treeDefinition.getGenome();
    if (tintIndex == BlockAbstractLeaves.FRUIT_COLOR_INDEX) {
        IFruitProvider fruitProvider = genome.getFruitProvider();
        return fruitProvider.getDecorativeColor();
    }
    ILeafSpriteProvider spriteProvider = genome.getPrimary().getLeafSpriteProvider();
    return spriteProvider.getColor(false);
}
Also used : ILeafSpriteProvider(forestry.api.arboriculture.ILeafSpriteProvider) TreeDefinition(forestry.arboriculture.genetics.TreeDefinition) ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with TreeDefinition

use of forestry.arboriculture.genetics.TreeDefinition in project ForestryMC by ForestryMC.

the class BlockDefaultLeaves method colorMultiplier.

@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
    TreeDefinition treeDefinition = getTreeDefinition(state);
    if (treeDefinition == null) {
        treeDefinition = TreeDefinition.Oak;
    }
    ITreeGenome genome = treeDefinition.getGenome();
    if (tintIndex == BlockAbstractLeaves.FRUIT_COLOR_INDEX) {
        IFruitProvider fruitProvider = genome.getFruitProvider();
        return fruitProvider.getDecorativeColor();
    }
    ILeafSpriteProvider spriteProvider = genome.getPrimary().getLeafSpriteProvider();
    return spriteProvider.getColor(false);
}
Also used : ILeafSpriteProvider(forestry.api.arboriculture.ILeafSpriteProvider) TreeDefinition(forestry.arboriculture.genetics.TreeDefinition) ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with TreeDefinition

use of forestry.arboriculture.genetics.TreeDefinition in project ForestryMC by ForestryMC.

the class BlockDefaultLeaves method getTree.

@Override
protected ITree getTree(IBlockAccess world, BlockPos pos) {
    IBlockState blockState = world.getBlockState(pos);
    TreeDefinition treeDefinition = getTreeDefinition(blockState);
    if (treeDefinition != null) {
        return treeDefinition.getIndividual();
    } else {
        return null;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TreeDefinition(forestry.arboriculture.genetics.TreeDefinition)

Aggregations

TreeDefinition (forestry.arboriculture.genetics.TreeDefinition)7 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 IFruitProvider (forestry.api.arboriculture.IFruitProvider)3 ITreeGenome (forestry.api.arboriculture.ITreeGenome)3 ILeafSpriteProvider (forestry.api.arboriculture.ILeafSpriteProvider)2 BlockDecorativeLeaves (forestry.arboriculture.blocks.BlockDecorativeLeaves)2 BlockDefaultLeaves (forestry.arboriculture.blocks.BlockDefaultLeaves)2 IBlockState (net.minecraft.block.state.IBlockState)2 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