コード例 #1
0
ファイル: Level.Blocks.cs プロジェクト: Benedani/MCGalaxy
        public void UpdateBlock(Player p, ushort x, ushort y, ushort z,
                                byte block, byte extBlock, ushort flags)
        {
            byte old = GetTile(x, y, z), oldExt = 0;

            if (old == Block.custom_block)
            {
                oldExt = GetExtTile(x, y, z);
            }

            bool drawn = (flags & BlockDBFlags.ManualPlace) != 0;

            if (!DoBlockchange(p, x, y, z, block, extBlock, drawn))
            {
                return;
            }
            BlockDB.Add(p, x, y, z, flags,
                        old, oldExt, block, extBlock);

            int index = PosToInt(x, y, z);

            if (bufferblocks)
            {
                BlockQueue.Addblock(p, index, block, extBlock);
            }
            else
            {
                Player.GlobalBlockchange(this, x, y, z, block, extBlock);
            }
        }
コード例 #2
0
ファイル: Level.Blocks.cs プロジェクト: ProtheanGod/KingMC
        public void UpdateBlock(Player p, ushort x, ushort y, ushort z, ExtBlock block,
                                ushort flags = BlockDBFlags.ManualPlace, bool buffered = false)
        {
            ExtBlock old   = GetBlock(x, y, z);
            bool     drawn = (flags & BlockDBFlags.ManualPlace) != 0;
            int      type  = DoBlockchange(p, x, y, z, block, drawn);

            if (type == 0)
            {
                return;            // no block change performed
            }
            BlockDB.Cache.Add(p, x, y, z, flags, old, block);
            if (type == 1)
            {
                return;            // not different visually
            }
            int index = PosToInt(x, y, z);

            if (buffered)
            {
                BlockQueue.Addblock(p, index, block);
            }
            else
            {
                Player.GlobalBlockchange(this, x, y, z, block);
            }
        }
コード例 #3
0
ファイル: Level.Blocks.cs プロジェクト: ProtheanGod/KingMC
 public void Blockchange(Player p, ushort x, ushort y, ushort z, ExtBlock block)
 {
     if (DoBlockchange(p, x, y, z, block) == 2)
     {
         Player.GlobalBlockchange(this, x, y, z, block);
     }
 }
コード例 #4
0
ファイル: Level.Blocks.cs プロジェクト: Peteys93/MCGalaxy
 public void Blockchange(Player p, ushort x, ushort y, ushort z, byte type, byte extType = 0)
 {
     if (DoBlockchange(p, x, y, z, type, extType))
     {
         Player.GlobalBlockchange(this, x, y, z, type, extType);
     }
 }
コード例 #5
0
ファイル: Level.Blocks.cs プロジェクト: ProtheanGod/KingMC
 public void Blockchange(int b, ExtBlock block, bool overRide = false,
                         PhysicsArgs data = default(PhysicsArgs), bool addUndo = true)   //Block change made by physics
 {
     if (DoPhysicsBlockchange(b, block, overRide, data, addUndo))
     {
         Player.GlobalBlockchange(this, b, block);
     }
 }
コード例 #6
0
ファイル: Level.Blocks.cs プロジェクト: Benedani/MCGalaxy
 public void Blockchange(Player p, ushort x, ushort y, ushort z,
                         byte block, byte extBlock = 0)
 {
     if (DoBlockchange(p, x, y, z, block, extBlock))
     {
         Player.GlobalBlockchange(this, x, y, z, block, extBlock);
     }
 }
コード例 #7
0
ファイル: Level.Blocks.cs プロジェクト: Peteys93/MCGalaxy
 public void Blockchange(int b, byte type, bool overRide = false,
                         PhysicsArgs data = default(PhysicsArgs),
                         byte extType     = 0, bool addUndo = true) //Block change made by physics
 {
     if (DoPhysicsBlockchange(b, type, overRide, data, extType, addUndo))
     {
         Player.GlobalBlockchange(this, b, type, extType);
     }
 }
コード例 #8
0
ファイル: Player.Handlers.cs プロジェクト: Benedani/MCGalaxy
        /// <summary> Updates the block at the given position, also turning the block below to dirt if the block above blocks light. </summary>
        internal bool ChangeBlock(ushort x, ushort y, ushort z, byte block, byte extBlock)
        {
            if (!level.DoBlockchange(this, x, y, z, block, extBlock))
            {
                return(false);
            }
            Player.GlobalBlockchange(level, x, y, z, block, extBlock);

            if (level.GrassGrow && level.GetTile(x, (ushort)(y - 1), z) == Block.grass &&
                !Block.LightPass(block, extBlock, level.CustomBlockDefs))
            {
                level.Blockchange(this, x, (ushort)(y - 1), z, Block.dirt);
            }
            return(true);
        }
コード例 #9
0
        /// <summary> Updates the block at the given position, mainly intended for manual changes by the player. </summary>
        /// <remarks> Adds to the BlockDB. Also turns block below to grass/dirt depending on light. </remarks>
        /// <returns> Return code from DoBlockchange </returns>
        public int ChangeBlock(ushort x, ushort y, ushort z, BlockID block)
        {
            BlockID old  = level.GetBlock(x, y, z);
            int     type = level.DoBlockchange(this, x, y, z, block);

            if (type == 0)
            {
                return(type);                                               // no change performed
            }
            if (type == 2)
            {
                Player.GlobalBlockchange(level, x, y, z, block);            // different visually
            }
            ushort flags = BlockDBFlags.ManualPlace;

            if (painting && CollideType.IsSolid(level.CollideType(old)))
            {
                flags = BlockDBFlags.Painted;
            }

            level.BlockDB.Cache.Add(this, x, y, z, flags, old, block);
            y--; // check for growth at block below

            bool grow = level.Config.GrassGrow && (level.physics == 0 || level.physics == 5);

            if (!grow || level.CanAffect(this, x, y, z) != null)
            {
                return(type);
            }
            BlockID below = level.GetBlock(x, y, z);

            BlockID grass = level.Props[below].GrassBlock;

            if (grass != Block.Invalid && block == Block.Air)
            {
                level.Blockchange(this, x, y, z, grass);
            }

            BlockID dirt = level.Props[below].DirtBlock;

            if (dirt != Block.Invalid && !level.LightPasses(block))
            {
                level.Blockchange(this, x, y, z, dirt);
            }
            return(type);
        }
コード例 #10
0
ファイル: Player.Handlers.cs プロジェクト: ProtheanGod/KingMC
        /// <summary> Updates the block at the given position, mainly intended for manual changes by the player. </summary>
        /// <remarks> Adds to the BlockDB. Also turns block below to grass/dirt depending on light. </remarks>
        /// <returns> Return code from DoBlockchange </returns>
        public int ChangeBlock(ushort x, ushort y, ushort z, ExtBlock block)
        {
            ExtBlock old  = level.GetBlock(x, y, z);
            int      type = level.DoBlockchange(this, x, y, z, block);

            if (type == 0)
            {
                return(type);                                               // no change performed
            }
            if (type == 2)
            {
                Player.GlobalBlockchange(level, x, y, z, block);            // different visually
            }
            ushort flags = BlockDBFlags.ManualPlace;

            if (painting && CollideType.IsSolid(level.CollideType(old)))
            {
                flags = BlockDBFlags.Painted;
            }
            level.BlockDB.Cache.Add(this, x, y, z, flags, old, block);

            bool autoGrass = level.Config.GrassGrow && (level.physics == 0 || level.physics == 5);

            if (!autoGrass)
            {
                return(type);
            }
            ExtBlock below = level.GetBlock(x, (ushort)(y - 1), z);

            ushort grassIdx = level.Props[below.Index].GrassIndex;

            if (grassIdx != Block.Invalid && block.BlockID == Block.Air)
            {
                level.Blockchange(this, x, (ushort)(y - 1), z, ExtBlock.FromIndex(grassIdx));
            }

            ushort dirtIdx = level.Props[below.Index].DirtIndex;

            if (dirtIdx != Block.Invalid && !level.LightPasses(block))
            {
                level.Blockchange(this, x, (ushort)(y - 1), z, ExtBlock.FromIndex(dirtIdx));
            }
            return(type);
        }
コード例 #11
0
ファイル: Level.Blocks.cs プロジェクト: Peteys93/MCGalaxy
        public void UpdateBlock(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            if (!DoBlockchange(p, x, y, z, type, extType))
            {
                return;
            }
            BlockPos bP = default(BlockPos);

            bP.name  = p.name;
            bP.index = PosToInt(x, y, z);
            bP.SetData(type, extType, type == 0);
            blockCache.Add(bP);

            if (bufferblocks)
            {
                BlockQueue.Addblock(p, bP.index, type, extType);
            }
            else
            {
                Player.GlobalBlockchange(this, x, y, z, type, extType);
            }
        }