1
0
Fork 0

Fix End stuff

new_mapgen_api
kay27 2022-02-18 04:17:27 +04:00
parent 34ab356193
commit 792c740a4d
2 changed files with 13 additions and 8 deletions

View File

@ -3,8 +3,8 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
local math = math local math_random = math.random
local table = table local math_floor = math.floor
--- Plant parts --- --- Plant parts ---
@ -24,7 +24,7 @@ local chorus_flower_box = {
-- Helper function -- Helper function
local function round(num, idp) local function round(num, idp)
local mult = 10^(idp or 0) local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult return math_floor(num * mult + 0.5) / mult
end end
-- This is a list of nodes that SHOULD NOT call their detach function -- This is a list of nodes that SHOULD NOT call their detach function
@ -344,6 +344,7 @@ end
-- Grow a single step of a chorus plant at pos. -- Grow a single step of a chorus plant at pos.
-- Pos must be a chorus flower. -- Pos must be a chorus flower.
function mcl_end.grow_chorus_plant_step(pos, node, pr) function mcl_end.grow_chorus_plant_step(pos, node, pr)
local pr = pr or PseudoRandom()
local new_flower_buds = {} local new_flower_buds = {}
local above = { x = pos.x, y = pos.y + 1, z = pos.z } local above = { x = pos.x, y = pos.y + 1, z = pos.z }
local node_above = minetest.get_node(above) local node_above = minetest.get_node(above)
@ -452,16 +453,20 @@ function mcl_end.grow_chorus_plant_step(pos, node, pr)
return new_flower_buds return new_flower_buds
end end
local fast_randomizer = {
next = function(self, min, max)
return math_random(min, max)
end
}
--- ABM --- --- ABM ---
local seed = minetest.get_mapgen_setting("seed")
local pr = PseudoRandom(seed)
minetest.register_abm({ minetest.register_abm({
label = "Chorus plant growth", label = "Chorus plant growth",
nodenames = { "mcl_end:chorus_flower" }, nodenames = { "mcl_end:chorus_flower" },
interval = 35.0, interval = 35.0,
chance = 4.0, chance = 4.0,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
mcl_end.grow_chorus_plant_step(pos, node, pr) mcl_end.grow_chorus_plant_step(pos, node, fast_randomizer)
end, end,
}) })

View File

@ -10,7 +10,7 @@ minetest.register_entity("mcl_end:ender_eye", {
-- Save and restore age -- Save and restore age
get_staticdata = function(self) get_staticdata = function(self)
return tostring(self._age) return tostring(self._age) or "0"
end, end,
on_activate = function(self, staticdata, dtime_s) on_activate = function(self, staticdata, dtime_s)
local age = tonumber(staticdata) local age = tonumber(staticdata)
@ -87,7 +87,7 @@ minetest.register_craftitem("mcl_end:ender_eye", {
end end
local origin = user:get_pos() local origin = user:get_pos()
origin.y = origin.y + 1.5 origin.y = origin.y + 1.5
local strongholds = mcl_structures.get_registered_structures("stronghold") local strongholds = mcl_structures.strongholds
local dim = mcl_worlds.pos_to_dimension(origin) local dim = mcl_worlds.pos_to_dimension(origin)
local is_creative = minetest.is_creative_enabled(user:get_player_name()) local is_creative = minetest.is_creative_enabled(user:get_player_name())