Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hidden fireflies don't work outside vanilla biomes #2966

Open
CowboyLva opened this issue Jul 12, 2022 · 5 comments
Open

Hidden fireflies don't work outside vanilla biomes #2966

CowboyLva opened this issue Jul 12, 2022 · 5 comments
Labels

Comments

@CowboyLva
Copy link

CowboyLva commented Jul 12, 2022

Tested on 5.5.1 Arch release(includes mtg in the package) and before that self compiled 5.5.0 with a stable branch of mtg.

Both have same results, fireflies work on vanilla biomes, but once used outside those the hide/unhide fuctions seem not to work.

I can get permanent fireflies by changing hidden fireflies to fireflies. Said fireflies will not change to their hidden variant.

Tested mods: Extra Biomes(ebiomes), Ethereal(ethereal).

@appgurueu
Copy link
Contributor

appgurueu commented Jul 12, 2022

Relevant code:

-- register fireflies as decorations
if minetest.get_mapgen_setting("mg_name") == "v6" then
minetest.register_decoration({
name = "fireflies:firefly_low",
deco_type = "simple",
place_on = "default:dirt_with_grass",
place_offset_y = 2,
sidelen = 80,
fill_ratio = 0.0002,
y_max = 31000,
y_min = 1,
decoration = "fireflies:hidden_firefly",
})
minetest.register_decoration({
name = "fireflies:firefly_high",
deco_type = "simple",
place_on = "default:dirt_with_grass",
place_offset_y = 3,
sidelen = 80,
fill_ratio = 0.0002,
y_max = 31000,
y_min = 1,
decoration = "fireflies:hidden_firefly",
})
else
minetest.register_decoration({
name = "fireflies:firefly_low",
deco_type = "simple",
place_on = {
"default:dirt_with_grass",
"default:dirt_with_coniferous_litter",
"default:dirt_with_rainforest_litter",
"default:dirt"
},
place_offset_y = 2,
sidelen = 80,
fill_ratio = 0.0005,
biomes = {
"deciduous_forest",
"coniferous_forest",
"rainforest",
"rainforest_swamp"
},
y_max = 31000,
y_min = -1,
decoration = "fireflies:hidden_firefly",
})
minetest.register_decoration({
name = "fireflies:firefly_high",
deco_type = "simple",
place_on = {
"default:dirt_with_grass",
"default:dirt_with_coniferous_litter",
"default:dirt_with_rainforest_litter",
"default:dirt"
},
place_offset_y = 3,
sidelen = 80,
fill_ratio = 0.0005,
biomes = {
"deciduous_forest",
"coniferous_forest",
"rainforest",
"rainforest_swamp"
},
y_max = 31000,
y_min = -1,
decoration = "fireflies:hidden_firefly",
})
end

and

-- start nodetimers
minetest.register_on_generated(function(minp, maxp, blockseed)
local gennotify = minetest.get_mapgen_object("gennotify")
local poslist = {}
for _, pos in ipairs(gennotify["decoration#"..firefly_low] or {}) do
local firefly_low_pos = {x = pos.x, y = pos.y + 3, z = pos.z}
table.insert(poslist, firefly_low_pos)
end
for _, pos in ipairs(gennotify["decoration#"..firefly_high] or {}) do
local firefly_high_pos = {x = pos.x, y = pos.y + 4, z = pos.z}
table.insert(poslist, firefly_high_pos)
end
if #poslist ~= 0 then
for i = 1, #poslist do
local pos = poslist[i]
minetest.get_node_timer(pos):start(1)
end
end
end)

Fireflies aren't supposed to be generated in those biomes, ergo no node timer loop can possibly be started, thus fireflies won't turn into hidden fireflies based on the light level.

I'm kinda surprised fireflies use node timers started in on_generated rather than an ABM for this...

@appgurueu appgurueu added the Bug label Jul 12, 2022
@sfan5
Copy link
Member

sfan5 commented Jul 13, 2022

I'm kinda surprised fireflies use node timers started in on_generated rather than an ABM for this...

Don't you mean an LBM? You don't want an ABM to happen constantly when node timers are already running.

Regardless, what would the fix here be?

@appgurueu
Copy link
Contributor

I'm kinda surprised fireflies use node timers started in on_generated rather than an ABM for this...

Don't you mean an LBM? You don't want an ABM to happen constantly when node timers are already running.

I had intended replacing the node timers with the ABM entirely?

@JoseDouglas26
Copy link
Contributor

Would it be possible to resolve this issue by creating an API for fireflies? A function of this API could be something like fireflies.register_fireflies_decoration(param1, param2, ..., biomes), where the biomes parameter is a list of biomes to register the decorations. Mods (Ethereal, Extra Biomes, etc) could use this API to add firefly decoration.

@sfan5 sfan5 changed the title Hidden fireflies don't work outside vanilla. Change code seems not to work. Hidden fireflies don't work outside vanilla biomes Dec 24, 2023
@appgurueu
Copy link
Contributor

After reconsideration, I think we should probably fix this by replacing the on_generated with an LBM as suggested by sfan5, and possibly also starting the node timer in on_construct for manually placed fireflies; I believe an ABM would probably add quite some unnecessary overhead for the relatively sparse fireflies (though I don't know the ABM implementation details too well), and also require larger changes. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants