mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2024-12-23 00:20:17 +01:00
add hopper
support (#18)
This commit is contained in:
parent
a8fceb249d
commit
d68e90f017
@ -148,7 +148,8 @@ function homedecor.register_furnace(name, furnacedef)
|
|||||||
can_dig = furnace_can_dig,
|
can_dig = furnace_can_dig,
|
||||||
allow_metadata_inventory_put = furnace_allow_put,
|
allow_metadata_inventory_put = furnace_allow_put,
|
||||||
allow_metadata_inventory_move = furnace_allow_move,
|
allow_metadata_inventory_move = furnace_allow_move,
|
||||||
inventory = { lockable = true }
|
inventory = { lockable = true },
|
||||||
|
is_furnace = true
|
||||||
}
|
}
|
||||||
|
|
||||||
local def_active = {
|
local def_active = {
|
||||||
@ -162,7 +163,8 @@ function homedecor.register_furnace(name, furnacedef)
|
|||||||
can_dig = furnace_can_dig,
|
can_dig = furnace_can_dig,
|
||||||
allow_metadata_inventory_put = furnace_allow_put,
|
allow_metadata_inventory_put = furnace_allow_put,
|
||||||
allow_metadata_inventory_move = furnace_allow_move,
|
allow_metadata_inventory_move = furnace_allow_move,
|
||||||
inventory = { lockable = true }
|
inventory = { lockable = true },
|
||||||
|
is_furnace = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if furnacedef.extra_nodedef_fields then
|
if furnacedef.extra_nodedef_fields then
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
local S = minetest.get_translator("homedecor_common")
|
local S = minetest.get_translator("homedecor_common")
|
||||||
|
|
||||||
|
local has_hopper = minetest.get_modpath("hopper")
|
||||||
|
local has_safe_hopper = has_hopper and
|
||||||
|
-- mod from https://github.com/minetest-mods/hopper respects the owner
|
||||||
|
(hopper.neighbors or
|
||||||
|
-- mod from https://notabug.org/TenPlus1/hopper respects the owner since 20220123
|
||||||
|
(hopper.version and hopper.version >= "20220123"))
|
||||||
|
|
||||||
local default_can_dig = function(pos,player)
|
local default_can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
return meta:get_inventory():is_empty("main")
|
return meta:get_inventory():is_empty("main")
|
||||||
@ -97,6 +104,23 @@ function homedecor.handle_inventory(name, def, original_def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local locked = inventory.locked
|
local locked = inventory.locked
|
||||||
|
|
||||||
|
if has_hopper and (not locked or has_safe_hopper) then
|
||||||
|
if inventory.size then
|
||||||
|
hopper:add_container({
|
||||||
|
{"top", "homedecor:"..name, "main"},
|
||||||
|
{"bottom", "homedecor:"..name, "main"},
|
||||||
|
{"side", "homedecor:"..name, "main"},
|
||||||
|
})
|
||||||
|
elseif original_def.is_furnace then
|
||||||
|
hopper:add_container({
|
||||||
|
{"top", "homedecor:"..name, "dst"},
|
||||||
|
{"bottom", "homedecor:"..name, "src"},
|
||||||
|
{"side", "homedecor:"..name, "fuel"},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if locked then
|
if locked then
|
||||||
local after_place_node = def.after_place_node
|
local after_place_node = def.after_place_node
|
||||||
def.after_place_node = function(pos, placer)
|
def.after_place_node = function(pos, placer)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name = homedecor_common
|
name = homedecor_common
|
||||||
description = Homedecor mod: common
|
description = Homedecor mod: common
|
||||||
depends = default, creative
|
depends = default, creative
|
||||||
optional_depends = screwdriver
|
optional_depends = screwdriver, hopper
|
||||||
|
@ -6,6 +6,8 @@ local placeholder_node = "homedecor:expansion_placeholder"
|
|||||||
function homedecor.register(name, original_def)
|
function homedecor.register(name, original_def)
|
||||||
local def = table.copy(original_def)
|
local def = table.copy(original_def)
|
||||||
|
|
||||||
|
def.is_furnace = nil
|
||||||
|
|
||||||
def.drawtype = def.drawtype
|
def.drawtype = def.drawtype
|
||||||
or (def.mesh and "mesh")
|
or (def.mesh and "mesh")
|
||||||
or (def.node_box and "nodebox")
|
or (def.node_box and "nodebox")
|
||||||
|
Loading…
Reference in New Issue
Block a user