Example #1
0
        public void UseBreak(Vector3 pos, Item item, Player player)
        {
            if (player.IsSpectator)
            {
                return;
            }

            Block block = this.GetBlock(pos);

            BlockBreakEventArgs args = new BlockBreakEventArgs(player, block, item);

            /*if (player.IsSurvival && !block.CanBreak)
             * {
             *  blockBreakEvent.IsCancel = true;
             * }*/

            /*if (Server.ServerConfig.SpawnProtection > 0 || player.Op)
             * {
             *  //TODO
             * }*/

            Server.Instance.Event.Block.OnBlockBreak(this, args);
            if (args.IsCancel)
            {
                this.SendBlocks(Server.Instance.GetOnlinePlayers(), new Vector3[] { block.ToVector3() });
                return;
            }

            //Item[] drops = blockBreakEvent.Drops;
            Item[] drops = block.GetDrops(item);

            //TODO : can destroy

            LevelEventPacket pk = new LevelEventPacket();

            pk.EventId  = LevelEventPacket.EVENT_PARTICLE_DESTROY;
            pk.Position = pos + new Vector3(0.5f, 0.5f, 0.5f);
            pk.Data     = block.RuntimeId;
            Server.Instance.BroadcastSendPacket(pk); //TODO : near players

            block.Break(player, item);

            item.DestroyBlock(block, player);

            //TODO : item drop
        }
Example #2
0
        public void UseBreak(Vector3 pos, Item item, Player player)
        {
            if (player.IsSpectator)
            {
                return;
            }
            Block block = this.GetBlock(pos);

            BlockBreakEventArgs blockBreakEvent = new BlockBreakEventArgs(player, block, item);

            if (player.IsSurvival && !block.CanBreak)
            {
                blockBreakEvent.IsCancel = true;
            }

            if (Server.ServerConfig.SpawnProtection > 0 || player.Op)
            {
                //TODO
            }

            BlockEvents.OnBlockBreak(blockBreakEvent);
            if (blockBreakEvent.IsCancel)
            {
                return;
            }

            Item[] drops = blockBreakEvent.Drops;

            //TODO : can destroy

            LevelEventPacket pk = new LevelEventPacket();

            pk.EventId  = LevelEventPacket.EVENT_PARTICLE_DESTROY;
            pk.Position = pos + new Vector3(0.5f, 0.5f, 0.5f);
            pk.Data     = block.RuntimeId;
            player.SendPacket(pk); //TODO : near players

            block.Break(player, item);

            item.BlockDestroyed(block, player);

            //TODO : item drop
        }