Search in sources :

Example 1 with BlockTrunkShell

use of com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell 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)

Example 2 with BlockTrunkShell

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

the class WorldListener method sendBlockBreakProgress.

@Override
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {
    if (mcServer == null) {
        return;
    }
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() instanceof BlockTrunkShell) {
        for (EntityPlayerMP entityplayermp : this.mcServer.getPlayerList().getPlayers()) {
            if (entityplayermp != null && entityplayermp.world == this.world) {
                double d0 = (double) pos.getX() - entityplayermp.posX;
                double d1 = (double) pos.getY() - entityplayermp.posY;
                double d2 = (double) pos.getZ() - entityplayermp.posZ;
                if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
                    BlockPos centerPos = pos.add(state.getValue(BlockTrunkShell.COREDIR).getOffset());
                    entityplayermp.connection.sendPacket(new SPacketBlockBreakAnim((-breakerId) - 1, centerPos, progress));
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockTrunkShell(com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos) SPacketBlockBreakAnim(net.minecraft.network.play.server.SPacketBlockBreakAnim)

Aggregations

BlockTrunkShell (com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell)2 IBlockState (net.minecraft.block.state.IBlockState)2 MapSignal (com.ferreusveritas.dynamictrees.api.network.MapSignal)1 BlockBranch (com.ferreusveritas.dynamictrees.blocks.BlockBranch)1 ShellMuse (com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell.ShellMuse)1 NodeNetVolume (com.ferreusveritas.dynamictrees.systems.nodemappers.NodeNetVolume)1 Block (net.minecraft.block.Block)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 SPacketBlockBreakAnim (net.minecraft.network.play.server.SPacketBlockBreakAnim)1 BlockPos (net.minecraft.util.math.BlockPos)1