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