Skip to content

Wrench rewrite #247

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

Merged
merged 4 commits into from
Nov 25, 2021
Merged

Wrench rewrite #247

merged 4 commits into from
Nov 25, 2021

Conversation

OgelGames
Copy link
Contributor

@OgelGames OgelGames commented Nov 17, 2021

Improves and fixes the wrench, making it suitable for all players.

  • Inventory contents of nodes are now checked to prevent nesting inventories. (also an item blacklist)
  • Wrench is now used with left-click instead of right-click. (allows repairing on anvil and putting in itemframes)
  • Added chat messages for when nodes can't be picked up.
  • Creative mode players can now place a picked-up node multiple times.
  • Picked-up nodes can have custom descriptions. (added to technic chests and default signs)
  • API now works, so other mods can register nodes.
  • Extra nodes are no longer registered for supported nodes. (overrides after_place_node)

Also added support for digtron inventory nodes, and blacklisted loaded digtron crates.

@OgelGames OgelGames added Enhancement New feature or request Testing needed Requires extended testing before working on issue, closing issue or merging pull request. labels Nov 17, 2021
@S-S-X

This comment has been minimized.

@S-S-X
Copy link
Member

S-S-X commented Nov 17, 2021

Another thing to think about: using original nodes with meta will add little overhead to all node placements.
This might not be big thing alone but problem I see here is that after done once you cannot really remove that override ever and it becomes locked when wrench is enabled.

With most things this probably does not really matter other than having few relatively expensive calls but probably most people wont be placing a lot of wrench enabled nodes around or doing that with mesecons enabled devices while using mesecons_debug.

Those are corner cases that actually can become bit worse but biggest thing is locking it without any possible way to revert that node override. Something to think a bit first, I'd like to get bit more opinions specifically about this feature lock.

S-S-X
S-S-X previously requested changes Nov 17, 2021
Copy link
Member

@S-S-X S-S-X left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recipe enabled by default is something that should not be there in my opinion because item is way too powerful..

@OgelGames

This comment has been minimized.

@OgelGames
Copy link
Contributor Author

OgelGames commented Nov 18, 2021

I do very strongly disagree with this, item is way too powerful for survival setting to be always craftable.

I don't think it is, digtron crates and inventories already have the same functionality (carrying lots of items), and are even more powerful because there is no hard limit on how much can be put inside them. (and yes I know, that should be fixed too)

That's also reason why recipe was removed.

To be exact, it was because it allowed nesting of chests (see the comment added in 0cf4133), which has now been fixed.

The recipe could be made more expensive though, it is very cheap currently.

@S-S-X
Copy link
Member

S-S-X commented Nov 18, 2021

problem I see here is that after done once you cannot really remove that override ever and it becomes locked when wrench is enabled ... I'd like to get bit more opinions specifically about this feature lock.

Huh? How is it locked?

How do you switch to another system if overriding node callbacks does not seem good? I think you cannot change it after introduced once while doing it any other way will leave options. (other than disabling wrench completely)

I don't think it is, digtron crates and inventories already have the same functionality (carrying lots of items), and are even more powerful because there is no hard limit on how much can be put inside them. (and yes I know, that should be fixed too)

I'm not sure what you're telling here, idea is bad but can be added because other mod that does it should be also fixed?

@BuckarooBanzay
Copy link
Member

I do very strongly disagree with this, item is way too powerful for survival setting to be always craftable.

I like the idea of using that in survival mode 🤔 its not like you have a real advantage with this, aside from the mobile inventory

Pandorabox-related:
Can we at least do a trial run and see how players are abusing it? Maybe with limited handouts (or presents?)

The recipe could be made more expensive though, it is very cheap currently.

👍

@S-S-X
Copy link
Member

S-S-X commented Nov 18, 2021

I do very strongly disagree with this, item is way too powerful for survival setting to be always craftable.

I like the idea of using that in survival mode 🤔 its not like you have a real advantage with this, aside from the mobile inventory

I do think that inventory extensions like this are not good, you could add mod with some 20x bag capacity instead and it will not be as powerful as wrench, especially bad if added to existing games and servers without explicitly deciding to do so.
Wrench is still very useful admin tool for fixing some situations easily and forcing explicit configuration to disable it (after noticing that it was enabled) is not good in my opinion.

