init.lua 970 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. local S = minetest.get_translator("map_barriers")
  2. undiggable_node_api.register_barrier("map_barriers:bedrock",
  3. {
  4. description = S("Bedrock"),
  5. tiles = {"basic_ground_nodes_stone.png"},
  6. sounds = generic_media.node_sound_stone_defaults(),
  7. })
  8. --generating bedrock layer
  9. local c_bedrock = minetest.get_content_id("map_barriers:bedrock")
  10. local lvm_buffer = {}
  11. local function on_generated(minp, maxp, blockseed)
  12. if not (-20 <= maxp.y and -20 >= minp.y)
  13. then
  14. return
  15. end
  16. local lvm, emin, emax = minetest.get_mapgen_object("voxelmanip")
  17. --passing a buffer increases performance by lowering need to
  18. --allocate memory
  19. local data = lvm:get_data(lvm_buffer)
  20. local a = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
  21. for z = emin.z, emax.z
  22. do
  23. for x = emin.x, emax.x
  24. do
  25. local index = a:index(x, -20, z)
  26. data[index] = c_bedrock
  27. end
  28. end
  29. lvm:set_data(data)
  30. lvm:calc_lighting()
  31. lvm:write_to_map(data)
  32. end
  33. minetest.register_on_generated(on_generated)