Simple way to prevent mapgen generating floating falling nodes

Post Reply
User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Simple way to prevent mapgen generating floating falling nodes

by Wuzzy » Post

If you ever were annoyed by the fact that in your game/mod, the mapgen generates falling nodes (like sand, gravel) above air (for example, if you generate sand as an ore in stone), I have recently found a very simple way to fix this. By adding a decoration:

Code: Select all

-- Turn hanging sand into sandstone
default.register_decoration(
   {
      deco_type = "simple",
      place_on = {"default:sand"},
      sidelen = 16,
      fill_ratio = 11.0,
      decoration = {"default:sandstone"},
      y_min = -31000,
      y_max = 31000,
      place_offset_y = -1,
      flags = "all_ceilings,force_placement",
})
Explanation: This replaces "hanging sand" with sandstone. all_ceilings first makes sure that only ceilings of the generated map are checked. place_offset_y=-1 makes sure the decoration is placed in the sand itself, and not below the sand. The offset is negative because all_ceilings inverts the offset. The force_placement flag is necessary because we place the sandstone into the sand. Since we know the node is always sand, the force-placement is safe. Finally, fill_ratio is a number above 10, which is a special case for "full coverage".

The sidelen I chose is arbitrary, I don't know which value would be the best (for performance).

This works surprisingly well. I don't know how good the performance of this is (no idea how to benchmark decorations).

Note that not all games would want this, of course. Some games don't consider the "floating sand" a problem, and some might even embrace it. In that case, you can ignore my trick. ;-)

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests