minetest-mods / moreblocks

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

partial rewrite and major bugfix #191

Closed fluxionary closed 1 year ago

fluxionary commented 2 years ago

It's become time for me to focus on cleaning up moreblocks and fixing a bunch of outstanding, (long-standing!) issues.

the major motivation is to make it easier to add "cut" shapes of various nodes without blowing up the node count too much, because the 32767 node id limit is a real problem. the minor motivation is that there's currently a lot of ways to end up losing material (or even generating it ex nihilo!) when using the circular saw.

I want to invite other people to comment on the changes I'm making, because I'm having to make a bunch of critical choices. Because moreblocks is in used by a huge number of people, I'm trying to make my changes not cause crashes on current servers, or result in any unknown nodes, but at the same time, I've made (and will continue to make) some serious structural changes to the mod, and would appreciate some extra eyes to check for situations that may escape my attempts to think things through or test things.

I anticipate the work I've got planned may take a couple more days to a couple more weeks, depending on time and health.

Some goals:

fix certain bugs:

maybe:

maybe some of the other bugs/PRS, but they mostly either seem to be fixed or unfixable

other remaining TODOs:

pie in the sky stuff, which i'll probably not fix in this PR:

outstanding PRs:

BuckarooBanzay commented 2 years ago

you've set yourself some goals there :thinking: are you sure you don't want to solve one thing after another instead?

In any case: good luck, take your time and feel free to ping me up for testing or feedback :+1:

fluxionary commented 2 years ago

Query: does anyone know if any mods use the exported "circular_saw" global? I'd prefer to remove the circular saw as a distinct namespace vs. stairsplus. I haven't personally seen any evidence it's used, but the minetest ecosystem is quite diverse and hard to grep.

fluxionary commented 2 years ago

are you sure you don't want to solve one thing after another instead?

at the moment, i think it'll be easier to achieve all the goals than to split it into distinct stages. i also admit that one of my common areas of failure is biting off more than i can chew. let's see if i can get this done in a week or two, as i expect.

In any case: good luck, take your time and feel free to ping me up for testing or feedback 👍

will do :)

BuckarooBanzay commented 2 years ago

Query: does anyone know if any mods use the exported "circular_saw" global?

