Fix End stuff

This commit is contained in:
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 math = math
local table = table
local math_random = math.random
local math_floor = math.floor
--- Plant parts ---
@ -24,7 +24,7 @@ local chorus_flower_box = {
-- Helper function
local function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
return math_floor(num * mult + 0.5) / mult
end
-- 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.
-- Pos must be a chorus flower.
function mcl_end.grow_chorus_plant_step(pos, node, pr)
local pr = pr or PseudoRandom()
local new_flower_buds = {}
local above = { x = pos.x, y = pos.y + 1, z = pos.z }
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
end
local fast_randomizer = {
next = function(self, min, max)
return math_random(min, max)
end
}
--- ABM ---
local seed = minetest.get_mapgen_setting("seed")
local pr = PseudoRandom(seed)
minetest.register_abm({
label = "Chorus plant growth",
nodenames = { "mcl_end:chorus_flower" },
interval = 35.0,
chance = 4.0,
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,
})

View File

@ -10,7 +10,7 @@ minetest.register_entity("mcl_end:ender_eye", {
-- Save and restore age
get_staticdata = function(self)
return tostring(self._age)
return tostring(self._age) or "0"
end,
on_activate = function(self, staticdata, dtime_s)
local age = tonumber(staticdata)
@ -87,7 +87,7 @@ minetest.register_craftitem("mcl_end:ender_eye", {
end
local origin = user:get_pos()
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 is_creative = minetest.is_creative_enabled(user:get_player_name())