Get rid of mcl_hoppers:hopper_item

Fixes hoppers being able to build in a weird way
This commit is contained in:
Wuzzy 2017-02-22 14:00:58 +01:00
parent e603b119ef
commit 9b857e685e

View file

@ -13,9 +13,10 @@ local mcl_hoppers_formspec =
"listring[current_player;main]"
minetest.register_node("mcl_hoppers:hopper", {
drop = "mcl_hoppers:hopper_item",
description = "Hopper (Node)",
groups = {cracky=1,level=2,container=2,not_in_creative_inventory=1},
description = "Hopper",
inventory_image = "mcl_hoppers_item.png",
wield_image = "mcl_hoppers_item.png",
groups = {cracky=1,level=2,container=2,deco_block=1,},
drawtype = "nodebox",
paramtype = "light",
tiles = {"mcl_hoppers_hopper_inside.png^mcl_hoppers_hopper_top.png", "mcl_hoppers_hopper_outside.png", "mcl_hoppers_hopper_outside.png", "mcl_hoppers_hopper_inside.png", "mcl_hoppers_hopper_outside.png", "mcl_hoppers_hopper_outside.png"},
@ -42,6 +43,26 @@ minetest.register_node("mcl_hoppers:hopper", {
local inv = meta:get_inventory()
inv:set_size("main", 5)
end,
after_place_node = function(pos, placer, itemstack, pointed_thing)
local pos = pointed_thing.under
local pos2 = pointed_thing.above
local x = pos.x - pos2.x
local y = pos.y - pos2.y
local z = pos.z - pos2.z
if x == -1 then
minetest.swap_node(pos2, {name="mcl_hoppers:hopper_side", param2=0})
elseif x == 1 then
minetest.swap_node(pos2, {name="mcl_hoppers:hopper_side", param2=2})
elseif z == -1 then
minetest.swap_node(pos2, {name="mcl_hoppers:hopper_side", param2=3})
elseif z == 1 then
minetest.swap_node(pos2, {name="mcl_hoppers:hopper_side", param2=1})
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos)
local meta2 = meta
@ -73,7 +94,7 @@ minetest.register_node("mcl_hoppers:hopper", {
minetest.register_node("mcl_hoppers:hopper_side", {
description = "Hopper (Side)",
drop = "mcl_hoppers:hopper_item",
drop = "mcl_hoppers:hopper",
groups = {cracky=1,level=2,container=2,not_in_creative_inventory=1},
drawtype = "nodebox",
paramtype = "light",
@ -102,6 +123,7 @@ minetest.register_node("mcl_hoppers:hopper_side", {
local inv = meta:get_inventory()
inv:set_size("main", 5)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos)
local meta2 = meta
@ -238,7 +260,7 @@ minetest.register_abm({
local above = {x=pos.x,y=pos.y+1,z=pos.z}
local frontnode = minetest.get_node(front)
-- Suck an item from the container above into the hopper
local abovenode = minetest.get_node(above)
local g = minetest.registered_nodes[abovenode.name].groups.container
@ -272,51 +294,14 @@ minetest.register_abm({
end
})
minetest.register_craftitem("mcl_hoppers:hopper_item", {
description = "Hopper",
inventory_image = "mcl_hoppers_item.png",
-- TODO: Move to redstone category
groups = { deco_block = 1 },
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.under
local pos2 = pointed_thing.above
local x = pos.x - pos2.x
local y = pos.y - pos2.y
local z = pos.z - pos2.z
local placed = false
if x == -1 then
minetest.set_node(pos2, {name="mcl_hoppers:hopper_side", param2=0})
placed = true
elseif x == 1 then
minetest.set_node(pos2, {name="mcl_hoppers:hopper_side", param2=2})
placed = true
elseif z == -1 then
minetest.set_node(pos2, {name="mcl_hoppers:hopper_side", param2=3})
placed = true
elseif z == 1 then
minetest.set_node(pos2, {name="mcl_hoppers:hopper_side", param2=1})
placed = true
else
minetest.set_node(pos2, {name="mcl_hoppers:hopper"})
placed = true
end
if placed == true then
minetest.sound_play(mcl_sounds.node_sound_metal_defaults().place, { pos = pos2 })
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end
end,
})
minetest.register_craft({
output = "mcl_hoppers:hopper_item",
output = "mcl_hoppers:hopper",
recipe = {
{"mcl_core:iron_ingot","","mcl_core:iron_ingot"},
{"mcl_core:iron_ingot","mcl_chests:chest","mcl_core:iron_ingot"},
{"","mcl_core:iron_ingot",""},
}
})
-- Legacy
minetest.register_alias("mcl_hoppers:hopper_item", "mcl_hoppers:hopper")