Pandorabox-related: Can we at least do a trial run and see how players are abusing it? Maybe with limited handouts (or presents?)

True that pandorabox survival mode is extremely easy survival, this is not situation with some other servers that do still have technic available.
This discussion can be moved to pandorabox.io with another pull request adding configuration for wrench.

@OgelGames
Copy link
Contributor Author

How do you switch to another system if overriding node callbacks does not seem good? I think you cannot change it after introduced once while doing it any other way will leave options.

Well yes, it would be complicated to change to another system (like a single item that changes texture), but I see no way to avoid that.

Overriding the callbacks isn't required though, it's just the most efficient way to do it. (the alternative is minetest.register_on_placenode)

especially bad if added to existing games and servers without explicitly deciding to do so ... forcing explicit configuration to disable it (after noticing that it was enabled) is not good in my opinion

Hmm, maybe, considering there's be no recipe for over 7 years... 🤔

I don't think it is, digtron crates and inventories already have the same functionality (carrying lots of items), and are even more powerful because there is no hard limit on how much can be put inside them. (and yes I know, that should be fixed too)

I'm not sure what you're telling here, idea is bad but can be added because other mod that does it should be also fixed?

I'm saying there has been a far more powerful item available in survival for a long time.

I like the idea of using that in survival mode 🤔 its not like you have a real advantage with this, aside from the mobile inventory

👍

@S-S-X
Copy link
Member

S-S-X commented Nov 18, 2021

but I see no way to avoid that.

Registering proxy item for wrench is way to do that.
User experience however would be a lot worse because of inventory image would be same for all picked up nodes and description would be only thing that indicates what item it actually is unless someone would implement luanti-org/luanti#5686

the alternative is minetest.register_on_placenode

I do not really see that as alternative, just bit worse way to do exactly same thing... (it still locks you with callback that has to handle registered items and no way out)

@S-S-X
Copy link
Member

S-S-X commented Nov 18, 2021

It seems that server crashes if large container with items that contain a lot of metadata is dropped, can probably be prevented by adding more items to blacklist (any item picked up by wrench that can cause large metadata like signs).
Memory chips from digistuff and metatool tools, probably a lot more but I guess those are reported when crashes happen.

Actual error is

An unhandled exception occurred: String too long for serializeString16
src/server.cpp:7d: virtual void* ServerThread::run(): A fatal error occurred: String too long for serializeString16

I see crafting configuration was made again be required so this probably is not that big problem as it is possible to restrict wrench use to trusted users. (after all wrench already had similar problems)

@S-S-X S-S-X dismissed their stale review November 18, 2021 11:11

Resolved

@OgelGames
Copy link
Contributor Author

OgelGames commented Nov 18, 2021

It seems that server crashes if large container with items that contain a lot of metadata is dropped, can probably be prevented by adding more items to blacklist (any item picked up by wrench that can cause large metadata like signs).

Could also do what digtron crate does, preventing dropping completely: https://github.com/minetest-mods/digtron/blob/master/nodes/node_crate.lua#L386

Or check the size of the metadata and prevent dropping if it's too big.

@S-S-X
Copy link
Member

S-S-X commented Nov 18, 2021

Could also do what digtron crate does, preventing dropping completely: https://github.com/minetest-mods/digtron/blob/master/nodes/node_crate.lua#L386

You can still drop digtron crates... luckily many players have not sent their larger trons through tubes but there's factory setups for that @ pandorabox.

For node placement callback I would like to still get some opinions/comments from other people.

It kind of is big thing because it is override that cannot be reverted afterwards, however bit easier now that crafting is not enabled by default as it decreases total amount of picked up nodes.

@S-S-X
Copy link
Member

S-S-X commented Nov 18, 2021

Or check the size of the metadata and prevent dropping if it's too big.

I think this should probably be done when picking up node and prevent pickup if it would result in too large metadata.
This way you do not need to add workarounds for every mod that allows doing things that would cause crash because of too much metadata.

Dropping is still bad even if limited and preventing direct drop would still be good to reduce this.

