nether_api.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. Modding/interop guide to Nether
  2. ===============================
  3. For portals API see portal_api.txt
  4. The Nether mod exposes some of its functions and data via the lua global
  5. `nether` and `nether.mapgen`
  6. * `nether.DEPTH_CEILING`: [read-only] Y value of the top of the Nether.
  7. * `nether.DEPTH_FLOOR`: [read-only] Y value of the bottom of the Nether.
  8. * `nether.DEPTH_FLOOR_LAYERS`: [writable] Gives the bottom Y of all
  9. locations that wish to be considered part of the Nether.
  10. DEPTH_FLOOR_LAYERS Allows mods to insert extra layers below the
  11. Nether, by knowing where their layer ceiling should start, and letting
  12. the layers be included in effects which only happen in the Nether.
  13. If a mod wishes to add a layer below the Nether it should read
  14. `nether.DEPTH_FLOOR_LAYERS` to find the bottom Y of the Nether and any
  15. other layers already under the Nether. The mod should leave a small gap
  16. between DEPTH_FLOOR_LAYERS and its ceiling (e.g. use DEPTH_FLOOR_LAYERS - 6
  17. for its ceiling Y, so there is room to shift edge-case biomes), then set
  18. `nether.DEPTH_FLOOR_LAYERS` to reflect the mod's floor Y value, and call
  19. `shift_existing_biomes()` with DEPTH_FLOOR_LAYERS as the `floor_y` argument.
  20. * `nether.NETHER_REALM_ENABLED`: [read-only] Gets the value of the "Enable
  21. Nether realm & portal" setting the nether mod exposes in Minetest's
  22. "All Settings" -> "Mods" -> "nether" options.
  23. When false, the entire nether mapgen is disabled (not run), and the portal
  24. to it is not registered. Reasons someone might disable the Nether realm
  25. include if a nether-layer mod was to be used as the Nether instead, or if
  26. the portal mechanic was desired in a game without the Nether, etc.
  27. * `nether.useBiomes`: [read-only] When this is false, the Nether interop
  28. functions below are not available (nil).
  29. Indicates that the biomes-enabled mapgen is in use. The Nether mod falls back
  30. to older mapgen code for v6 maps and old versions of Minetest, the older
  31. mapgen code doesn't use biomes and doesn't provide API/interop functions.
  32. Mapgen functions available when nether.useBiomes is true
  33. --------------------------------------------------------
  34. The following functions are nil if `nether.useBiomes` is false,
  35. and also nil if `nether.NETHER_REALM_ENABLED` is false.
  36. * `nether.mapgen.shift_existing_biomes(floor_y, ceiling_y)` Move any existing
  37. biomes out of the y-range specified by `floor_y` and `ceiling_y`.
  38. * `nether.mapgen.get_region(pos)`: Returns two values, (region, noise) where
  39. `region` is a value from `nether.mapgen.RegionEnum` and `noise` is the
  40. unadjusted cave perlin value.
  41. * `nether.mapgen.RegionEnum` values are tables which contain an invariant
  42. `name` and a localized `desc`. Current region names include overworld,
  43. positive, positive shell, center, center shell, negative, and negative
  44. shell.
  45. "positive" corresponds to conventional Nether caverns, and "center"
  46. corresponds to the Mantle region.
  47. * `nether.mapgen.get_cave_point_perlin()`: Returns the PerlinNoise object for
  48. the Nether's cavern noise.
  49. * `nether.mapgen.get_cave_perlin_at(pos)`: Returns the Nether cavern noise
  50. value at a given 3D position.
  51. Other mapgen functions
  52. -------------------------------------------
  53. If the Nether realm is enabled, then this function will be available
  54. regardless of whether `nether.useBiomes` is true:
  55. * `nether.find_nether_ground_y(target_x, target_z, start_y, player_name)`
  56. Uses knowledge of the nether mapgen algorithm to return a suitable ground
  57. level for placing a portal.
  58. * `player_name` is optional, allowing a player to spawn a remote portal
  59. in their own protected areas.