MCSharp.World.Map.Blockchange C# (CSharp) Method

Blockchange() public method

public Blockchange ( Player p, ushort x, ushort y, ushort z, byte type ) : void
p Player
x ushort
y ushort
z ushort
type byte
return void
        public void Blockchange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            try
            {
                if (x >= width || y > depth || z >= height) { p.Kick("Building outside boundaries!"); return; }
                if (y == depth) { return; }
                byte b = GetTile(x, y, z);

                if (Block.Convert(b) != Block.Convert(type))    //Should save bandwidth sending identical looking blocks, like air/op_air changes.
                {
                    Player.GlobalBlockchange(this, x, y, z, type);
                }

                if (b == Block.sponge && (Physics == Physics.Normal || Physics == Physics.Advanced) && type != Block.sponge)
                {
                    PhysSpongeRemoved(PosToInt(x, y, z));
                }

                SetTile(x, y, z, type);               //Updates server level blocks

                if (Physics > 0)
                {
                    if (Block.Physics(type))
                    {
                        AddCheck(PosToInt(x, y, z));
                    }
                }
                changed = true;
            }
            catch (Exception e)
            {
                Logger.Log(p.name + " has triggered a block change error in Map on " + name, LogType.Error);
                Logger.Log(e.Message, LogType.ErrorMessage);
                Player.GlobalMessageOps(p.name + " has triggered a block change error in level.cs on " + name);
                IRCBot.Say(p.name + " has triggered a block change error in level.cs on " + name);
            }
        }

Same methods

Map::Blockchange ( ushort x, ushort y, ushort z, byte type ) : void

Usage Example

Exemplo n.º 1
0
        //
        void AddTree(Map Lvl, ushort x, ushort z, ushort y, Random Rand)
        {
            byte height = (byte)Rand.Next(4, 7);

            for (ushort zz = 0; zz < height; zz++)
            {
                if (Lvl.GetTile(x, (ushort)(z + zz), y) == Block.air)   //Not likly to trigger anyway
                {
                    Lvl.Blockchange(x, (ushort)(z + zz), y, Block.trunk);
                }
                else
                {
                    height = (byte)zz;
                }
            }

            short top = (short)(height - 3);

            for (short xx = (short)-top; xx <= top; ++xx)
            {
                for (short yy = (short)-top; yy <= top; ++yy)
                {
                    for (short zz = (short)-top; zz <= top; ++zz)
                    {
                        if (Lvl.GetTile((ushort)(x + xx), (ushort)(z + zz + height), (ushort)(y + yy)) == Block.air)   //Not likly to trigger anyway
                        {
                            //short Dist = (short)(Math.Abs(xx) + Math.Abs(yy) + Math.Abs(zz));
                            short Dist = (short)(Math.Sqrt(xx * xx + yy * yy + zz * zz));
                            if (Dist < top + 1)
                            {
                                if (Rand.Next((int)(Dist)) < 2)
                                {
                                    Lvl.Blockchange((ushort)(x + xx), (ushort)(z + zz + height), (ushort)(y + yy), Block.leaf);
                                }
                            }
                        }
                    }
                }
            }
        }
All Usage Examples Of MCSharp.World.Map::Blockchange