@S-S-X S-S-X linked an issue Nov 18, 2021 that may be closed by this pull request
@S-S-X
Copy link
Member

S-S-X commented Nov 18, 2021

Related side note, I tried to hack up luanti-org/luanti#5686 and tested with meta:set_string("inventory_image", "mod:nodename").
It works fine but just for node names, I've got no knowledge about engine and implementation with more options would take much more time if I would do it (mostly to read and learn interfaces...).

I'm pretty sure someone with knowledge about engine itemdef/stack/inventory stuff could make it work in few minutes and also do proper complete implementation pretty fast. That would allow using proxy stack for wrench and some hope to get better UX in future.

However what I've seen happening around engine pull requests I'm pretty sure it has to be 1. probably just someone else 2. probably someone with engine knowledge 3. someone who can implement it fast enough to not waste too much time when pr is left unnoticed or rejected. 4. someone with a lot of extra time to debate / fix style / test / doc requests for PR.
Know someone? there would also be that bounty for it... I've just modified few lines in client/hud.cpp to make simple metadata texture switching work

@OgelGames
Copy link
Contributor Author

luanti-org/luanti#5686

There's another problem with that option: it would require the min_minetest_version to be whatever version that feature is added to.

Also, whichever system we change to will have the same problem of being hard to change again (or revert), because there will no longer be separate items to alias.

@github-actions
Copy link

Click for detailed source code test coverage report

Test coverage report for Technic CNC 79.01% in 10/14 files:

File                             Hits Missed Coverage
-----------------------------------------------------
programs.lua                   263  0      100.00%
materials/basic_materials.lua  17   0      100.00%
materials/default.lua          177  4      97.79%
cnc.lua                        50   3      94.34%
materials/init.lua             13   1      92.86%
formspec.lua                   103  8      92.79%
digilines.lua                  39   8      82.98%
init.lua                       19   6      76.00%
api.lua                        160  83     65.84%
pipeworks.lua                  25   13     65.79%
materials/technic_worldgen.lua 0    25     0.00%
materials/moreblocks.lua       0    29     0.00%
materials/ethereal.lua         0    37     0.00%
materials/bakedclay.lua        0    13     0.00%

Test coverage report for technic chests 45.24% in 6/6 files:

File          Hits Missed Coverage
----------------------------------
chests.lua    98   18     84.48%
init.lua      34   18     65.38%
register.lua  84   78     51.85%
formspec.lua  76   93     44.97%
inventory.lua 10   100    9.09%
digilines.lua 2    61     3.17%

Test coverage report for technic 65.26% in 111/111 files:

