Search in sources :

Example 1 with IAlleleTreeSpecies

use of forestry.api.arboriculture.IAlleleTreeSpecies in project ForestryMC by ForestryMC.

the class SaplingStateMapper method putStateModelLocations.

@Override
public Map<IBlockState, ModelResourceLocation> putStateModelLocations(Block block) {
    for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
        if (allele instanceof IAlleleTreeSpecies) {
            IAlleleTreeSpecies tree = (IAlleleTreeSpecies) allele;
            IBlockState state = block.getDefaultState().withProperty(BlockSapling.TREE, tree);
            LinkedHashMap<IProperty<?>, Comparable<?>> linkedhashmap = Maps.newLinkedHashMap(state.getProperties());
            String modID = tree.getModID();
            String s = String.format("%s:%s", modID, "germlings");
            mapStateModelLocations.put(state, new ModelResourceLocation(s, getPropertyString(linkedhashmap)));
        }
    }
    return mapStateModelLocations;
}
Also used : IAllele(forestry.api.genetics.IAllele) IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IBlockState(net.minecraft.block.state.IBlockState) IProperty(net.minecraft.block.properties.IProperty) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 2 with IAlleleTreeSpecies

use of forestry.api.arboriculture.IAlleleTreeSpecies in project ForestryMC by ForestryMC.

the class TileLeaves method onBlockTick.

@Override
public void onBlockTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    ITree tree = getTree();
    if (tree == null) {
        return;
    }
    ITreeGenome genome = tree.getGenome();
    IAlleleTreeSpecies primary = genome.getPrimary();
    if (!checkedForConversionToDefaultLeaves) {
        if (shouldConvertToDefaultLeaves()) {
            IBlockState defaultLeaves = ModuleArboriculture.getBlocks().getDefaultLeaves(primary.getUID());
            worldIn.setBlockState(getPos(), defaultLeaves);
            return;
        }
        checkedForConversionToDefaultLeaves = true;
    }
    boolean isDestroyed = isDestroyed(tree, damage);
    for (ILeafTickHandler tickHandler : primary.getRoot().getLeafTickHandlers()) {
        if (tickHandler.onRandomLeafTick(tree, world, rand, getPos(), isDestroyed)) {
            return;
        }
    }
    if (isDestroyed) {
        return;
    }
    if (damage > 0) {
        damage--;
    }
    if (hasFruit() && getRipeningTime() < ripeningPeriod) {
        ITreekeepingMode treekeepingMode = TreeManager.treeRoot.getTreekeepingMode(world);
        float sappinessModifier = treekeepingMode.getSappinessModifier(genome, 1f);
        float sappiness = genome.getSappiness() * sappinessModifier;
        if (rand.nextFloat() < sappiness) {
            ripeningTime++;
            sendNetworkUpdateRipening();
        }
    }
    if (caterpillar != null) {
        matureCaterpillar();
    }
    effectData = tree.doEffect(effectData, world, getPos());
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IBlockState(net.minecraft.block.state.IBlockState) ITreekeepingMode(forestry.api.arboriculture.ITreekeepingMode) ILeafTickHandler(forestry.api.arboriculture.ILeafTickHandler) ITree(forestry.api.arboriculture.ITree) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Example 3 with IAlleleTreeSpecies

use of forestry.api.arboriculture.IAlleleTreeSpecies in project ForestryMC by ForestryMC.

the class ModelDecorativeLeaves method bakeBlock.

@Override
protected void bakeBlock(BlockDecorativeLeaves block, TreeDefinition treeDefinition, IModelBaker baker, boolean inventory) {
    TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
    ITreeGenome genome = treeDefinition.getGenome();
    IAlleleTreeSpecies species = genome.getPrimary();
    ILeafSpriteProvider leafSpriteProvider = species.getLeafSpriteProvider();
    ResourceLocation leafSpriteLocation = leafSpriteProvider.getSprite(false, Proxies.render.fancyGraphicsEnabled());
    TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
    // Render the plain leaf block.
    baker.addBlockModel(null, leafSprite, BlockAbstractLeaves.FOLIAGE_COLOR_INDEX);
    // Render overlay for fruit leaves.
    ResourceLocation fruitSpriteLocation = genome.getFruitProvider().getDecorativeSprite();
    if (fruitSpriteLocation != null) {
        TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
        baker.addBlockModel(null, fruitSprite, BlockAbstractLeaves.FRUIT_COLOR_INDEX);
    }
    // Set the particle sprite
    baker.setParticleSprite(leafSprite);
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) TextureMap(net.minecraft.client.renderer.texture.TextureMap) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceLocation(net.minecraft.util.ResourceLocation) ILeafSpriteProvider(forestry.api.arboriculture.ILeafSpriteProvider) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Example 4 with IAlleleTreeSpecies

use of forestry.api.arboriculture.IAlleleTreeSpecies in project ForestryMC by ForestryMC.

the class ModelLeaves method createEmptyKey.

private Key createEmptyKey(TextureMap map, boolean fancy) {
    IAlleleTreeSpecies oakSpecies = TreeDefinition.Oak.getIndividual().getGenome().getPrimary();
    ResourceLocation spriteLocation = oakSpecies.getLeafSpriteProvider().getSprite(false, fancy);
    TextureAtlasSprite sprite = map.getAtlasSprite(spriteLocation.toString());
    return new Key(sprite, null, fancy);
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 5 with IAlleleTreeSpecies

use of forestry.api.arboriculture.IAlleleTreeSpecies in project ForestryMC by ForestryMC.

the class TreeGenome method calculateMatchesTemplateGenome.

private boolean calculateMatchesTemplateGenome() {
    IAlleleTreeSpecies primary = getPrimary();
    IAllele[] template = getSpeciesRoot().getTemplate(primary);
    IChromosome[] chromosomes = getChromosomes();
    for (int i = 0; i < chromosomes.length; i++) {
        IChromosome chromosome = chromosomes[i];
        String templateUid = template[i].getUID();
        IAllele primaryAllele = chromosome.getPrimaryAllele();
        if (!primaryAllele.getUID().equals(templateUid)) {
            return false;
        }
        IAllele secondaryAllele = chromosome.getSecondaryAllele();
        if (!secondaryAllele.getUID().equals(templateUid)) {
            return false;
        }
    }
    return true;
}
Also used : IAllele(forestry.api.genetics.IAllele) IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IChromosome(forestry.api.genetics.IChromosome)

Aggregations

IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)24 ITreeGenome (forestry.api.arboriculture.ITreeGenome)14 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)7 ItemStack (net.minecraft.item.ItemStack)7 IAllele (forestry.api.genetics.IAllele)6 ArrayList (java.util.ArrayList)6 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)6 ResourceLocation (net.minecraft.util.ResourceLocation)6 ILeafSpriteProvider (forestry.api.arboriculture.ILeafSpriteProvider)5 TextureMap (net.minecraft.client.renderer.texture.TextureMap)5 ITree (forestry.api.arboriculture.ITree)4 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)2 IChromosome (forestry.api.genetics.IChromosome)2 IFruitFamily (forestry.api.genetics.IFruitFamily)2 IBlockState (net.minecraft.block.state.IBlockState)2 Biome (net.minecraft.world.biome.Biome)2 ControlText (binnie.core.gui.controls.ControlText)1 Control (binnie.core.gui.controls.core.Control)1 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)1 Area (binnie.core.gui.geometry.Area)1