Did a quick grep in our modpack (https://github.com/pandorabox-io/pandorabox-mods/) and the following popped up:

I don't think that's a problem if just the global name changes :+1:

BuckarooBanzay commented 2 years ago

Query: does anyone know if any mods use the exported "circular_saw" global?

Relayed search result from @rubenwardy from the cdb: https://content.minetest.net/zipgrep/a831eba5-af21-4c4a-9cc9-c45981f21141/ (thanks)

fluxionary commented 2 years ago

Relayed search result from @rubenwardy from the cdb: https://content.minetest.net/zipgrep/a831eba5-af21-4c4a-9cc9-c45981f21141/ (thanks)

that's a fantastic tool i didn't know existed. wish i had access to run new queries, but i can certainly see why it would be restricted.

i'll review the code usage and make a decision about whether to publish the old API as well, or submit PRs for those mods (if necessary)

fluxionary commented 2 years ago

Things are at a point where I wouldn't mind having people test this to find bugs and integration issues. Please report the issues on my fork https://github.com/fluxionary/minetest-moreblocks/issues

fluxionary commented 2 years ago

I've finished the manual integration testing with other mods, and ended up with only 2 outstanding PRs:

Please review https://github.com/fluxionary/minetest-moreblocks/issues/9 for the reasons why I don't consider other incompatibilities necessary to fix rn - mostly, things were already incompatible, or there is no reasonable "correct" way to solve the issues due to engine limitations. Maybe I should write a script to crawl the server list to see who's using the affected mods...

Other than that, I mostly need to write documentation and proof-read the code.

fluxionary commented 2 years ago

I've finished all the parts of this that I intend to do for now, and have tested things reasonably thoroughly, and have removed the [WIP] tag. Please let me know what I can do to get this pulled :)

fluxionary commented 2 years ago

screenshot_20220620_185147

I assume this is due to letting mods specify e.g. 'nodetype = "node"' and letting them override what we're trying to do.

this is a blocking bug and needs to be fixed before this should be accepted. but i probably need 12 hours to sleep and wake up again.

fluxionary commented 2 years ago

screenshot_20220620_190506

this is a blocking bug and needs to be fixed before this should be accepted. but i probably need 12 hours to sleep and wake up again.

fluxionary commented 2 years ago

I assume this is due to letting mods specify e.g. 'nodetype = "node"' and letting them override what we're trying to do.

this is a blocking bug and needs to be fixed before this should be accepted. but i probably need 12 hours to sleep and wake up again.

fixed via https://github.com/minetest-mods/moreblocks/pull/191/commits/21a374b8dd07108c4066d950c9a0b4c9826421da

fluxionary commented 2 years ago

this is a blocking bug and needs to be fixed before this should be accepted. but i probably need 12 hours to sleep and wake up again.

Fixed in https://github.com/minetest-mods/moreblocks/pull/191/commits/2163a39844683ce0b93eae51bdf83940c1433772.

This was partially because moreblocks used to register some nodes using the "technic" modname even when technic wasn't installed.

fluxionary commented 2 years ago

player request: allow picking up a stack from the player inventory, and replacing the "source" nodes in the saw (either full node or microblock). i tried to make this work in the early stages of the project, and hit a wall (what to do w/ microblocks?), but i think i might have a better handle on the mechanics now, and will try to do this tomorrow.

fluxionary commented 2 years ago

player request: allow picking up a stack from the player inventory, and replacing the "source" nodes in the saw (either full node or microblock). i tried to make this work in the early stages of the project, and hit a wall (what to do w/ microblocks?), but i think i might have a better handle on the mechanics now, and will try to do this tomorrow.

implemented this here https://github.com/minetest-mods/moreblocks/pull/191/commits/59b36fc6d1983c35cb5de0dbd67172a44f694196

BuckarooBanzay commented 2 years ago

I updated the moreblocks repo in a PR to the pandorabox-mods repo (https://github.com/pandorabox-io/pandorabox-mods/pull/2343) There are a few integration tests running for every mod-update/PR in that repo

One of those tests is a check if every previously registered node/tool/item is still registered or at least has an alias/LBM. I'm not sure it even got to that test but here are the first results:

Lots of those warnings:

...
2022-06-24 05:10:42: WARNING[Main]: [stairsplus] removing group overrides from scifi_nodes:stair_blackplate_inner
2022-06-24 05:10:42: WARNING[Main]: [stairsplus] removing group overrides from scifi_nodes:stair_blackplate_outer
2022-06-24 05:10:42: WARNING[Main]: [stairsplus] removing group overrides from scifi_nodes:stair_blackplate_alt_1
2022-06-24 05:10:42: WARNING[Main]: [stairsplus] removing group overrides from scifi_nodes:stair_blackplate_alt_2
2022-06-24 05:10:42: WARNING[Main]: [stairsplus] removing group overrides from scifi_nodes:stair_blackplate_alt_4
2022-06-24 05:10:42: WARNING[Main]: [stairsplus] removing group overrides from scifi_nodes:stair_blackplate_alt_8

And a fatal error in the homedecor modpack:

2022-06-24 05:10:43: ERROR[Main]: ModError: Failed to load and run script from /var/lib/minetest/.minetest/worlds/world/worldmods/homedecor_modpack/building_blocks/init.lua:
2022-06-24 05:10:43: ERROR[Main]: ...ld/worldmods/homedecor_modpack/building_blocks/alias.lua:13: bad argument #1 to 'ipairs' (table expected, got nil)
2022-06-24 05:10:43: ERROR[Main]: stack traceback:
2022-06-24 05:10:43: ERROR[Main]:   [C]: in function 'ipairs'
2022-06-24 05:10:43: ERROR[Main]:   ...ld/worldmods/homedecor_modpack/building_blocks/alias.lua:13: in main chunk
2022-06-24 05:10:43: ERROR[Main]:   [C]: in function 'dofile'
2022-06-24 05:10:43: ERROR[Main]:   ...rld/worldmods/homedecor_modpack/building_blocks/init.lua:3: in main chunk

Looks like it tries to iterate over stairsplus.shapes_list and fails: https://github.com/mt-mods/homedecor_modpack/blob/master/building_blocks/alias.lua#L13

Details: https://github.com/pandorabox-io/pandorabox-mods/runs/7036147424?check_suite_focus=true

fluxionary commented 2 years ago

Lots of those warnings:

2022-06-24 05:10:42: WARNING[Main]: [stairsplus] removing group overrides from scifi_nodes:stair_blackplate_inner

that's expected - stairsplus now tries to automatically adapt the groups of the base node. overriding groups is currently not possible when using the "old" API, though it can be done via the new API: https://github.com/fluxionary/minetest-moreblocks/blob/2774e54a70d2efa83994303261cf30ce222bd138/stairsplus/API.md?plain=1#L89-L90

fluxionary commented 2 years ago

Looks like it tries to iterate over stairsplus.shapes_list and fails: https://github.com/mt-mods/homedecor_modpack/blob/master/building_blocks/alias.lua#L13

https://github.com/mt-mods/homedecor_modpack/pull/38/files

not sure why i didn't try to do a test against the full pandorabox modpack yet, or how homedecor escaped my previous audit, i'll get on that.

BuckarooBanzay commented 2 years ago

Thanks for fixing the homedecor issue :+1:

Another thing popped up though :wink: (no pressure)

2022-06-24 16:11:30: ERROR[Main]: ModError: Failed to load and run script from /var/lib/minetest/.minetest/worlds/world/worldmods/basic_streets/init.lua:
2022-06-24 16:11:30: ERROR[Main]: ...orlds/world/worldmods/moreblocks/stairsplus/api/node.lua:59: cannot register "basic_streets:street_straight" w/ paramtype2 "colorwallmounted" w/ stairsplus
2022-06-24 16:11:30: ERROR[Main]: stack traceback:
2022-06-24 16:11:30: ERROR[Main]:   [C]: in function 'error'
2022-06-24 16:11:30: ERROR[Main]:   ...orlds/world/worldmods/moreblocks/stairsplus/api/node.lua:59: in function 'check_node_validity'
2022-06-24 16:11:30: ERROR[Main]:   ...orlds/world/worldmods/moreblocks/stairsplus/api/node.lua:88: in function 'register_single'
2022-06-24 16:11:30: ERROR[Main]:   ...orlds/world/worldmods/moreblocks/stairsplus/api/node.lua:76: in function 'register_single'
2022-06-24 16:11:30: ERROR[Main]:   ...orlds/world/worldmods/moreblocks/stairsplus/api/node.lua:249: in function 'register_group'
2022-06-24 16:11:30: ERROR[Main]:   ...rldmods/moreblocks/stairsplus/compat2/old_moreblocks.lua:60: in function 'register_group'
2022-06-24 16:11:30: ERROR[Main]:   ...rldmods/moreblocks/stairsplus/compat2/old_moreblocks.lua:70: in function 'register_all'
2022-06-24 16:11:30: ERROR[Main]:   ....minetest/worlds/world/worldmods/basic_streets/nodes.lua:60: in main chunk
2022-06-24 16:11:30: ERROR[Main]:   [C]: in function 'dofile'
2022-06-24 16:11:30: ERROR[Main]:   .../.minetest/worlds/world/worldmods/basic_streets/init.lua:3: in main chunk

is it disallowed now to register nodes with colorwallmounted as param2type?

fluxionary commented 2 years ago

next crash:

ModError: Failed to load and run script from /home/flux/.minetest/worlds/pandorabox/worldmods/basic_streets/init.lua:
.../pandorabox/worldmods/moreblocks/stairsplus/api/node.lua:59: cannot register "basic_streets:street_straight" w/ paramtype2 "colorwallmounted" w/ stairsplus
stack traceback:
    [C]: in function 'error'
    .../pandorabox/worldmods/moreblocks/stairsplus/api/node.lua:59: in function 'check_node_validity'
    .../pandorabox/worldmods/moreblocks/stairsplus/api/node.lua:88: in function 'register_single'
    .../pandorabox/worldmods/moreblocks/stairsplus/api/node.lua:76: in function 'register_single'
    .../pandorabox/worldmods/moreblocks/stairsplus/api/node.lua:251: in function 'register_group'
    ...rldmods/moreblocks/stairsplus/compat2/old_moreblocks.lua:60: in function 'register_group'
    ...rldmods/moreblocks/stairsplus/compat2/old_moreblocks.lua:70: in function 'register_all'
    ...test/worlds/pandorabox/worldmods/basic_streets/nodes.lua:60: in main chunk
    [C]: in function 'dofile'
    ...etest/worlds/pandorabox/worldmods/basic_streets/init.lua:3: in main chunk
Check debug.txt for details.

i was already aware of this issue, but i deemed it "unfixable" https://github.com/fluxionary/minetest-moreblocks/issues/9 given that nodes can't have a paramtype2 of both "colorwallmounted" and "facedir". i suppose the correct thing to do here is have stairsplus just ignore that value when someone uses the legacyapi (same with just "color")

fluxionary commented 2 years ago

Another thing popped up though 😉 (no pressure)

i'm running a local clone of pandorabox now, i'll try to shake things out and make fixes, and let you know when i'm done so we don't end up doing the same work =D (see the comment above)

fluxionary commented 2 years ago
ModError: Failed to load and run script from /home/flux/.minetest/worlds/pandorabox/worldmods/lavastuff/init.lua:
...rldmods/moreblocks/stairsplus/compat2/old_moreblocks.lua:56: cannot register stairs for lavastuff:ingot before the node is defined
stack traceback:
    [C]: in function 'error'
    ...rldmods/moreblocks/stairsplus/compat2/old_moreblocks.lua:56: in function 'register_group'
    ...rldmods/moreblocks/stairsplus/compat2/old_moreblocks.lua:77: in function 'register_all'
    ....minetest/worlds/pandorabox/worldmods/lavastuff/init.lua:338: in main chunk
Check debug.txt for details.

... it really registers stairs for an ingot? i have to see what that looks like...

fluxionary commented 2 years ago

lavastuff PR: https://github.com/minetest-mods/lavastuff/pull/18

fluxionary commented 2 years ago

i committed some more tweaks for compatibility w/ mods using the old API. other than the existing PRs, i'm now able to run the pandorabox mod collection locally.

fluxionary commented 2 years ago

Bug w/ mineclone from the forums:

2022-06-26 22:29:13: ERROR[Main]: ModError: Failed to load and run script from C:\Games\minetest\bin\..\mods\moreblocks\stairsplus_legacy\init.lua:
2022-06-26 22:29:13: ERROR[Main]: ...\minetest\bin\..\mods\moreblocks\stairsplus\api\node.lua:71: node "wool:white" is not defined
2022-06-26 22:29:13: ERROR[Main]: stack traceback:
2022-06-26 22:29:13: ERROR[Main]:   [C]: in function 'error'
2022-06-26 22:29:13: ERROR[Main]:   ...\minetest\bin\..\mods\moreblocks\stairsplus\api\node.lua:71: in function 'register_single'
2022-06-26 22:29:13: ERROR[Main]:   ...\minetest\bin\..\mods\moreblocks\stairsplus\api\node.lua:251: in function 'register_group'
2022-06-26 22:29:13: ERROR[Main]:   ...netest\bin\..\mods\moreblocks\stairsplus_legacy\init.lua:39: in function 'register_legacy'
2022-06-26 22:29:13: ERROR[Main]:   ...netest\bin\..\mods\moreblocks\stairsplus_legacy\wool.lua:7: in main chunk
2022-06-26 22:29:13: ERROR[Main]:   [C]: in function 'dofile'
2022-06-26 22:29:13: ERROR[Main]:   ...netest\bin\..\mods\moreblocks\stairsplus_legacy\init.lua:47: in main chunk
2022-06-26 22:29:13: ERROR[Main]: Check debug.txt for details.
2022-06-26 22:29:13: ACTION[Main]: Server: Shutting down
Niklp09 commented 2 years ago

Do you plan backwards compatibility with moreblocks 2.0?

fluxionary commented 2 years ago

Do you plan backwards compatibility with moreblocks 2.0?

it should be, at least mostly. i've tested it w/ a wide variety of mods. in the description, towards the bottom, you can see the outstanding PRs against other mods where compatibility has broken.

Niklp09 commented 2 years ago

I had 3.0 on my server for testing, now back to 2.0. I don't see any backwards compatibility there. All stairplus nodes are unknown nodes grafik

fluxionary commented 2 years ago

I had 3.0 on my server for testing, now back to 2.0. I don't see any backwards compatibility there. All stairplus nodes are unknown nodes

oh i see. 3.0 is backwards compatible as in you can upgrade existing worlds to it, and use mods designed for the 2. API with it, but you certainly can't downgrade to 2. and expect things to work right, because e.g. a lot of node names have changed.

BuckarooBanzay commented 2 years ago

Tested this on a local copy of pandorabox again, everything seems to work and all previously registered nodes were available :+1:

Niklp09 commented 2 years ago

I have not yet understood why 2 circular saw categories are created in unified_inventory

fluxionary commented 2 years ago

I have not yet understood why 2 circular saw categories are created in unified_inventory

one for cuttable nodes, one for cut nodes.

Calinou commented 2 years ago

Outstanding work :slightly_smiling_face:

Is this ready to merge, or should we wait for more servers to test this PR?

Niklp09 commented 2 years ago

Why have nodes which have neither a stairplus or stairs api call to register stairs also stairplus-stairs? I thought you wanted to reduce unnecessary nodes

fluxionary commented 2 years ago

Why have nodes which have neither a stairplus or stairs api call to register stairs also stairplus-stairs? I thought you wanted to reduce unnecessary nodes

i'm confused. which nodes?

fluxionary commented 2 years ago

Is this ready to merge, or should we wait for more servers to test this PR?

to me, this feels mature, but i also don't mind waiting for other servers to test.

Niklp09 commented 2 years ago

i'm confused. which nodes?

Nodes of mods that do not use stairsplus or stairs.

Niklp09 commented 2 years ago

For example: for the nodes from the mod "titanium" are registered stairsplus stairs. However, there is no call for this in the mod. https://github.com/Niklp09/titanium

fluxionary commented 2 years ago

For example: for the nodes from the mod "titanium" are registered stairsplus stairs. However, there is no call for this in the mod. https://github.com/Niklp09/titanium

how is anything being registered as a stair (stairsplus or otherwise) in that "fork" of the titanium mod? there's no logic to do that in that mod or in this mod.

the point of this PR isn't to keep server operators from creating node model variants, but to reduce the number of useless variants that server operators must accept by using this mod in the first place.

Niklp09 commented 2 years ago

In the titanium mod is no call to register stairs. If I deactivate "moreblocks" no more stairs are registered.

fluxionary commented 2 years ago

In the titanium mod is no call to register stairs. If I deactivate "moreblocks" no more stairs are registered.

but even when moreblocks is enabled, stairs shouldn't be registered for titanium nodes. are you saying that when you use the 2 mods together, magically there's stairs? is a third mod doing the actual stairs registration for titanium?

Niklp09 commented 2 years ago

are you saying that when you use the 2 mods together, magically there's stairs?

yes

is a third mod doing the actual stairs registration for titanium?

no

fluxionary commented 2 years ago

are you saying that when you use the 2 mods together, magically there's stairs?

yes

doesn't happen for me: screenshot_20220718_100221

Niklp09 commented 2 years ago

@fluxionary Forget it, was a mistake from me Edit: bug with another mod (xdecor)

Niklp09 commented 2 years ago

If xdecor is also turned on, you will be able to reproduce my problem. Maybe an issue should be made at xdecor.

grafik

fluxionary commented 2 years ago

ahh, i see them now

screenshot_20220719_172233

it's xdecor's accursed workbench, which creates all sorts of fun:

https://github.com/minetest-mods/xdecor/blob/3b5b3f0c11c441b9667949194b671fc6aa72b843/src/workbench.lua#L299-L303

fortunately it only registers the basic variants (through the stairs API), not all the possibilities for all possible nodes O_O

Niklp09 commented 2 years ago

When I open the circular saw formspec I get this warning: ERROR[Main]: Ignoring out-of-bounds argument escape sequence in translation

fluxionary commented 2 years ago

When I open the circular saw formspec I get this warning: ERROR[Main]: Ignoring out-of-bounds argument escape sequence in translation

ugh just discovered this issue w/ smartshops, seems to cause the same issue here, i think

https://github.com/minetest/minetest/issues/12566

just to check, what node from what mod was in the saw, if any?

Niklp09 commented 2 years ago

Problem exists with and without node in the saw

fluxionary commented 2 years ago

Problem exists with and without node in the saw

hm, i can't replicate the issue. what version of the minetest client/server are you using?