init.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. local S = minetest.get_translator("bedrock2")
  2. local bedrock = {}
  3. bedrock.layer = -30912 -- determined as appropriate by experiment
  4. bedrock.node = {name = "bedrock2:bedrock"}
  5. local depth = tonumber(minetest.settings:get("bedrock2_y"))
  6. if depth ~= nil then
  7. bedrock.layer = depth
  8. end
  9. minetest.register_on_generated(function(minp, maxp)
  10. if maxp.y >= bedrock.layer and minp.y <= bedrock.layer then
  11. local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
  12. local data = vm:get_data()
  13. local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
  14. local c_bedrock = minetest.get_content_id("bedrock2:bedrock")
  15. for x = minp.x, maxp.x do
  16. for z = minp.z, maxp.z do
  17. local p_pos = area:index(x, bedrock.layer, z)
  18. data[p_pos] = c_bedrock
  19. end
  20. end
  21. vm:set_data(data)
  22. vm:calc_lighting()
  23. vm:update_liquids()
  24. vm:write_to_map()
  25. end
  26. end)
  27. minetest.register_node("bedrock2:bedrock", {
  28. description = S("Bedrock"),
  29. _doc_items_longdesc = S("Bedrock is a very hard block. It cannot be mined, altered, destroyed or moved by any means. It appears at the bottom of the world in a flat layer."),
  30. tiles = {"bedrock2_bedrock.png"},
  31. groups = {immortal=1, not_in_creative_inventory=1, },
  32. sounds = { footstep = { name = "bedrock2_step", gain = 1 } },
  33. is_ground_content = false,
  34. on_blast = function() end,
  35. on_destruct = function () end,
  36. can_dig = function() return false end,
  37. diggable = false,
  38. drop = "",
  39. })