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

Add support for MineClone container groups #96

Open
ThePython10110 opened this issue Nov 19, 2023 · 10 comments
Open

Add support for MineClone container groups #96

ThePython10110 opened this issue Nov 19, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@ThePython10110
Copy link

ThePython10110 commented Nov 19, 2023

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:

  • container: Node is a container which physically stores items within and has at least 1 inventory
    • container=2: Has one inventory with list name "main". Items can be placed and taken freely
    • container=3: Same as container=2, but shulker boxes can not be inserted
    • container=4: Furnace-like, has lists "src", "fuel" and "dst".
      It is expected that this also reacts on on_timer;
      the node timer must be started from other mods when they add into "src" or "fuel"
    • container=5: Left part of a 2-part horizontal connected container. Both parts have a "main" inventory
      list. Both inventories are considered to belong together. This is used for large chests.
    • container=6: Same as above, but for the right part.
    • container=7: Has inventory list "main", no movement allowed
    • container=1: Other/unspecified container type

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.

@ThePython10110 ThePython10110 changed the title MineClone container groups Add support for MineClone container groups Nov 19, 2023
@BuckarooBanzay
Copy link
Member

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

@BuckarooBanzay BuckarooBanzay added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Nov 22, 2023
@ThePython10110
Copy link
Author

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
Copy link
Contributor

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

@corarona
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

corarona commented Dec 15, 2023

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

  • def._mcl_hoppers_on_try_pull(node_pos, hopper_pos, hopper_inv, hopper_list)
  • def._mcl_hoppers_on_try_push(node_pos, hopper_pos, hopper_inv, hopper_list)

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
Copy link
Contributor

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
Copy link

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.

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

No branches or pull requests

5 participants