private void OnPlayerDigging(PlayerDiggingPacket p)
 {
     if (PlayerDigging != null) PlayerDigging.Invoke(this, new PacketEventArgs<PlayerDiggingPacket>(p));
 }
Exemple #2
0
        public static void HandlePacketPlayerDigging(Client client, PlayerDiggingPacket packet)
        {
            Player player = client.Owner;

            int x = packet.X;
            int y = packet.Y;
            int z = packet.Z;

            byte type = player.World.GetBlockId(x, y, z);
            byte data = player.World.GetBlockData(x, y, z);

            switch (packet.Action)
            {
                case PlayerDiggingPacket.DigAction.StartDigging:
                    client.SendMessage(String.Format("SkyLight: {0}", player.World.GetSkyLight(x, y, z)));
                    client.SendMessage(String.Format("BlockLight: {0}", player.World.GetBlockLight(x, y, z)));
                    client.SendMessage(String.Format("Opacity: {0}", player.World.GetBlockChunk(x, y, z).GetOpacity(x & 0xf, y, z & 0xf)));
                    client.SendMessage(String.Format("Height: {0}", player.World.GetHeight(x, z)));
                    client.SendMessage(String.Format("Data: {0}", player.World.GetBlockData(x, y, z)));
                    //this.SendMessage()
                    if (player.World.BlockHelper.Instance(type).IsSingleHit)
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    if (player.GameMode == 1)
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    break;

                case PlayerDiggingPacket.DigAction.FinishDigging:
                    StructBlock block = new StructBlock(x, y, z, type, data, player.World);
                    player.World.BlockHelper.Instance(type).Destroy(player, block);
                    break;
            }
        }
Exemple #3
0
        public static void HandlePacketPlayerDigging(Client client, PlayerDiggingPacket packet)
        {
            Player player = client.Owner;

            UniversalCoords coords = UniversalCoords.FromWorld(packet.X, packet.Y, packet.Z);

            Chunk chunk = player.World.GetChunk(coords);

            if (chunk == null)
                return;

            byte type = (byte)chunk.GetType(coords);
            byte data = chunk.GetData(coords);

            switch (packet.Action)
            {
                case PlayerDiggingPacket.DigAction.StartDigging:
            #if DEBUG
                    UniversalCoords oneUp = UniversalCoords.FromWorld(coords.WorldX, coords.WorldY + 1, coords.WorldZ);
                    client.SendMessage(String.Format("SkyLight: {0}", player.World.GetSkyLight(oneUp)));
                    client.SendMessage(String.Format("BlockLight: {0}", player.World.GetBlockLight(oneUp)));
                    client.SendMessage(String.Format("Opacity: {0}", player.World.GetChunk(oneUp, false, false).GetOpacity(oneUp)));
                    client.SendMessage(String.Format("Height: {0}", player.World.GetHeight(oneUp)));
                    client.SendMessage(String.Format("Data: {0}", player.World.GetBlockData(oneUp)));
                    //this.SendMessage()
            #endif
                    if (BlockHelper.IsSingleHit(type))
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    if (BlockHelper.Instance(type) is BlockLeaves && player.Inventory.ActiveItem.Type == (short)BlockData.Items.Shears)
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    if (player.GameMode == 1)
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    break;

                case PlayerDiggingPacket.DigAction.FinishDigging:
                    StructBlock block = new StructBlock(coords, type, data, player.World);
                    BlockHelper.Instance(type).Destroy(player, block);
                    break;

                case PlayerDiggingPacket.DigAction.DropItem:
                    player.DropItem();
                    break;
            }
        }
Exemple #4
0
        public static void ReadPlayerDigging(Client client, PacketReader reader)
        {
            PlayerDiggingPacket pd = new PlayerDiggingPacket();
            pd.Read(reader);

            if (!reader.Failed)
                Client.HandlePacketPlayerDigging(client, pd);
        }
Exemple #5
0
        public static void HandlePacketPlayerDigging(Client client, PlayerDiggingPacket packet)
        {
            Player player = client.Owner;

            UniversalCoords coords = UniversalCoords.FromWorld(packet.X, packet.Y, packet.Z);

            byte type = player.World.GetBlockId(coords);
            byte data = player.World.GetBlockData(coords);

            switch (packet.Action)
            {
                case PlayerDiggingPacket.DigAction.StartDigging:
                    client.SendMessage(String.Format("SkyLight: {0}", player.World.GetSkyLight(coords)));
                    client.SendMessage(String.Format("BlockLight: {0}", player.World.GetBlockLight(coords)));
                    client.SendMessage(String.Format("Opacity: {0}", player.World.GetBlockChunk(coords).GetOpacity(coords)));
                    client.SendMessage(String.Format("Height: {0}", player.World.GetHeight(coords)));
                    client.SendMessage(String.Format("Data: {0}", player.World.GetBlockData(coords)));
                    //this.SendMessage()
                    if (BlockHelper.Instance(type).IsSingleHit)
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    if (BlockHelper.Instance(type) is BlockLeaves && player.Inventory.ActiveItem.Type == (short)BlockData.Items.Shears)
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    if (player.GameMode == 1)
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    break;

                case PlayerDiggingPacket.DigAction.FinishDigging:
                    StructBlock block = new StructBlock(coords, type, data, player.World);
                    BlockHelper.Instance(type).Destroy(player, block);
                    break;

                case PlayerDiggingPacket.DigAction.DropItem:
                    var slot = player.Inventory.ActiveSlot;
                    player.Inventory.RemoveItem(slot);
                    player.DropItem();
                    break;
            }
        }