1
0
Fork 0
DigWorks/mods/ITEMS/mcl_mushrooms/small.lua

103 lines
3.4 KiB
Lua
Raw Normal View History

local on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
-- no interaction possible with entities
return itemstack
end
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node(pointed_thing.under)
if placer and not placer:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
end
end
local a = pointed_thing.above
local node_above = minetest.get_node(a)
local node_below = minetest.get_node({x=a.x, y=a.y-1, z=a.z})
local def = minetest.registered_nodes[node_below.name]
local def2 = minetest.registered_nodes[node_above.name]
-- Placement rules:
-- * Always allowed on podzol or mycelimu
-- * Otherwise, must be solid, opaque and have daylight light level <= 12
local light = minetest.get_node_light(a, 0.5)
local light_ok = false
if light and light <= 12 then
light_ok = true
end
if (node_below.name == "mcl_core:podzol" or node_below.name == "mcl_core:mycelium") or
(light_ok and (def.groups and def.groups.solid and def.groups.opaque)) and
def2.buildable_to then
local idef = itemstack:get_definition()
local success = minetest.item_place_node(itemstack, placer, pointed_thing)
if success then
if idef.sounds and idef.sounds.place then
minetest.sound_play(idef.sounds.place, {pos=above, gain=1})
end
end
end
return itemstack
end
2017-03-01 01:16:52 +01:00
minetest.register_node("mcl_mushrooms:mushroom_brown", {
2015-06-29 19:55:56 +02:00
description = "Brown Mushroom",
drawtype = "plantlike",
tiles = { "farming_mushroom_brown.png" },
inventory_image = "farming_mushroom_brown.png",
wield_image = "farming_mushroom_brown.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,dig_by_piston=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
2017-01-04 10:11:35 +01:00
light_source = 1,
2015-06-29 19:55:56 +02:00
selection_box = {
type = "fixed",
fixed = { -3/16, -0.5, -3/16, 3/16, -2/16, 3/16 },
2015-06-29 19:55:56 +02:00
},
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
2015-06-29 19:55:56 +02:00
})
2017-03-01 01:16:52 +01:00
minetest.register_node("mcl_mushrooms:mushroom_red", {
2015-06-29 19:55:56 +02:00
description = "Red Mushroom",
drawtype = "plantlike",
tiles = { "farming_mushroom_red.png" },
inventory_image = "farming_mushroom_red.png",
wield_image = "farming_mushroom_red.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,dig_by_piston=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
2015-06-29 19:55:56 +02:00
selection_box = {
type = "fixed",
fixed = { -3/16, -0.5, -3/16, 3/16, -2/16, 3/16 },
2015-06-29 19:55:56 +02:00
},
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
2015-06-29 19:55:56 +02:00
})
2017-03-01 01:16:52 +01:00
minetest.register_craftitem("mcl_mushrooms:mushroom_stew", {
2015-06-29 19:55:56 +02:00
description = "Mushroom Stew",
_doc_items_longdesc = "Mushroom stew is a healthy soup which can be consumed for 6 hunger points.",
2017-01-20 18:38:12 +01:00
inventory_image = "farming_mushroom_stew.png",
2017-02-16 17:45:33 +01:00
on_place = minetest.item_eat(6, "mcl_core:bowl"),
on_secondary_use = minetest.item_eat(6, "mcl_core:bowl"),
2017-02-16 15:08:26 +01:00
groups = { food = 3, eatable = 6 },
2017-01-16 23:34:40 +01:00
stack_max = 1,
2015-06-29 19:55:56 +02:00
})
minetest.register_craft({
type = "shapeless",
2017-03-01 01:16:52 +01:00
output = "mcl_mushrooms:mushroom_stew",
recipe = {'mcl_core:bowl', 'mcl_mushrooms:mushroom_brown', 'mcl_mushrooms:mushroom_red'}
2017-01-04 10:11:35 +01:00
})
2017-03-01 01:16:52 +01:00