use of forestry.arboriculture.blocks.BlockDefaultLeaves in project ForestryMC by ForestryMC.
the class ModelDefaultLeaves method getInventoryKey.
@Override
protected TreeDefinition getInventoryKey(ItemStack stack) {
Block block = Block.getBlockFromItem(stack.getItem());
Preconditions.checkArgument(block instanceof BlockDefaultLeaves, "ItemStack must be for default leaves.");
BlockDefaultLeaves bBlock = (BlockDefaultLeaves) block;
return bBlock.getTreeType(stack.getMetadata());
}
use of forestry.arboriculture.blocks.BlockDefaultLeaves 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.blocks.BlockDefaultLeaves in project ForestryMC by ForestryMC.
the class ModelDefaultLeaves method getWorldKey.
@Override
protected TreeDefinition getWorldKey(IBlockState state) {
Block block = state.getBlock();
Preconditions.checkArgument(block instanceof BlockDefaultLeaves, "state must be for default leaves.");
BlockDefaultLeaves bBlock = (BlockDefaultLeaves) block;
TreeDefinition treeDefinition = bBlock.getTreeDefinition(state);
Preconditions.checkNotNull(treeDefinition);
return treeDefinition;
}
use of forestry.arboriculture.blocks.BlockDefaultLeaves in project ForestryMC by ForestryMC.
the class ProxyArboricultureClient method initializeModels.
@Override
public void initializeModels() {
{
ModelResourceLocation blockModelLocation = new ModelResourceLocation("forestry:leaves");
ModelResourceLocation itemModelLocation = new ModelResourceLocation("forestry:leaves", "inventory");
BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModelLocation, new ModelLeaves(), ModuleArboriculture.getBlocks().leaves);
ModelManager.getInstance().registerCustomBlockModel(blockModelIndex);
}
for (BlockDecorativeLeaves leaves : ModuleArboriculture.getBlocks().leavesDecorative) {
String resourceName = "forestry:leaves.decorative." + leaves.getBlockNumber();
ModelResourceLocation blockModelLocation = new ModelResourceLocation(resourceName);
ModelResourceLocation itemModeLocation = new ModelResourceLocation(resourceName, "inventory");
BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModeLocation, new ModelDecorativeLeaves(), leaves);
ModelManager.getInstance().registerCustomBlockModel(blockModelIndex);
}
for (BlockDefaultLeaves leaves : ModuleArboriculture.getBlocks().leavesDefault) {
String resourceName = "forestry:leaves.default." + leaves.getBlockNumber();
ModelResourceLocation blockModelLocation = new ModelResourceLocation(resourceName);
ModelResourceLocation itemModeLocation = new ModelResourceLocation(resourceName, "inventory");
BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModeLocation, new ModelDefaultLeaves(), leaves);
ModelManager.getInstance().registerCustomBlockModel(blockModelIndex);
}
ModelLoaderRegistry.registerLoader(WoodModelLoader.INSTANCE);
for (BlockArbSlab slab : ModuleArboriculture.getBlocks().slabsDouble) {
registerWoodModel(slab, true);
}
for (BlockArbSlab slab : ModuleArboriculture.getBlocks().slabsDoubleFireproof) {
registerWoodModel(slab, true);
}
}
Aggregations