1
0
Fork 0

Update on_place callbacks when placing hopper

objects
Wuzzy 2018-01-10 16:44:50 +01:00
parent 8b15e41b12
commit 990a9a8b46
1 changed files with 15 additions and 28 deletions

View File

@ -1,5 +1,8 @@
local chest = minetest.get_content_id("mcl_chests:chest")
--[[ BEGIN OF NODE DEFINITIONS ]]
local mcl_hoppers_formspec =
"size[9,7]"..
"background[-0.19,-0.25;9.41,10.48;mcl_hoppers_inventory.png]"..
@ -10,9 +13,6 @@ local mcl_hoppers_formspec =
"listring[current_name;main]"..
"listring[current_player;main]"
--[[ BEGIN OF NODE DEFINITIONS ]]
local redstone_rules =
{{x= 1, y= 0, z= 0},
{x=-1, y= 0, z= 0},
@ -126,39 +126,26 @@ def_hopper_enabled.on_place = function(itemstack, placer, pointed_thing)
end
end
local bpos
if uposnodedef.buildable_to then
bpos = upos
else
local aposnodedef = minetest.registered_nodes[minetest.get_node(apos).name]
if not aposnodedef then return itemstack end
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
local fake_itemstack = ItemStack(itemstack)
local newnode, param2
if x == -1 then
minetest.set_node(bpos, {name="mcl_hoppers:hopper_side", param2=0})
fake_itemstack:set_name("mcl_hoppers:hopper_side")
param2 = 0
elseif x == 1 then
minetest.set_node(bpos, {name="mcl_hoppers:hopper_side", param2=2})
fake_itemstack:set_name("mcl_hoppers:hopper_side")
param2 = 2
elseif z == -1 then
minetest.set_node(bpos, {name="mcl_hoppers:hopper_side", param2=3})
fake_itemstack:set_name("mcl_hoppers:hopper_side")
param2 = 3
elseif z == 1 then
minetest.set_node(bpos, {name="mcl_hoppers:hopper_side", param2=1})
else
minetest.set_node(bpos, {name="mcl_hoppers:hopper", param2=0})
end
if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item()
fake_itemstack:set_name("mcl_hoppers:hopper_side")
param2 = 1
end
local itemstack, success = minetest.item_place_node(fake_itemstack, placer, pointed_thing, param2)
itemstack:set_name("mcl_hoppers:hopper")
return itemstack
end
def_hopper_enabled.mesecons = {