Search in sources :

Example 6 with ETTreeDefinition

use of binnie.extratrees.genetics.ETTreeDefinition in project Binnie by ForestryMC.

the class BlockETDecorativeLeaves method colorMultiplier.

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

Example 7 with ETTreeDefinition

use of binnie.extratrees.genetics.ETTreeDefinition in project Binnie by ForestryMC.

the class ModuleWood method onBakedEvent.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onBakedEvent(ModelBakeEvent e) {
    // Find all ExtraTrees saplings
    List<ModelResourceLocation> models = e.getModelRegistry().getKeys().stream().filter(mrl -> mrl.getResourceDomain().startsWith(Constants.EXTRA_TREES_MOD_ID)).filter(mrl -> mrl.getResourcePath().startsWith("germlings")).collect(Collectors.toList());
    // Replace model
    Map<String, ETTreeDefinition> map = Arrays.stream(ETTreeDefinition.values()).collect(Collectors.toMap(o -> o.name().toLowerCase(), o -> o));
    models.forEach(model -> {
        String species = model.getVariant().split("=")[1];
        ETTreeDefinition treeSpecies = map.get(species);
        int primaryColor = treeSpecies.getLeafColor().getRGB();
        int secondaryColor = treeSpecies.getWoodColor().getRGB();
        IBakedModel bakedModel = e.getModelRegistry().getObject(model);
        if (bakedModel == null) {
            return;
        }
        e.getModelRegistry().putObject(model, new DoublePassBakedModel(bakedModel, primaryColor, secondaryColor));
    });
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) ModelBakeEvent(net.minecraftforge.client.event.ModelBakeEvent) Arrays(java.util.Arrays) ForestryModule(forestry.api.modules.ForestryModule) IWoodTyped(forestry.arboriculture.IWoodTyped) ILiquidDefinition(binnie.core.liquid.ILiquidDefinition) EnumETLog(binnie.extratrees.wood.EnumETLog) EnumShrubLog(binnie.extratrees.wood.EnumShrubLog) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) PropertyETType(binnie.extratrees.blocks.property.PropertyETType) BlockETSlab(binnie.extratrees.blocks.wood.BlockETSlab) ExtraTrees(binnie.extratrees.ExtraTrees) Block(net.minecraft.block.Block) ModuleManager(binnie.core.modules.ModuleManager) OreDictionary(net.minecraftforge.oredict.OreDictionary) Side(net.minecraftforge.fml.relauncher.Side) WoodManager(binnie.extratrees.wood.WoodManager) Constants(binnie.core.Constants) FruitSprite(binnie.extratrees.genetics.fruits.FruitSprite) Map(java.util.Map) BlockETDoor(binnie.extratrees.blocks.wood.BlockETDoor) RecipeUtil(binnie.core.util.RecipeUtil) WoodBlockKind(forestry.api.arboriculture.WoodBlockKind) AlleleRegisterEvent(forestry.api.genetics.AlleleRegisterEvent) ITreeRoot(forestry.api.arboriculture.ITreeRoot) WoodAccess(forestry.arboriculture.WoodAccess) ItemMetadata(binnie.core.block.ItemMetadata) BlockForestryFenceGate(forestry.arboriculture.blocks.BlockForestryFenceGate) ModuleArboriculture(forestry.arboriculture.ModuleArboriculture) OreDictUtil(forestry.core.utils.OreDictUtil) BlockETDefaultLeaves(binnie.extratrees.blocks.BlockETDefaultLeaves) Collectors(java.util.stream.Collectors) ModuleUtils(binnie.core.util.ModuleUtils) BlockMultiFence(binnie.extratrees.blocks.decor.BlockMultiFence) DoublePassBakedModel(binnie.core.models.DoublePassBakedModel) List(java.util.List) BlockForestryStairs(forestry.arboriculture.blocks.BlockForestryStairs) BinnieCore(binnie.core.BinnieCore) BlockETDecorativeLeaves(binnie.extratrees.blocks.BlockETDecorativeLeaves) ItemETSlab(binnie.extratrees.blocks.wood.ItemETSlab) FMLInterModComms(net.minecraftforge.fml.common.event.FMLInterModComms) EnumVanillaWoodType(forestry.api.arboriculture.EnumVanillaWoodType) AlleleETFruitDefinition(binnie.extratrees.genetics.AlleleETFruitDefinition) FluidStack(net.minecraftforge.fluids.FluidStack) VanillaPlanks(binnie.extratrees.wood.planks.VanillaPlanks) BlockETFence(binnie.extratrees.blocks.wood.BlockETFence) ItemBlockETDecorativeLeaves(binnie.extratrees.items.ItemBlockETDecorativeLeaves) IButterflyRoot(forestry.api.lepidopterology.IButterflyRoot) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ExtraTreesModuleUIDs(binnie.core.modules.ExtraTreesModuleUIDs) ItemBlockETWood(binnie.extratrees.blocks.wood.ItemBlockETWood) RecipeManagers(forestry.api.recipes.RecipeManagers) IPlankType(binnie.extratrees.wood.planks.IPlankType) BlockETLog(binnie.extratrees.blocks.wood.BlockETLog) MultiFenceRecipeSize(binnie.extratrees.blocks.decor.MultiFenceRecipeSize) HashMap(java.util.HashMap) GameRegistry(net.minecraftforge.fml.common.registry.GameRegistry) MultiFenceRecipeEmbedded(binnie.extratrees.blocks.decor.MultiFenceRecipeEmbedded) ETTreeDefinition(binnie.extratrees.genetics.ETTreeDefinition) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) ExtraTreePlanks(binnie.extratrees.wood.planks.ExtraTreePlanks) Minecraft(net.minecraft.client.Minecraft) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) CarpentryManager(binnie.extratrees.api.CarpentryManager) ItemBlockETWoodDoor(binnie.extratrees.blocks.wood.ItemBlockETWoodDoor) ButterflySpecies(binnie.extratrees.genetics.ButterflySpecies) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ForestryPlanks(binnie.extratrees.wood.planks.ForestryPlanks) Nullable(javax.annotation.Nullable) ItemBlockLeaves(forestry.arboriculture.items.ItemBlockLeaves) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit) Items(net.minecraft.init.Items) ExtraTreeLiquid(binnie.extratrees.items.ExtraTreeLiquid) TextureMap(net.minecraft.client.renderer.texture.TextureMap) ForestryModuleUids(forestry.modules.ForestryModuleUids) MultiFenceRecipeSolid(binnie.extratrees.blocks.decor.MultiFenceRecipeSolid) BlockShrubLog(binnie.extratrees.blocks.wood.BlockShrubLog) TreeManager(forestry.api.arboriculture.TreeManager) Mods(binnie.core.Mods) AlleleSpeciesRegisterEvent(forestry.api.genetics.AlleleSpeciesRegisterEvent) IWoodAccess(forestry.api.arboriculture.IWoodAccess) ExtraTreeMutation(binnie.extratrees.genetics.ExtraTreeMutation) IBlockState(net.minecraft.block.state.IBlockState) MinecraftForge(net.minecraftforge.common.MinecraftForge) Fluids(forestry.core.fluids.Fluids) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) BlankModule(binnie.core.modules.BlankModule) Preconditions(com.google.common.base.Preconditions) BlockETPlank(binnie.extratrees.blocks.wood.BlockETPlank) ETTreeDefinition(binnie.extratrees.genetics.ETTreeDefinition) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) DoublePassBakedModel(binnie.core.models.DoublePassBakedModel) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with ETTreeDefinition

