示例#1
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;
                        }
                    }
            }
        }
示例#2
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;
                        }
                    }
            }
        }
示例#3
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);
                        }
                    }
                }
            }
        }