1
0
Fork 0

Fix more errors when building hoppers

This commit is contained in:
Wuzzy 2017-02-22 14:15:06 +01:00
parent 9b857e685e
commit 034614003d
1 changed files with 31 additions and 10 deletions

View File

@ -44,23 +44,44 @@ minetest.register_node("mcl_hoppers:hopper", {
inv:set_size("main", 5) inv:set_size("main", 5)
end, end,
after_place_node = function(pos, placer, itemstack, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.under local upos = pointed_thing.under
local pos2 = pointed_thing.above local apos = pointed_thing.above
local x = pos.x - pos2.x local bpos
local y = pos.y - pos2.y local uposnodedef = minetest.registered_nodes[minetest.get_node(upos).name]
local z = pos.z - pos2.z if uposnodedef.buildable_to then
bpos = upos
else
local aposnodedef = minetest.registered_nodes[minetest.get_node(apos).name]
if aposnodedef.buildable_to then
bpos = apos
end
end
if bpos == nil then
return itemstack
end
local x = upos.x - apos.x
local y = upos.y - apos.y
local z = upos.z - apos.z
if x == -1 then if x == -1 then
minetest.swap_node(pos2, {name="mcl_hoppers:hopper_side", param2=0}) minetest.set_node(bpos, {name="mcl_hoppers:hopper_side", param2=0})
elseif x == 1 then elseif x == 1 then
minetest.swap_node(pos2, {name="mcl_hoppers:hopper_side", param2=2}) minetest.set_node(bpos, {name="mcl_hoppers:hopper_side", param2=2})
elseif z == -1 then elseif z == -1 then
minetest.swap_node(pos2, {name="mcl_hoppers:hopper_side", param2=3}) minetest.set_node(bpos, {name="mcl_hoppers:hopper_side", param2=3})
elseif z == 1 then elseif z == 1 then
minetest.swap_node(pos2, {name="mcl_hoppers:hopper_side", param2=1}) minetest.set_node(bpos, {name="mcl_hoppers:hopper_side", param2=1})
else
minetest.set_node(bpos, {name="mcl_hoppers:hopper", param2=0})
end end
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end, end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)