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;
}
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());
}
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);
}
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);
}
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;
}
Aggregations