示例#1
0
 public void OnNeighborUpdated(int x, int y, int z, Block thisBlock, Block updatedNeighbor)
 {
     if (Config.PhysicsFloodProtection && z >= map.WaterLevel)
     {
         return;
     }
     if ((thisBlock == Block.Water || thisBlock == Block.StillWater) &&
         (updatedNeighbor == Block.Lava || updatedNeighbor == Block.StillLava))
     {
         map.SetBlock(null, x, y, z, LavaPhysics.LavaPlusWater);
     }
     else if (thisBlock == Block.Water)
     {
         map.PhysicsQueueTick(x, y, z, updatedNeighbor);
     }
     else if (thisBlock == Block.StillWater)
     {
         if (CanSpreadTo(map.GetBlock(x - 1, y, z)) ||
             CanSpreadTo(map.GetBlock(x + 1, y, z)) ||
             CanSpreadTo(map.GetBlock(x, y - 1, z)) ||
             CanSpreadTo(map.GetBlock(x, y + 1, z)) ||
             CanSpreadTo(map.GetBlock(x, y, z - 1)))
         {
             map.SetBlockNoUpdate(x, y, z, Block.Water);
             map.PhysicsQueueTick(x, y, z, Block.Water);
         }
     }
 }
示例#2
0
        public void Trigger(int x, int y, int z)
        {
            int dropZ = z;

            while (dropZ > 0)
            {
                if (!LetsSandThrough(map.GetBlock(x, y, dropZ - 1)))
                {
                    break;
                }
                dropZ--;
            }

            if (dropZ == z)
            {
                return;
            }
            Block oldBlock = map.GetBlock(x, y, dropZ);

            if (oldBlock != Block.Air)
            {
                map.SetBlockNoUpdate(x, y, dropZ, Block.Air);
            }
            map.Swap(x, y, z,
                     x, y, dropZ);
        }
示例#3
0
        void TriggerSapling(int x, int y, int z)
        {
            if (!Config.PhysicsPlants)
            {
                return;
            }
            Block blockUnder = map.GetBlock(x, y, z - 1);

            if (blockUnder != Block.Grass && blockUnder != Block.Dirt || !IsLit(x, y, z))
            {
                map.SetBlock(null, x, y, z, Block.Air);
                return;
            }
            if (Config.PhysicsTrees && random.Next(5) == 0)
            {
                map.SetBlockNoUpdate(x, y, z, Block.Air);
                if (!map.GrowTree(random, x, y, z))
                {
                    map.SetBlockNoUpdate(x, y, z, Block.Sapling);
                }
            }
        }