use of forestry.api.genetics.IItemTranslator 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;
}
});
}
}
Aggregations