Esempio n. 1
0
        static void PlayerClickCallback(Player p, MouseButton btn, MouseAction action,
                                        ushort yaw, ushort pitch, byte entity,
                                        ushort x, ushort y, ushort z, TargetBlockFace face)
        {
            Weapon weapon = p.weapon;

            if (weapon == null || action != MouseAction.Pressed)
            {
                return;
            }

            if (!(btn == MouseButton.Left || btn == MouseButton.Right))
            {
                return;
            }
            if (!p.level.Config.Guns)
            {
                weapon.Disable(); return;
            }

            BlockID held = p.ClientHeldBlock;

            if (!CommandParser.IsBlockAllowed(p, "use", held))
            {
                return;
            }

            Vec3F32 dir = DirUtils.GetDirVectorExt(yaw, pitch);

            weapon.OnActivated(dir, held);
        }