Как узнать, на какую сторону блока смотрит игрок?

Версия Minecraft
1.7.10
API
Forge
40
1
0
Добрый вечер. Нужно узнать, на какую из шести поверхностей блока смотрит игрок. Как можно это определить на 1.7.10?

Есть код (в классе инструмента):
Код при ломании блока инструментом:
public boolean onBlockDestroyed(ItemStack is, World world, Block block, int x, int y, int z, EntityLivingBase entity) {
        if (block.getMaterial() == Material.rock) {
            if (entity instanceof EntityPlayer) {
                EntityPlayer player = (EntityPlayer)entity;
                if (!player.isSneaking()) {
                    return false;
                }
            }
            for (int ax = -1; ax <= 1; ax ++) {
                for (int ay = -1; ay <= 1; ay++) {
                    for (int az = -1; az <= 1; az++) {
                        int bx = x + ax, by = y + ay, bz = z + az;
                        if (world.isAirBlock(bx, by, bz)) continue;
                        if (world.getBlock(bx, by, bz).getMaterial() != block.getMaterial()) continue;
                        //world.func_147480_a(bx, by, bz, true);
                        world.getBlock(bx, by, bz).dropBlockAsItem(world, bx, by, bz, 0, 0);
                        world.setBlock(bx, by, bz, Blocks.air);
                    }
                }
            }
        }
        return true;
    }

Нужно, чтобы ломалось 9 блоков с центром на том блоке, на который игрок смотрит, но чтобы не ломать во все стороны, мне нужно узнать, на на какую сторону этого блока смотрит игрок.
 
Решение
Для будущих поколений:

Как узнать, какую сторону блока сломал игрок::
//entity - игрок
//Если будет плохо работать - увеличивайте fasc и dist
float fasc = 1F;
float dist = 4.5F;
Vec3 vec = Vec3.createVectorHelper(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ);
Vec3 pvec = entity.getLook(fasc);
Vec3 tvec = vec.addVector(pvec.xCoord * dist, pvec.yCoord * dist, pvec.zCoord * dist);
MovingObjectPosition mop = entity.worldObj.rayTraceBlocks(vec, tvec, true);
int side = 6;
if (mop != null) side = mop.sideHit;
//side - сторона блока (0-5)


Весь код в классе инструмента при ломании блока им (редактируйте под себя):
    public boolean onBlockDestroyed(ItemStack is, World world, Block block, int x, int y, int z, EntityLivingBase entity) {
        
        if (block.getMaterial() != Material.rock) return false;
        if (!(entity...
7,099
324
1,509
40
1
0
Для будущих поколений:

Как узнать, какую сторону блока сломал игрок::
//entity - игрок
//Если будет плохо работать - увеличивайте fasc и dist
float fasc = 1F;
float dist = 4.5F;
Vec3 vec = Vec3.createVectorHelper(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ);
Vec3 pvec = entity.getLook(fasc);
Vec3 tvec = vec.addVector(pvec.xCoord * dist, pvec.yCoord * dist, pvec.zCoord * dist);
MovingObjectPosition mop = entity.worldObj.rayTraceBlocks(vec, tvec, true);
int side = 6;
if (mop != null) side = mop.sideHit;
//side - сторона блока (0-5)


Весь код в классе инструмента при ломании блока им (редактируйте под себя):
    public boolean onBlockDestroyed(ItemStack is, World world, Block block, int x, int y, int z, EntityLivingBase entity) {
        
        if (block.getMaterial() != Material.rock) return false;
        if (!(entity instanceof EntityPlayerMP)) return false;
        if (!entity.isSneaking()) return false;
        
        float fasc = 1F;
        float dist = 4.5F;
        Vec3 vec = Vec3.createVectorHelper(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ);
        Vec3 pvec = entity.getLook(fasc);
        Vec3 tvec = vec.addVector(pvec.xCoord * dist, pvec.yCoord * dist, pvec.zCoord * dist);
        MovingObjectPosition mop = entity.worldObj.rayTraceBlocks(vec, tvec, true);
        int side = 6;
        if (mop != null) side = mop.sideHit;

        int rx = side == 4 || side == 5 ? 0 : 1;
        int ry = side == 0 || side == 1 ? 0 : 1;
        int rz = side == 2 || side == 3 ? 0 : 1;
        
        for (int ax = -rx; ax <= rx; ax++) {
            for (int ay = -ry; ay <= ry; ay++) {
                for (int az = -rz; az <= rz; az++) {
                    int bx = x + ax, by = y + ay, bz = z + az;
                    if (world.isAirBlock(bx, by, bz)) continue;
                    if (world.getBlock(bx, by, bz).getMaterial() != block.getMaterial()) continue;
                    //world.func_147480_a(bx, by, bz, true);
                    world.getBlock(bx, by, bz).dropBlockAsItem(world, bx, by, bz, 0, 0);
                    world.setBlock(bx, by, bz, Blocks.air);
                }
            }
        }
        return true;
    }
 
Сверху