HybridDog / connected_chests

Adds big chests to minetest.
https://forum.minetest.net/viewtopic.php?f=9&t=10264&p=156571
Other
6 stars 7 forks source link

Add support the hopper mod #14

Closed rautyrauty closed 1 month ago

rautyrauty commented 4 months ago

closes: #13 requires: https://github.com/minetest-mods/hopper/pull/26

rautyrauty commented 4 months ago

Well, I wrote to all the developers of the hopper mod (FaceDeer, tenplus1 and SmallJoker) and everyone ignores me. 😕

Please write your opinion about the array "deco_nodes". I don't have a better solution yet. The Minetest developers are already aware of the pointed_thing problem with the non-standard selection_box: https://github.com/minetest/minetest/issues/9147 Or is it not a problem, since we are really pointing to the left node.

HybridDog commented 4 months ago

I think a cleaner solution could be to extend the hopper API such that it is possible to specify a function which returns the container's inventory and inventory name, or something similar. For example:

hopper:add_container({
    container_node = "default:chest_connected_left",
    get_inventory = function(target_pos, where_from)
        local chest_left_pos = target_pos
        return minetest.get_meta(chest_left_pos):get_inventory(), "main"
    end,
})

hopper:add_container({
    container_node = "default:chest_connected_right",
    get_inventory = function(target_pos, where_from)
        local node = minetest.get_node(target_pos)
        if node.param2 > 3 then
            -- The right connected chest node has an invalid param2 value
            -- Cannot determine the inventory
            return
        end
        local x, z = unpack(param_tab2[node.param2])
        local chest_left_pos = {x=pos.x+x, y=pos.y, z=pos.z+z}
        local node_left = minetest.get_node(chest_left_pos)
        if node_left.name ~= "default:chest_connected_left"
        or node_left.param2 ~= node.param2 then
            -- On the left there is no valild connected chest node
            -- Cannot determine the inventory
            return
        end
        return minetest.get_meta(chest_left_pos):get_inventory(), "main"
    end,
})
rautyrauty commented 4 months ago

Yes, you're right. I'll do it. But what about "deco_nodes"?

HybridDog commented 4 months ago

If I understand it correctly, the problem is finding the hopper param2 value when it is placed on the right side of a connected chest, where the pointed thing's under is the position of the left side, which is not directly next to above, where the placed node appears.

I think both real_inv_pos and deco_nodes should not be saved in node metadata because they would be wrong if the connected chest is pushed by a piston or moved in some other way.

It should be possible to add an optional function argument to hopper:add_container which returns all positions which belong to the container and use this if, when the hopper is placed, the pointed thing's under is not directly next to above; for example something like this:

hopper:add_container({
    container_node = "default:chest_connected_left",
    get_container_positions = function(pos)
        local node = minetest.get_node(pos)
        if node.param2 > 3 then
            -- The left connected chest node has an invalid param2 value
            return {pos}
        end
        local x, z = unpack(param_tab2[node.param2])
        return {pos, {x=pos.x-x, y=pos.y, z=pos.z-z}}
    end,
    get_inventory = function(target_pos, where_from)
        […]
    end
})

The hopper mod could first compare pointed thing's under with above to find a param2 value, and if it doesn't work and the get_container_positions argument exists, compare above with all position returned by get_container_positions. I don't know if there are simpler ways to solve the problem.

rautyrauty commented 3 months ago

Yes, you're right again. But, before the next changes, I want to wait for at least one hopper developer. I have a suspicion that the hopper mod is dead.

SmallJoker commented 2 months ago

Off-topic:

@rautyrauty

Well, I wrote to all the developers of the hopper mod

FYI I did not ignore you on purpose. It just happens that - whatever means you used - did not show up on my side. Please request a review or @-ping me where needed. That's usually how things appear in my GitHub notifications.

rautyrauty commented 2 months ago

@SmallJoker

I wrote to you in the mk939@ymail.com. I found it here: https://github.com/minetest/minetest/blob/master/.mailmap#L32

Yes, I forgot about @-ping.

rautyrauty commented 2 months ago

I got confused in my repositories and therefore made mistakes.

rautyrauty commented 1 month ago

@HybridDog merge pls