From a511152cdf43bdc82f93481209f14025bed9f688 Mon Sep 17 00:00:00 2001 From: kay27 Date: Sun, 27 Sep 2020 22:56:39 +0400 Subject: [PATCH] Fix glass bottles remained empty on take water from cauldrons, https://github.com/kay27/MineClone2/issues/1 --- mods/ITEMS/mcl_potions/init.lua | 49 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index 4b96a80dc..b7f814c24 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -105,34 +105,31 @@ minetest.register_craftitem("mcl_potions:glass_bottle", { end end if get_water then - local creative = minetest.is_creative_enabled(placer:get_player_name()) - if from_liquid_source or creative then - -- Replace with water bottle, if possible, otherwise - -- place the water potion at a place where's space - local water_bottle - if river_water then - water_bottle = ItemStack("mcl_potions:river_water") - else - water_bottle = ItemStack("mcl_potions:water") - end - local inv = placer:get_inventory() - if creative then - -- Don't replace empty bottle in creative for convenience reasons - if not inv:contains_item("main", water_bottle) then - inv:add_item("main", water_bottle) - end - elseif itemstack:get_count() == 1 then - return water_bottle - else - if inv:room_for_item("main", water_bottle) then - inv:add_item("main", water_bottle) - else - minetest.add_item(placer:get_pos(), water_bottle) - end - itemstack:take_item() - end + local water_bottle + if river_water then + water_bottle = ItemStack("mcl_potions:river_water") + else + water_bottle = ItemStack("mcl_potions:water") end + -- Replace with water bottle, if possible, otherwise + -- place the water potion at a place where's space + local inv = placer:get_inventory() minetest.sound_play("mcl_potions_bottle_fill", {pos=pointed_thing.under, gain=0.5, max_hear_range=16}, true) + if minetest.is_creative_enabled(placer:get_player_name()) then + -- Don't replace empty bottle in creative for convenience reasons + if not inv:contains_item("main", water_bottle) then + inv:add_item("main", water_bottle) + end + elseif itemstack:get_count() == 1 then + return water_bottle + else + if inv:room_for_item("main", water_bottle) then + inv:add_item("main", water_bottle) + else + minetest.add_item(placer:get_pos(), water_bottle) + end + itemstack:take_item() + end end end return itemstack