use of binnie.extratrees.genetics.ETTreeDefinition in project Binnie by ForestryMC.

the class ItemBlockETDecorativeLeaves method getColorFromItemstack.

@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemstack(ItemStack itemStack, int renderPass) {
    int meta = itemStack.getMetadata();
    BlockETDecorativeLeaves block = getBlock();
    ETTreeDefinition treeDefinition = block.getTreeType(meta);
    if (treeDefinition == null) {
        return ModuleArboriculture.proxy.getFoliageColorBasic();
    }
    ITreeGenome genome = treeDefinition.getGenome();
    if (renderPass == 0) {
        return genome.getPrimary().getLeafSpriteProvider().getColor(false);
    } else {
        IFruitProvider fruitProvider = genome.getFruitProvider();
        return fruitProvider.getDecorativeColor();
    }
}
Also used : BlockETDecorativeLeaves(binnie.extratrees.blocks.BlockETDecorativeLeaves) ETTreeDefinition(binnie.extratrees.genetics.ETTreeDefinition) ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ETTreeDefinition (binnie.extratrees.genetics.ETTreeDefinition)8 BlockETDecorativeLeaves (binnie.extratrees.blocks.BlockETDecorativeLeaves)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 BlockETDefaultLeaves (binnie.extratrees.blocks.BlockETDefaultLeaves)3 IFruitProvider (forestry.api.arboriculture.IFruitProvider)3 ITreeGenome (forestry.api.arboriculture.ITreeGenome)3 ItemMetadata (binnie.core.block.ItemMetadata)2 BlockMultiFence (binnie.extratrees.blocks.decor.BlockMultiFence)2 PropertyETType (binnie.extratrees.blocks.property.PropertyETType)2 BlockETDoor (binnie.extratrees.blocks.wood.BlockETDoor)2 BlockETFence (binnie.extratrees.blocks.wood.BlockETFence)2 BlockETLog (binnie.extratrees.blocks.wood.BlockETLog)2 BlockETPlank (binnie.extratrees.blocks.wood.BlockETPlank)2 BlockETSlab (binnie.extratrees.blocks.wood.BlockETSlab)2 BlockShrubLog (binnie.extratrees.blocks.wood.BlockShrubLog)2 ItemBlockETWoodDoor (binnie.extratrees.blocks.wood.ItemBlockETWoodDoor)2 ItemETSlab (binnie.extratrees.blocks.wood.ItemETSlab)2 ItemBlockETDecorativeLeaves (binnie.extratrees.items.ItemBlockETDecorativeLeaves)2 EnumETLog (binnie.extratrees.wood.EnumETLog)2 IBlockState (net.minecraft.block.state.IBlockState)2