Exemplo n.º 1
0
        public void LavaFlow(int x, int y, int z, byte meta)
        {
            byte block = w.GetBlock(x, y, z);
            byte bMeta = w.GetMeta(x, y, z);

            if (block == 0 || block == 51 || ((block == 10 || block == 11) && (meta & 0x7) < bMeta && (bMeta & 0x8) == 0))
            {
                AddUpdate(x, y, z, 10, meta);
                if (block == 51)
                {
                    Player.GlobalSoundEffect(x, (byte)y, z, 1004, w);
                }
            }
            else if (BlockData.LiquidDestroy(block))
            {
                AddUpdate(x, y, z, 10, meta);
                Player.GlobalSoundEffect(x, (byte)y, z, 2000, 4, w);

                short dropId = Player.BlockDropSwitch(block);
                if (FindBlocks.ValidItem(dropId))
                {
                    w.DropItem(x, y, z, dropId);
                }
            }
        }
Exemplo n.º 2
0
        public void WaterFlow(int x, int y, int z, byte meta)
        {
            if (SpongeCheck(x, y, z))
            {
                return;
            }
            byte block = w.GetBlock(x, y, z);
            byte bMeta = w.GetMeta(x, y, z);

            if (block == 0 || block == 51 || ((block == 8 || block == 9) && (meta & 0x7) < bMeta && (bMeta & 0x8) == 0))
            {
                AddUpdate(x, y, z, 8, meta);
                if (block == 51)
                {
                    Player.GlobalSoundEffect(x, (byte)y, z, 1004, w);
                }
            }
            else if (BlockData.LiquidDestroy(block))
            {
                AddUpdate(x, y, z, 8, meta);

                short dropId = Player.BlockDropSwitch(block);
                if (FindBlocks.ValidItem(dropId))
                {
                    w.DropItem(x, y, z, dropId);
                }
            }
            else if (block == 10 || block == 11)
            {
                if ((bMeta & 0x8) != 0)
                {
                    return;
                }
                if ((bMeta & 0x7) == 0)
                {
                    AddUpdate(x, y, z, 49, 0);
                }
                else
                {
                    AddUpdate(x, y, z, 4, 0);
                }
                Player.GlobalSoundEffect(x, (byte)y, z, 1004, w);
                //Player.GlobalSoundEffect(x, (byte)y, z, 2000, 4, w);
            }
        }
Exemplo n.º 3
0
        private void HandleDigging(byte[] message)
        {
            //Send Animation, this shouldn't only be sent when digging
            //Now handled in HandleAnimation(), this code isn't needed

            /*foreach (int i in VisibleEntities.ToArray())
             * {
             *  Entity e = Entity.Entities[i];
             *  if (!e.isPlayer) continue;
             *  Player p = e.p;
             *  if (p.level == level && p != this)
             *      p.SendAnimation(id, 1);
             * }*/

            if (message[0] == 0)
            {
                int  x         = util.EndianBitConverter.Big.ToInt32(message, 1);
                byte y         = message[5];
                int  z         = util.EndianBitConverter.Big.ToInt32(message, 6);
                byte direction = message[10];

                Point3 face = BlockData.GetFaceBlock(x, y, z, direction);

                byte rc = level.GetBlock(x, y, z); //block hit

                if (OnBlockChange != null)
                {
                    OnBlockChange(this, x, y, z, current_block_holding.id);
                    return;
                }

                if (OnBlockLeftClick != null)
                {
                    OnBlockLeftClick(this, x, y, z, direction);
                }
                if (PlayerBlockLeftClick != null)
                {
                    PlayerBlockLeftClick(this, x, y, z, direction);
                }
                if (cancelblockleft)
                {
                    cancelblockleft = false;
                    return;
                }

                if (BlockChange.LeftClicked.ContainsKey(rc))
                {
                    BlockChange.LeftClicked[rc].DynamicInvoke(this, new BCS(new Point3(x, y, z), 0, 0, 0, 0));
                }

                if (level.GetBlock((int)face.x, (int)face.y, (int)face.z) == 51)
                {
                    level.BlockChange((int)face.x, (int)face.y, (int)face.z, 0, 0);
                    Player.GlobalSoundEffect(face, 1004, level);
                }

                if (Server.mode == 1)
                {
                    if (BlockChange.Destroyed.ContainsKey(rc))
                    {
                        if (!(bool)BlockChange.Destroyed[rc].DynamicInvoke(this, new BCS(new Point3(x, y, z), 0, 0, 0, 0)))
                        {
                            //SendBlockChange(x, y, z, level.GetBlock(x, y, z), level.GetMeta(x, y, z));
                            Logger.Log("Delegate for " + rc + " Destroyed returned false");
                            return;
                        }
                    }

                    level.BlockChange(x, y, z, 0, 0);
                    goto doSound;
                }
                else if (BlockData.CanInstantBreak(rc))
                {
                    if (BlockChange.Destroyed.ContainsKey(rc))
                    {
                        if (!(bool)BlockChange.Destroyed[rc].DynamicInvoke(this, new BCS(new Point3(x, y, z), 0, 0, 0, 0)))
                        {
                            //SendBlockChange(x, y, z, level.GetBlock(x, y, z), level.GetMeta(x, y, z));
                            Logger.Log("Delegate for " + rc + " Destroyed returned false");
                            return;
                        }
                    }

                    short dropId = BlockDropSwitch(rc);
                    if (dropId != 0)
                    {
                        level.DropItem(x, y, z, dropId, level.GetMeta(x, y, z));
                    }

                    level.BlockChange(x, y, z, 0, 0);
                    goto doSound;
                }
                return;

doSound:
                Player.GlobalBreakEffect(x, y, z, rc, level, this);
            }
            if (message[0] == 2)
            {
                //Player is done digging
                int  x         = util.EndianBitConverter.Big.ToInt32(message, 1);
                byte y         = message[5];
                int  z         = util.EndianBitConverter.Big.ToInt32(message, 6);
                byte direction = message[10];

                Point3 face = BlockData.GetFaceBlock(x, y, z, direction);

                short id      = level.GetBlock(x, y, z);
                short storeId = id;
                byte  count   = 1;

                if (OnBlockBreak != null)
                {
                    OnBlockBreak(this, x, y, z, (byte)id, level.GetMeta(x, y, z));
                }
                if (PlayerBlockBreak != null)
                {
                    PlayerBlockBreak(this, x, y, z, (byte)id, level.GetMeta(x, y, z));
                }
                if (cancelbreak)
                {
                    cancelbreak = false;
                    return;
                }

                if (BlockChange.Destroyed.ContainsKey(id))
                {
                    if (!(bool)BlockChange.Destroyed[id].DynamicInvoke(this, new BCS(new Point3(x, y, z), 0, 0, 0, 0)))
                    {
                        //SendBlockChange(x, y, z, level.GetBlock(x, y, z), level.GetMeta(x, y, z));
                        Logger.Log("Delegate for " + id + " Destroyed returned false");
                        return;
                    }
                }

                id = BlockDropSwitch(id);

                if (id != 0)
                {
                    level.DropItem(x, y, z, id, level.GetMeta(x, y, z), count);
                }

                level.BlockChange(x, y, z, 0, 0);

                Player.GlobalBreakEffect(x, y, z, storeId, level, this);
            }
            if (message[0] == 4)
            {
                //TODO drop one of the item the player is holding!
                //inventory.Remove(inventory.current_index, 1);
            }
            if (message[0] == 5)
            {
                // TODO: Shoot arrow!
            }
        }