File                                      Hits Missed Coverage
--------------------------------------------------------------
max_lag.lua                                   12   0      100.00%
machines/register/init.lua                    15   0      100.00%
machines/register/freezer_recipes.lua         13   0      100.00%
machines/other/init.lua                       8    0      100.00%
machines/MV/solar_array.lua                   12   0      100.00%
machines/MV/init.lua                          17   0      100.00%
machines/MV/grinder.lua                       17   0      100.00%
machines/MV/generator.lua                     9    0      100.00%
machines/MV/freezer.lua                       17   0      100.00%
machines/MV/extractor.lua                     17   0      100.00%
machines/MV/electric_furnace.lua              17   0      100.00%
machines/MV/compressor.lua                    17   0      100.00%
machines/MV/centrifuge.lua                    17   0      100.00%
machines/MV/battery_box.lua                   17   0      100.00%
machines/MV/alloy_furnace.lua                 19   0      100.00%
machines/LV/solar_array.lua                   11   0      100.00%
machines/LV/init.lua                          17   0      100.00%
machines/LV/grinder.lua                       16   0      100.00%
machines/LV/generator.lua                     9    0      100.00%
machines/LV/electric_furnace.lua              15   0      100.00%
machines/LV/compressor.lua                    20   0      100.00%
machines/LV/battery_box.lua                   15   0      100.00%
machines/LV/alloy_furnace.lua                 17   0      100.00%
machines/HV/solar_array.lua                   11   0      100.00%
machines/HV/init.lua                          12   0      100.00%
machines/HV/grinder.lua                       17   0      100.00%
machines/HV/generator.lua                     9    0      100.00%
machines/HV/electric_furnace.lua              17   0      100.00%
machines/HV/compressor.lua                    17   0      100.00%
machines/HV/battery_box.lua                   17   0      100.00%
legacy.lua                                    33   0      100.00%
items.lua                                     128  0      100.00%
crafts.lua                                    133  0      100.00%
../technic_worldgen/nodes.lua                 109  0      100.00%
../technic_worldgen/crafts.lua                103  0      100.00%
../technic_worldgen/config.lua                9    0      100.00%
../technic_cnc/programs.lua                   263  0      100.00%
../technic_cnc/materials/technic_worldgen.lua 32   0      100.00%
../technic_cnc/materials/init.lua             14   0      100.00%
../technic_cnc/materials/basic_materials.lua  17   0      100.00%
machines/LV/led.lua                           73   1      98.65%
../technic_cnc/materials/default.lua          178  4      97.80%
machines/register/cables.lua                  174  4      97.75%
machines/register/compressor_recipes.lua      36   1      97.30%
machines/LV/geothermal.lua                    75   3      96.15%
config.lua                                    49   2      96.08%
machines/register/solar_array.lua             46   2      95.83%
machines/LV/solar_panel.lua                   42   2      95.45%
../technic_cnc/cnc.lua                        50   3      94.34%
tools/init.lua                                13   1      92.86%
machines/network.lua                          327  27     92.37%
machines/LV/water_mill.lua                    67   6      91.78%
machines/register/grindings.lua               42   5      89.36%
machines/LV/lamp.lua                          110  14     88.71%
../technic_worldgen/overrides.lua             39   5      88.64%
machines/MV/cables.lua                        29   4      87.88%
machines/LV/cables.lua                        29   4      87.88%
init.lua                                      29   4      87.88%
machines/HV/cables.lua                        28   4      87.50%
machines/register/grinder_recipes.lua         106  16     86.89%
../technic_worldgen/rubber.lua                64   10     86.49%
../technic_worldgen/init.lua                  19   3      86.36%
../technic_worldgen/oregen.lua                155  28     84.70%
util/throttle.lua                             9    2      81.82%
machines/register/machine_base.lua            165  41     80.10%
../technic_cnc/formspec.lua                   88   23     79.28%
machines/LV/extractor.lua                     18   5      78.26%
../technic_cnc/init.lua                       19   6      76.00%
machines/register/recipes.lua                 62   20     75.61%
tools/flashlight.lua                          65   21     75.58%
machines/switching_station.lua                76   25     75.25%
machines/register/battery_box.lua             222  73     75.25%
machines/register/centrifuge_recipes.lua      21   7      75.00%
radiation.lua                                 262  88     74.86%
../technic_cnc/api.lua                        194  66     74.62%
effects.lua                                   5    2      71.43%
machines/MV/wind_mill.lua                     46   22     67.65%
machines/other/coal_furnace.lua               2    1      66.67%
machines/supply_converter.lua                 93   48     65.96%
../technic_cnc/pipeworks.lua                  25   13     65.79%
machines/switching_station_globalstep.lua     40   21     65.57%
machines/register/alloy_recipes.lua           28   15     65.12%
machines/other/injector.lua                   72   39     64.86%
machines/MV/hydro_turbine.lua                 43   26     62.32%
machines/MV/tool_workshop.lua                 56   34     62.22%
machines/register/generator.lua               122  88     58.10%
register.lua                                  21   19     52.50%
tools/cans.lua                                53   48     52.48%
machines/power_monitor.lua                    40   38     51.28%
machines/init.lua                             55   54     50.46%
machines/other/coal_alloy_furnace.lua         63   63     50.00%
machines/LV/music_player.lua                  46   46     50.00%
tools/mining_lasers.lua                       39   40     49.37%
machines/other/constructor.lua                67   69     49.26%
tools/vacuum.lua                              19   21     47.50%
tools/tree_tap.lua                            24   27     47.06%
machines/HV/forcefield.lua                    101  157    39.15%
machines/HV/quarry.lua                        124  217    36.36%
machines/HV/nuclear_reactor.lua               116  208    35.80%
machines/register/common.lua                  39   75     34.21%
tools/chainsaw.lua                            40   83     32.52%
tools/multimeter.lua                          71   149    32.27%
machines/compat/api.lua                       16   34     32.00%
tools/sonic_screwdriver.lua                   18   40     31.03%
machines/other/frames.lua                     184  445    29.25%
helpers.lua                                   38   100    27.54%
tools/mining_drill.lua                        76   226    25.17%
machines/other/anchor.lua                     14   74     15.91%
machines/compat/digtron.lua                   2    11     15.38%
tools/prospector.lua                          16   92     14.81%
machines/register/extractor_recipes.lua       6    65     8.45%

