Search in sources :

Example 1 with ShellMuse

use of com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell.ShellMuse in project DynamicTrees by DynamicTreesTeam.

the class WailaBranchHandler method getTreeVolume.

private float getTreeVolume(World world, BlockPos pos) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    // Dereference proxy trunk shell block
    if (block instanceof BlockTrunkShell) {
        ShellMuse muse = ((BlockTrunkShell) block).getMuse(world, pos);
        if (muse != null) {
            state = muse.state;
            block = state.getBlock();
            pos = muse.pos;
        }
    }
    if (block instanceof BlockBranch) {
        BlockBranch branch = (BlockBranch) block;
        // Analyze only part of the tree beyond the break point and calculate it's volume, then destroy the branches
        NodeNetVolume volumeSum = new NodeNetVolume();
        branch.analyse(state, world, pos, null, new MapSignal(volumeSum));
        return volumeSum.getVolume() * ModConfigs.treeHarvestMultiplier;
    }
    return 0;
}
Also used : NodeNetVolume(com.ferreusveritas.dynamictrees.systems.nodemappers.NodeNetVolume) IBlockState(net.minecraft.block.state.IBlockState) BlockTrunkShell(com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell) Block(net.minecraft.block.Block) ShellMuse(com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell.ShellMuse) BlockBranch(com.ferreusveritas.dynamictrees.blocks.BlockBranch) MapSignal(com.ferreusveritas.dynamictrees.api.network.MapSignal)

Aggregations

MapSignal (com.ferreusveritas.dynamictrees.api.network.MapSignal)1 BlockBranch (com.ferreusveritas.dynamictrees.blocks.BlockBranch)1 BlockTrunkShell (com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell)1 ShellMuse (com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell.ShellMuse)1 NodeNetVolume (com.ferreusveritas.dynamictrees.systems.nodemappers.NodeNetVolume)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1