Exemplo n.º 4
0
            public static bool LavaFlow(Physics P, Check C)
            {
                if (C.time < 6)
                {
                    C.time++; return(false);
                }

                byte meta = P.w.GetMeta(C.x, C.y, C.z);

                if (!P.HigherLiquidCheck(C.x, C.y, C.z, 10, meta) && !P.HigherLiquidCheck(C.x, C.y, C.z, 11, meta))
                {
                    if ((meta & 0x7) >= 0x6)
                    {
                        P.AddUpdate(C.x, C.y, C.z, 0, 0);
                    }
                    else
                    {
                        P.AddUpdate(C.x, C.y, C.z, 10, (byte)Math.Min(meta + 2, 0x6));
                        if (!P.AdjacentLiquidCheck(C.x, C.y, C.z, 10) && !P.AdjacentLiquidCheck(C.x, C.y, C.z, 11))
                        {
                            C.time = 0; return(false);
                        }
                    }
                }
                else if ((meta & 0x8) != 0)
                {
                    if (!P.LavaFlowCheck(C.x, C.y - 1, C.z))
                    {
                        meta = 0; goto flowOut;
                    }
                    P.LavaFlow(C.x, C.y - 1, C.z, 0x8);
                }
                else if ((meta & 0x7) < 0x6)
                {
                    goto flowOut;
                }
                else
                {
                    P.LavaFlow(C.x, C.y - 1, C.z, 0x8);
                }
                return(true);

flowOut:
                if (P.LavaFlowCheck(C.x, C.y - 1, C.z))
                {
                    P.LavaFlow(C.x, C.y - 1, C.z, 0x8);
                    if (!P.AdjacentLiquidCheck(C.x, C.y, C.z, 10) && !P.AdjacentLiquidCheck(C.x, C.y, C.z, 11))
                    {
                        P.LavaFlow(C.x + 1, C.y, C.z, 0x6);
                        P.LavaFlow(C.x - 1, C.y, C.z, 0x6);
                        P.LavaFlow(C.x, C.y, C.z + 1, 0x6);
                        P.LavaFlow(C.x, C.y, C.z - 1, 0x6);
                    }
                }
                else
                {
                    if (P.AdjacentLiquidCheck(C.x, C.y, C.z, 8) || P.AdjacentLiquidCheck(C.x, C.y, C.z, 9))
                    {
                        if ((meta & 0x7) == 0)
                        {
                            P.AddUpdate(C.x, C.y, C.z, 49, 0);
                        }
                        else
                        {
                            P.AddUpdate(C.x, C.y, C.z, 4, 0);
                        }
                        Player.GlobalSoundEffect(C.x, (byte)C.y, C.z, 1004, P.w);
                        //Player.GlobalSoundEffect(C.x, (byte)C.y, C.z, 2000, 4, w);
                    }
                    else
                    {
                        meta += 2;
                        P.LavaFlow(C.x + 1, C.y, C.z, meta);
                        P.LavaFlow(C.x - 1, C.y, C.z, meta);
                        P.LavaFlow(C.x, C.y, C.z + 1, meta);
                        P.LavaFlow(C.x, C.y, C.z - 1, meta);

                        if (P.w.GetBlock(C.x, C.y - 1, C.z) == 8 || P.w.GetBlock(C.x, C.y - 1, C.z) == 9)
                        {
                            P.AddUpdate(C.x, C.y - 1, C.z, 4, 0);
                            Player.GlobalSoundEffect(C.x, (byte)C.y, C.z, 1004, P.w);
                        }
                    }
                }
                return(true);
            }