Raw test runner output for geeks:

CNC:

●●●●●●●●●●●●●●●●●●●●●●
22 successes / 0 failures / 0 errors / 0 pending : 0.178741 seconds

Chests:

W:	Configuration: invalid key	exclude_textures
W:	Configuration: invalid key	validate_textures
●●●●●
5 successes / 0 failures / 0 errors / 0 pending : 0.041636 seconds

Technic:

●◌◌●●●◌●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●◌●●●●●
174 successes / 0 failures / 0 errors / 4 pending : 5.86885 seconds

Pending → spec/api_spec.lua @ 132
Technic API Machine registration registers my_mod:my_battery
spec/api_spec.lua:132: Battery box registration does not include all fields

Pending → spec/api_spec.lua @ 189
Technic API Machine registration registers my_mod:machine_base
spec/api_spec.lua:189: Base machine registration does not include all fields

Pending → spec/api_spec.lua @ 284
Technic API internals technic.cables TBD, misleading name and should be updated
spec/api_spec.lua:284: TBD technic.cables naming and need, see technic networks data for possible options

Pending → spec/supply_converter_spec.lua @ 78
Supply converter building overloads network
spec/supply_converter_spec.lua:78: overload does not work with supply converter

@S-S-X
Copy link
Member

S-S-X commented Nov 19, 2021

minetest/minetest#5686

There's another problem with that option: it would require the min_minetest_version to be whatever version that feature is added to.

That simply is not true, feature is fully backwards compatible and items will work completely fine with old clients.

Also, whichever system we change to will have the same problem of being hard to change again (or revert), because there will no longer be separate items to alias.

It is not hard but close to impossible to remove additional (and most of time useless) processing from node callbacks of other nodes and other mods.
With proxy item that is not the case because you will not be overwriting code of other mods at all and there is no overrides to begin with.

edit. @OgelGames
If confusion is because of overrides I'll repeat #247 (comment)
I'm not concerned about single mod having itself locked with some feature because of design decisions but about injecting code to other mods when you simply cannot remove that without breaking tool completely.

If confusion is about possibly having stack textures in future then that is simply client enhancement and it does not affect usability in any way.
It only slightly affects user experience because with old client you only have description and with new client you have texture and description.

@S-S-X
Copy link
Member

S-S-X commented Nov 19, 2021

Well, maybe I'm trying to protect other mods and special use cases bit too much here.

Actually to update wrench again to use single proxy item with good user experience and without affecting or overriding other mods is just destroying all items inside picked up containers and maybe for that it is enough to have note in changelog.

I guess admin should read changelog anyway, inform players and player who did not place their picked up containers in time will simply lose all items inside for not following advice.

(still other opinions about this would be nice to have, I just see doing overrides as bad practice in general especially if causes troubles with future updates and in this case overrides could be completely avoided easily)

@BuckarooBanzay
Copy link
Member

(still other opinions about this would be nice to have, I just see doing overrides as bad practice in general especially if causes troubles with future updates and in this case overrides could be completely avoided easily)

This is actually quite elegant in terms of up- and downgrading: An picked-up chest with the new method just becomes a regular chest if you downgrade, nothing to clean up afterwards.

IMO: i don't see an issue with it, there have been far worse hacks than this (not that i would describe this as a hack though)

@OgelGames OgelGames merged commit 166da3e into master Nov 25, 2021
@OgelGames OgelGames deleted the wrench-rewrite branch November 25, 2021 03:54
@Athozus Athozus added this to the 2.0.0 milestone Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Testing needed Requires extended testing before working on issue, closing issue or merging pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add aliases for old wrench node names
4 participants