mirror of
https://github.com/minetest-mods/hopper.git
synced 2024-11-19 22:03:47 +01:00
Vertical hoppers can now be rotated on their side and work as expected
Consistency is now maintained for side and vertical hoppers regarding which face of a target node they inject items into. Injecting from the top goes to the same inventory regardless of what hopper type did the injecting, and likewise injecting from the side goes ot the same inventory.
This commit is contained in:
parent
ce30c31a24
commit
ad0ad11039
34
init.lua
34
init.lua
@ -24,7 +24,7 @@ if single_craftable_item then
|
|||||||
else
|
else
|
||||||
hopper_usage = hopper_usage .. S("Hopper blocks come in both 'vertical' and 'side' forms. They can be interconverted between the two forms via the crafting grid.\n\n")
|
hopper_usage = hopper_usage .. S("Hopper blocks come in both 'vertical' and 'side' forms. They can be interconverted between the two forms via the crafting grid.\n\n")
|
||||||
end
|
end
|
||||||
hopper_usage = hopper_usage .. S("When used with furnaces, vertical hoppers inject items into the furnace's \"raw material\" inventory slot and side hoppers inject items into the furnace's \"fuel\" inventory slot.\n\nItems that cannot be placed in a target block's inventory will remain in the hopper.\n\nHoppers have the same permissions as the player that placed them. Hoppers placed by you are allowed to take items from or put items into locked chests that you own, but hoppers placed by other players will be unable to do so. A hopper's own inventory is not not owner-locked, though, so you can use this as a way to allow other players to deposit items into your locked chests.")
|
hopper_usage = hopper_usage .. S("When used with furnaces, hoppers inject items into the furnace's \"raw material\" inventory slot when the narrow end is attached to the top or bottom and inject items into the furnace's \"fuel\" inventory slot when attached to the furnace's side.\n\nItems that cannot be placed in a target block's inventory will remain in the hopper.\n\nHoppers have the same permissions as the player that placed them. Hoppers placed by you are allowed to take items from or put items into locked chests that you own, but hoppers placed by other players will be unable to do so. A hopper's own inventory is not not owner-locked, though, so you can use this as a way to allow other players to deposit items into your locked chests.")
|
||||||
|
|
||||||
local containers = {}
|
local containers = {}
|
||||||
local neighbors = {}
|
local neighbors = {}
|
||||||
@ -54,7 +54,10 @@ function hopper:add_container(list)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- default containers ( relative position, target node, node inventory affected )
|
-- "top" indicates what inventory the hopper will take items from if this node is located at the hopper's wide end
|
||||||
|
-- "side" indicates what inventory the hopper will put items into if this node is located at the hopper's narrow end and at the same height as the hopper
|
||||||
|
-- "bottom" indicates what inventory the hopper will put items into if this node is located at the hopper's narrow end and either above or below the hopper.
|
||||||
|
|
||||||
hopper:add_container({
|
hopper:add_container({
|
||||||
{"top", "hopper:hopper", "main"},
|
{"top", "hopper:hopper", "main"},
|
||||||
{"bottom", "hopper:hopper", "main"},
|
{"bottom", "hopper:hopper", "main"},
|
||||||
@ -156,6 +159,7 @@ minetest.register_node("hopper:hopper", {
|
|||||||
groups = {cracky = 3},
|
groups = {cracky = 3},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
tiles = {
|
tiles = {
|
||||||
"hopper_top_" .. texture_resolution .. ".png",
|
"hopper_top_" .. texture_resolution .. ".png",
|
||||||
"hopper_top_" .. texture_resolution .. ".png",
|
"hopper_top_" .. texture_resolution .. ".png",
|
||||||
@ -465,6 +469,15 @@ local directions = {
|
|||||||
[23]={["src"]={x=0, y=-1, z=0},["dst"]={x=0, y=0, z=-1}},
|
[23]={["src"]={x=0, y=-1, z=0},["dst"]={x=0, y=0, z=-1}},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local bottomdir = function(facedir)
|
||||||
|
return ({[0]={x=0, y=-1, z=0},
|
||||||
|
{x=0, y=0, z=-1},
|
||||||
|
{x=0, y=0, z=1},
|
||||||
|
{x=-1, y=0, z=0},
|
||||||
|
{x=1, y=0, z=0},
|
||||||
|
{x=0, y=1, z=0}})[math.floor(facedir/4)]
|
||||||
|
end
|
||||||
|
|
||||||
-- hopper workings
|
-- hopper workings
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
label = "Hopper transfer",
|
label = "Hopper transfer",
|
||||||
@ -475,13 +488,20 @@ minetest.register_abm({
|
|||||||
catch_up = false,
|
catch_up = false,
|
||||||
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local source_pos, destination_pos
|
local source_pos, destination_pos, destination_dir
|
||||||
if node.name == "hopper:hopper_side" then
|
if node.name == "hopper:hopper_side" then
|
||||||
source_pos = vector.add(pos, directions[node.param2].src)
|
source_pos = vector.add(pos, directions[node.param2].src)
|
||||||
destination_pos = vector.add(pos, directions[node.param2].dst)
|
destination_dir = directions[node.param2].dst
|
||||||
|
destination_pos = vector.add(pos, destination_dir)
|
||||||
else
|
else
|
||||||
source_pos = {x=pos.x, y=pos.y+1, z=pos.z}
|
destination_dir = bottomdir(node.param2)
|
||||||
destination_pos = {x=pos.x, y=pos.y-1, z=pos.z}
|
source_pos = vector.subtract(pos, destination_dir)
|
||||||
|
destination_pos = vector.add(pos, destination_dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
local output_direction
|
||||||
|
if destination_dir.y == 0 then
|
||||||
|
output_direction = "horizontal"
|
||||||
end
|
end
|
||||||
|
|
||||||
local source_node = minetest.get_node(source_pos)
|
local source_node = minetest.get_node(source_pos)
|
||||||
@ -492,7 +512,7 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
|
|
||||||
if containers[destination_node.name] ~= nil then
|
if containers[destination_node.name] ~= nil then
|
||||||
if node.name == "hopper:hopper_side" then
|
if output_direction == "horizontal" then
|
||||||
send_item_to(pos, destination_pos, destination_node, containers[destination_node.name]["side"])
|
send_item_to(pos, destination_pos, destination_node, containers[destination_node.name]["side"])
|
||||||
else
|
else
|
||||||
send_item_to(pos, destination_pos, destination_node, containers[destination_node.name]["bottom"])
|
send_item_to(pos, destination_pos, destination_node, containers[destination_node.name]["bottom"])
|
||||||
|
@ -50,9 +50,10 @@ msgstr ""
|
|||||||
|
|
||||||
#: init.lua:24
|
#: init.lua:24
|
||||||
msgid ""
|
msgid ""
|
||||||
"When used with furnaces, vertical hoppers inject items into the furnace's "
|
"When used with furnaces, hoppers inject items into the furnace's \"raw "
|
||||||
"\"raw material\" inventory slot and side hoppers inject items into the "
|
"material\" inventory slot when the narrow end is attached to the top or "
|
||||||
"furnace's \"fuel\" inventory slot.\n"
|
"bottom and inject items into the furnace's \"fuel\" inventory slot when "
|
||||||
|
"attached to the furnace's side.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Items that cannot be placed in a target block's inventory will remain in the "
|
"Items that cannot be placed in a target block's inventory will remain in the "
|
||||||
"hopper.\n"
|
"hopper.\n"
|
||||||
|
@ -50,9 +50,10 @@ msgstr ""
|
|||||||
|
|
||||||
#: init.lua:24
|
#: init.lua:24
|
||||||
msgid ""
|
msgid ""
|
||||||
"When used with furnaces, vertical hoppers inject items into the furnace's "
|
"When used with furnaces, hoppers inject items into the furnace's \"raw "
|
||||||
"\"raw material\" inventory slot and side hoppers inject items into the "
|
"material\" inventory slot when the narrow end is attached to the top or "
|
||||||
"furnace's \"fuel\" inventory slot.\n"
|
"bottom and inject items into the furnace's \"fuel\" inventory slot when "
|
||||||
|
"attached to the furnace's side.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Items that cannot be placed in a target block's inventory will remain in the "
|
"Items that cannot be placed in a target block's inventory will remain in the "
|
||||||
"hopper.\n"
|
"hopper.\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user