mirror of
https://github.com/minetest-mods/hopper.git
synced 2024-12-22 13:22:28 +01:00
Fix error caused by rotated chutes
The 'top' inventory is no longer available when the chute is rotated along the X or Z axis.
This commit is contained in:
parent
e91bc6ef0c
commit
eee0dc0f13
26
utility.lua
26
utility.lua
@ -85,8 +85,13 @@ local function get_container_inventory(node_pos, inv_info)
|
|||||||
return inventory
|
return inventory
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Used to remove items from the target block and put it into the hopper's inventory
|
--- @param Removes items from the target node and puts them into the hopper's inventory
|
||||||
|
--- @param target_inv_info : Inventory information where to take the ItemStacks
|
||||||
hopper.take_item_from = function(hopper_pos, target_pos, target_node, target_inv_info)
|
hopper.take_item_from = function(hopper_pos, target_pos, target_node, target_inv_info)
|
||||||
|
if not target_inv_info then
|
||||||
|
return false -- Cannot move take from this direction
|
||||||
|
end
|
||||||
|
|
||||||
local target_def = minetest.registered_nodes[target_node.name]
|
local target_def = minetest.registered_nodes[target_node.name]
|
||||||
if not target_def then
|
if not target_def then
|
||||||
return
|
return
|
||||||
@ -161,6 +166,9 @@ local function try_send_item_to_air(hopper_inv, target_pos)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @brief Moves items from the hopper's inventory to the destination and triggers inventory actions
|
||||||
|
--- @param placer : (optional) PlayerRef
|
||||||
|
--- @param target_def : Target nodedef
|
||||||
local function send_item_to_inv(hopper_inv, target_pos, filtered_items, placer, target_inv_info, target_def)
|
local function send_item_to_inv(hopper_inv, target_pos, filtered_items, placer, target_inv_info, target_def)
|
||||||
local target_inv_name = target_inv_info.inventory_name
|
local target_inv_name = target_inv_info.inventory_name
|
||||||
local target_inv = get_container_inventory(target_pos, target_inv_info)
|
local target_inv = get_container_inventory(target_pos, target_inv_info)
|
||||||
@ -197,8 +205,14 @@ local function send_item_to_inv(hopper_inv, target_pos, filtered_items, placer,
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Used to put items from the hopper inventory into the target block
|
--- @brief Used to put items from the hopper inventory into the target block
|
||||||
|
--- @param target_inv_info : Inventory information where to put the ItemStacks
|
||||||
|
--- @param filtered_items : (optional) whitelist of item names { ["modname:itemname"] = true, ... }
|
||||||
hopper.send_item_to = function(hopper_pos, target_pos, target_node, target_inv_info, filtered_items)
|
hopper.send_item_to = function(hopper_pos, target_pos, target_node, target_inv_info, filtered_items)
|
||||||
|
if not target_inv_info then
|
||||||
|
return false -- Cannot move item into this direction
|
||||||
|
end
|
||||||
|
|
||||||
local target_def = minetest.registered_nodes[target_node.name]
|
local target_def = minetest.registered_nodes[target_node.name]
|
||||||
if not target_def then
|
if not target_def then
|
||||||
return false
|
return false
|
||||||
@ -210,12 +224,8 @@ hopper.send_item_to = function(hopper_pos, target_pos, target_node, target_inv_i
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if target_inv_info then
|
local placer = get_placer(hopper_meta:get_string("placer"))
|
||||||
local placer = get_placer(hopper_meta:get_string("placer"))
|
return send_item_to_inv(hopper_inv, target_pos, filtered_items, placer, target_inv_info, target_def)
|
||||||
return send_item_to_inv(hopper_inv, target_pos, filtered_items, placer, target_inv_info, target_def)
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
hopper.try_eject_item = function(hopper_pos, target_pos)
|
hopper.try_eject_item = function(hopper_pos, target_pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user