mt-mods / pipeworks

Pipeworks is a mod for Minetest allowing the crafting and usage of pipes and tubes
Other
14 stars 17 forks source link

Add support for MineClone `container` groups #96

Open ThePython10110 opened 8 months ago

ThePython10110 commented 8 months ago

Pipeworks should support MineClone's container groups. This would make it compatible with any containers that support MineClone's hoppers (and therefore most mods that support MineClone).

Formspecs should be overridden manually if they are going to be overridden.

From MineClone's GROUPS.md:

You could do this fairly easily, something like this:

for name, def in pairs(minetest.registered_items) do
    local container = def.groups.container
        if container == 2 or container == 3 then
            minetest.override_item(name,
                tube = {
                    -- check allow_metadata_inventory_put/take/move functions
                    -- insert/remove from main
                }
            )
        elseif container == 4 then
            minetest.override_item(name,
                tube = {
                    -- check allow_metadata_inventory_put/take/move functions
                    -- insert into src from the top and fuel from side (?), remove from dst
                    -- Looking at things, it seems like fuel usually goes into the top with Pipeworks, although with hoppers it goes into the side. So I don't know.
                    -- start node timer
                }
            )
        elseif container == 5 or container == 6 then
            minetest.override_item(name,
                tube = {
                    -- check allow_metadata_inventory_put/take/move functions
                    -- insert into main or other side's main
                }
            )
        end
    end
end

It doesn't even depend on any MineClone mods. Also, it should override the groups and after_place/on_rotate/after_dig functions (in a non-destructive way, of course), but I didn't bother to type all that in.

BuckarooBanzay commented 8 months ago

sounds useful, might be good to be able to enable/disable that with a setting

ThePython10110 commented 7 months ago

MineClone2 has now changed their container groups to be almost meaningless, and they have a new API system that would potentially be easier to port. Mineclonia still uses this system, though. It would be great if both were supported.

wsor4035 commented 7 months ago

@corarona any thoughts on if mineclonia well cherrypick the apis in question/compatibility across both of the games?

corarona commented 7 months ago

Well mineclonia has had a similar api for a while (while preserving the old container groups too), i guess they aren't named exactly the same though.

So cherry pick: probably no but maybe we can change them to be compatible, i'll have a look some time.

corarona commented 7 months ago

It would sound like a good idea for them to put the container groups back though as this system has been in place for a long time.

corarona commented 7 months ago

mmmh their system seems a bit complex so I tend to say no. I'll think about if I can make it work though.

In general it seems unlikely things will stay compatible mid term if things like this keep happening i guess.

corarona commented 7 months ago

Well the new mcl2 system is needlessly complex and poorly documented but i think i have managed to make a compat layer:

https://codeberg.org/mineclonia/mineclonia/commit/14d595a7e1fbcda66a53c9448e45d5fa20506888

corarona commented 7 months ago

Also contains some clues on how to use the mcl2 api:

note: hopper_list is always "main"

these are expected to return: inventory, list, stack_index (inv and list are always of the node, not the hopper, the stack_index is the hopper's stack_index in case of push i.e. stack_index is always of the item to be moved)

if they do they will move the item and run _mcl_hoppers_after_push/pull

SwissalpS commented 7 months ago

This may be offtopic. Isn't MCL trying to be a clone of another game? Does that other game have autocrafters and other items provided by pipeworks too? Or does MCL just clone certain aspects of the other game and then functions from this 'universe' are patched onto it?

corarona commented 6 months ago

Isn't MCL trying to be a clone of another game? Does that other game have autocrafters and other items provided by pipeworks too?

Autocrafters are coming in 1.21 i heard, that being said "that game" has tons of mods so, not sure it's in any way inconsistent or that i would care if it were :P

In any case mcl2 hopper api is now supported by mineclonia, although as mentioned before i think it's not really a good api as it makes something simple somewhat complicated.