From 2664fb871b7d9295b4d4b4f7ce63eb220daf2f09 Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 24 Oct 2022 16:23:14 +0200 Subject: [PATCH] sweet berries plantable not only on farming soil --- mods/ITEMS/mcl_campfires/init.lua | 16 ++++++++-------- mods/ITEMS/mcl_farming/sweet_berry.lua | 14 +++++++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mods/ITEMS/mcl_campfires/init.lua b/mods/ITEMS/mcl_campfires/init.lua index 195612533..083fbce57 100644 --- a/mods/ITEMS/mcl_campfires/init.lua +++ b/mods/ITEMS/mcl_campfires/init.lua @@ -59,18 +59,18 @@ for _, campfire in pairs(campfires) do drawtype = "mesh", mesh = "mcl_campfires_campfire_lit.obj", tiles = {{ - name="mcl_campfires_" .. campfire.techname .. "_fire.png", + name="mcl_campfires_" .. campfire.techname .. "_fire.png", animation={ - type="vertical_frames", - aspect_w=16, - aspect_h=16, + type="vertical_frames", + aspect_w=16, + aspect_h=16, length=2.0 }}, - {name="mcl_campfires_" .. campfire.techname .. "_log_lit.png", + {name="mcl_campfires_" .. campfire.techname .. "_log_lit.png", animation={ - type="vertical_frames", - aspect_w=16, - aspect_h=16, + type="vertical_frames", + aspect_w=16, + aspect_h=16, length=2.0 }} }, diff --git a/mods/ITEMS/mcl_farming/sweet_berry.lua b/mods/ITEMS/mcl_farming/sweet_berry.lua index 3307dd271..de5db82bc 100644 --- a/mods/ITEMS/mcl_farming/sweet_berry.lua +++ b/mods/ITEMS/mcl_farming/sweet_berry.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local planton = {"mcl_core:dirt_with_grass","mcl_core:dirt","mcl_core:podzol","mcl_core:coarse_dirt","mcl_farming:soil","mcl_moss:moss"} + for i=0, 3 do local texture = "mcl_farming_sweet_berry_bush_" .. i .. ".png" local node_name = "mcl_farming:sweet_berry_bush_" .. i @@ -40,12 +42,14 @@ minetest.register_craftitem("mcl_farming:sweet_berry", { groups = { food = 2, eatable = 1, compostability=30 }, on_secondary_use = minetest.item_eat(1), on_place = function(itemstack, placer, pointed_thing) - local new = mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_sweet_berry:sweet_berry_bush_0") - if new then - return new - else - return minetest.do_item_eat(1, nil, itemstack, placer, pointed_thing) + if pointed_thing.type == "node" and table.indexof(planton,minetest.get_node(pointed_thing.under).name) ~= -1 and minetest.get_node(pointed_thing.above).name == "air" then + minetest.set_node(pointed_thing.above,{name="mcl_farming:sweet_berry_bush_0"}) + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:take_item() + end + return itemstack end + return minetest.do_item_eat(1, nil, itemstack, placer, pointed_thing) end, }) minetest.register_alias("mcl_sweet_berry:sweet_berry", "mcl_farming:sweet_berry")