minetest-mods / moreblocks

More Blocks
https://content.minetest.net/packages/Calinou/moreblocks/
zlib License
45 stars 67 forks source link

Support more default blocks in registrations #176

Closed Caellian closed 2 years ago

Caellian commented 3 years ago

There's really no reason why most of these shouldn't be supported.

Since properties from original nodes are being copied over, it might be a good idea to prevent variants for gravity affected blocks from falling.

In future, once multiple nodes occupying the same space gets added, it'd be great if players aren't forced to replace gravel paths in front of their homes with something else because they have mesecons wires there which can't be covered properly as gravel panels don't exist. Same goes for most natural terrain nodes like dirt with grass/litter variants and building traps.

Ideally, these should be modifiable on per-world basis with something like:

function read_list(path)
    file, err = io.open(path)
    if err then
        return {}
    end

    local res = {}
    while true do
        ln = file:read()
        if ln == nil then -- EOF
            break
        end

        if ln:find("^%s*#") or ln:find("^%s*$") then
            -- skip over comments and empty lines
        else
            table.insert(res, ln:match("^%s*(.-)%s*$"))
        end
    end

    file:close()

    return res
end

local auto_generated = read_list(world_dir.."/config/moreblocks_reg.txt")

and adding a hook to minetest.register_node function:

original_register_node_fn = minetest.register_node

minetest.register_node = function(name, ...)
    original_register_node_fn(name, ...)

    local added = -1
    for i, id in pairs(process_later) do
        if id == name then
            processing_logic_func(name)
            added = i
            break
        end
    end

    if added != -1 then
        table.remove(process_later, added)

        if #multipart.process_later == 0 then
            minetest.register_node = original_register_node_fn
            original_register_node_fn = nil
        end
    end
end

Did I start writing the same mod as this one before figuring out it exists?! 🙉 Mayyybee. :smile:

Caellian commented 3 years ago

Oddly enough permafrost_with_stones seems to work fine even though mossy variant uses layered textures.

I had to comment out all layered textures as those nodes require special handling. This should maybe be fixed, but it's a bit tricky to handle currently and isn't worth the effort tbh.

Ores aren't layered so they work fine too.

Regarding the remaining changes, I'll do it in a separate PR as it's not really related to the point of this one. I started writing it down and it turned out to have a bit larger scope than what I originally thought.

This can be merged.

Calinou commented 3 years ago

I have two issues with this:

Caellian commented 3 years ago

Alright, so:

I'll make the proposed modifications.

fluxionary commented 2 years ago

There's really no reason why most of these shouldn't be supported.

Personally I think that adding all the variants that moreblocks currenty includes is already a huge problem, because of the 32767 limit on unique node ids. It's trivial for server owners to add more variants if they want to, but moreblocks (stairsplus) ends up taking the vast majority of node ids on most large servers as it stands. For instance, on the your-land server, stairsplus is currently responsible for 15021 out of 21406 node ids in use, which is over 70%. And most of those will never be used.