예제 #1
0
        public override void Physics(Level level, int pos)
        {
            BlockPos blockPos = level.IntToBlockPos(pos);
            BlockPos belowBlockPos = blockPos.Diff(0, -1, 0);

            MCBlocks below = level.GetTile(belowBlockPos);

            if (below == MCBlocks.Zero)
            {
            }
            else if (Crushable.Contains((byte)below))
            {
                level.PhysicsBlockChange(belowBlockPos, MCBlocks.Sand);
                level.PhysicsBlockChange(blockPos, MCBlocks.Air);
                //if(level.physics.PhysicsUpdates.Contains(level.PosToInt(belowPos))) return;
                //level.physics.PhysicsUpdates.Add(level.PosToInt(belowPos));
            }
            else if (level.Physics.Realistic)
            {
                for (int x = -1; x < 2; ++x)
                    for (int z = -1; z < 2; ++z)
                    {
                        if (Math.Abs(x) == 1 && Math.Abs(z) == 1) continue;
                        if (belowBlockPos.X + x < 0 || belowBlockPos.Z + z < 0) continue;
                        BlockPos aroundPos = blockPos.Diff(x, 0, z);
                        BlockPos aroundBelowPos = belowBlockPos.Diff(x, 0, z);
                        if (level.NotInBounds(aroundBelowPos)) continue;

                        int testPos = level.PosToInt(aroundPos);
                        int newPos = level.PosToInt(aroundBelowPos);
                        if (Crushable.Contains(level.BlockData[newPos]) && level.BlockData[testPos] == 0)
                        {
                            level.PhysicsBlockChange(aroundBelowPos, MCBlocks.Sand);
                            level.PhysicsBlockChange(blockPos, MCBlocks.Air);
                            //if (level.physics.PhysicsUpdates.Contains(level.PosToInt(aroundBelowPos))) return;
                            //level.physics.PhysicsUpdates.Add(level.PosToInt(aroundBelowPos));
                            return;
                        }
                    }
            }
        }
예제 #2
0
        public override void Physics(Level level, int pos)
        {
            BlockPos blockPos = level.IntToBlockPos(pos);
            BlockPos belowBlockPos = blockPos.Diff(0, -1, 0);

            if (!level.Physics.OtherData.ContainsKey(pos)) return;

            var current = (byte)(level.Physics.OtherData[pos] - 1);
            if (current == 0) return;

            int belowPos = level.PosToInt(belowBlockPos);
            byte type = level.BlockData[belowPos];

            if (type == (byte)MCBlocks.LavaStill)
            {
                if (level.Physics.OtherData[belowPos] < current)
                {
                    level.Physics.OtherData.Remove(belowPos);
                    level.Physics.OtherData.Add(belowPos, current);
                }
            }
            else if (Crushable.Contains(type))
            {
                level.Physics.OtherData.Remove(belowPos);
                level.Physics.OtherData.Add(belowPos, current);
                level.PhysicsBlockChange(belowBlockPos, MCBlocks.LavaStill);
            }
            else
            {
                for (int x = -1; x < 2; ++x)
                    for (int z = -1; z < 2; ++z)
                    {
                        if (Math.Abs(x) == 1 && Math.Abs(z) == 1) continue;
                        if (blockPos.X + x < 0 || blockPos.Z + z < 0) continue;

                        BlockPos aroundPos = blockPos.Diff(x, 0, z);

                        if (level.NotInBounds(aroundPos)) continue;

                        int newPos = level.PosToInt(aroundPos);
                        byte newType = level.BlockData[newPos];

                        if (newType == (byte)MCBlocks.LavaStill)
                        {
                            if (level.Physics.OtherData.ContainsKey(newPos))
                            {
                                if (level.Physics.OtherData[newPos] >= current) continue;
                                level.Physics.OtherData[newPos] = current;
                            }
                            else
                            {
                                level.Physics.OtherData.Add(newPos, current);
                            }
                        }
                        else if (Crushable.Contains(newType))
                        {
                            level.Physics.OtherData.Remove(newPos);
                            level.Physics.OtherData.Add(newPos, current);
                            level.PhysicsBlockChange(aroundPos, MCBlocks.LavaStill);
                            //if (level.physics.PhysicsUpdates.Contains(level.PosToInt(aroundBelowPos))) return;
                            //level.physics.PhysicsUpdates.Add(level.PosToInt(aroundBelowPos));
                            return;
                        }
                    }
            }
        }
예제 #3
0
        public override void Physics(Level level, int pos)
        {
            BlockPos blockPos = level.IntToBlockPos(pos);
            BlockPos aboveBlockPos = blockPos.Diff(0, 1, 0);

            int abovePos = level.PosToInt(aboveBlockPos);

            byte type = level.BlockData[abovePos];

            if (LightPass.Contains(type)) return;

            level.PhysicsBlockChange(blockPos, MCBlocks.Dirt);
        }
예제 #4
0
        public override void Physics(Level level, int pos)
        {
            BlockPos blockPos = level.IntToBlockPos(pos);

            //This code works, but in order to change dirt into grass we have to check below every block in the same way, so we wont use it for now
            //if (level.physics.realistic)
            //{
            //	for (int y = blockPos.y + 1; y < level.sizeY; ++y)
            //	{
            //		BlockPos currentBlockPos = new BlockPos(blockPos.x, (ushort)y, blockPos.z);
            //		int currentPos = level.PosToInt(currentBlockPos);

            //		byte type = level.blocks[currentPos];

            //		if (!Block.LightPass.Contains(type)) { return; }
            //	}
            //}
            //else
            {
                BlockPos currentBlockPos = blockPos.Diff(0, 1, 0);
                int currentPos = level.PosToInt(currentBlockPos);

                byte type = level.BlockData[currentPos];

                if (!LightPass.Contains(type)) return;
            }
            if (level.BlockData[pos] != (byte)MCBlocks.Dirt) return;
            level.PhysicsBlockChange(blockPos, MCBlocks.Grass);
        }
예제 #5
0
        public override void Physics(Level level, int pos)
        {
            BlockPos blockPos = level.IntToBlockPos(pos);

            BlockPos belowBlockPos = blockPos.Diff(0, -1, 0);
            int belowPos = level.PosToInt(belowBlockPos);

            if (level.BlockData[belowPos] == (byte)MCBlocks.Staircasestep)
            {
                level.PhysicsBlockChange(belowBlockPos, MCBlocks.Staircasefull);
                level.PhysicsBlockChange(blockPos, MCBlocks.Air);
            }
        }
예제 #6
0
        public override void Physics(Level level, int pos)
        {
            BlockPos blockPos = level.IntToBlockPos(pos);

            for (int x = -1; x < 2; ++x)
            {
                for (int y = -1; y < 2; ++y)
                {
                    for (int z = -1; z < 2; ++z)
                    {
                        BlockPos currentBlockPos = blockPos.Diff(x, y, z);
                        int currentPos = level.PosToInt(currentBlockPos);

                        if (level.NotInBounds(currentBlockPos)) continue;

                        var type = (MCBlocks)level.BlockData[currentPos];

                        if (type == MCBlocks.Water || type == MCBlocks.WaterStill || type == MCBlocks.Lava ||
                            type == MCBlocks.LavaStill)
                        {
                            level.PhysicsBlockChange(currentBlockPos, MCBlocks.Air);
                        }
                    }
                }
            }
        }