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); } } }
public void Trigger(int x, int y, int z) { // Find where the snow should drop down to (if at all) int dropZ = z; while (dropZ > 0) { if (!LetsSnowThrough(map.GetBlock(x, y, dropZ - 1))) { break; } dropZ--; } // If snow can drop down, start falling... bool snowHasDropped = false; if (dropZ != z) { Block oldBlock = map.GetBlock(x, y, dropZ); map.SetBlockNoNeighborChange(null, x, y, z, Block.Air); if (oldBlock != Block.Snow) { snowHasDropped = true; } z = dropZ; } if (ThisShouldMelt(x, y, z)) { // If we have any hot neighbors, queue melting (2 ticks from now) map.PhysicsQueueTick(x, y, z, Block.Snow); } else if (snowHasDropped) { // Land the dropped snow map.SetBlock(null, x, y, dropZ, Block.Snow); } }