From c424b036b2876769e6f48be4f5af5668d1161ec4 Mon Sep 17 00:00:00 2001 From: kay27 Date: Mon, 10 Aug 2020 16:30:55 +0400 Subject: [PATCH 1/3] Fix furnaces timing when you leave them or skip the nights, https://git.minetest.land/Wuzzy/MineClone2/issues/533 --- mods/ITEMS/mcl_furnaces/init.lua | 213 ++++++++++++++++++++----------- 1 file changed, 135 insertions(+), 78 deletions(-) diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index c76b379e6..cb797ff91 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -153,11 +153,52 @@ local function swap_node(pos, name) minetest.swap_node(pos, node) end +local function furnace_reset_delta_time(pos) + local meta = minetest.get_meta(pos) + local time_multiplier = 86400 / (minetest.settings:get('time_speed') or 72) + local current_game_time = .0 + ((minetest.get_day_count() + minetest.get_timeofday()) * time_multiplier) + + -- TODO: Change meta:get/set_string() to get/set_float() for 'last_gametime'. + -- In Windows *_float() works OK but under Linux it returns rounded unusable values like 449540.000000000 + local last_game_time = meta:get_string("last_gametime") + if last_game_time then + last_game_time = tonumber(last_game_time) + end + if not last_game_time or last_game_time < 1 or math.abs(last_game_time - current_game_time) <= 1.5 then + return + end + + meta:set_string("last_gametime", tostring(current_game_time)) +end + +local function furnace_get_delta_time(pos) + local meta = minetest.get_meta(pos) + local time_multiplier = 86400 / (minetest.settings:get('time_speed') or 72) + local current_game_time = .0 + ((minetest.get_day_count() + minetest.get_timeofday()) * time_multiplier) + + local last_game_time = meta:get_string("last_gametime") + if last_game_time then + last_game_time = tonumber(last_game_time) + end + if not last_game_time or last_game_time < 1 then + last_game_time = current_game_time + elseif last_game_time == current_game_time then + current_game_time = current_game_time + 1.0 + end + + local elapsed_game_time = .0 + current_game_time - last_game_time + + meta:set_string("last_gametime", tostring(current_game_time)) + + return meta, elapsed_game_time +end + local function furnace_node_timer(pos, elapsed) -- -- Inizialize metadata -- - local meta = minetest.get_meta(pos) + local meta, elapsed_game_time = furnace_get_delta_time(pos) + local fuel_time = meta:get_float("fuel_time") or 0 local src_time = meta:get_float("src_time") or 0 local src_item = meta:get_string("src_item") or "" @@ -167,98 +208,101 @@ local function furnace_node_timer(pos, elapsed) local srclist, fuellist local cookable, cooked + local active local fuel + srclist = inv:get_list("src") + fuellist = inv:get_list("fuel") + + -- Check if src item has been changed + if srclist[1]:get_name() ~= src_item then + -- Reset cooking progress in this case + src_time = 0 + src_item = srclist[1]:get_name() + end + local update = true - while update do - update = false - - srclist = inv:get_list("src") - fuellist = inv:get_list("fuel") - + while elapsed_game_time > 0.00001 and update do -- -- Cooking -- - -- Check if we have cookable content + local el = elapsed_game_time + + -- Check if we have cookable content: cookable local aftercooked cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) cookable = cooked.time ~= 0 - - -- Check if src item has been changed - if srclist[1]:get_name() ~= src_item then - -- Reset cooking progress in this case - src_time = 0 - src_item = srclist[1]:get_name() - update = true - - -- Check if we have enough fuel to burn - elseif fuel_time < fuel_totaltime then - -- The furnace is currently active and has enough fuel - fuel_time = fuel_time + elapsed - -- If there is a cookable item then check if it is ready yet - if cookable then - -- Successful cooking requires space in dst slot and time - if inv:room_for_item("dst", cooked.item) then - src_time = src_time + elapsed - - -- Place result in dst list if done - if src_time >= cooked.time then - inv:add_item("dst", cooked.item) - inv:set_stack("src", 1, aftercooked.items[1]) - - -- Unique recipe: Pour water into empty bucket after cooking wet sponge successfully - if inv:get_stack("fuel", 1):get_name() == "mcl_buckets:bucket_empty" then - if srclist[1]:get_name() == "mcl_sponges:sponge_wet" then - inv:set_stack("fuel", 1, "mcl_buckets:bucket_water") - -- Also for river water - elseif srclist[1]:get_name() == "mcl_sponges:sponge_wet_river_water" then - inv:set_stack("fuel", 1, "mcl_buckets:bucket_river_water") - end - end - - src_time = 0 - update = true - end - elseif src_time ~= 0 then - -- If output slot is occupied, stop cooking - src_time = 0 - update = true - end + if cookable then + -- Successful cooking requires space in dst slot and time + if not inv:room_for_item("dst", cooked.item) then + cookable = false end - else - -- Furnace ran out of fuel - if cookable then - -- We need to get new fuel - local afterfuel - fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) - - if fuel.time == 0 then - -- No valid fuel in fuel list - fuel_totaltime = 0 - src_time = 0 - else - -- Take fuel from fuel list - inv:set_stack("fuel", 1, afterfuel.items[1]) - update = true - fuel_totaltime = fuel.time + (fuel_time - fuel_totaltime) - src_time = src_time + elapsed - end - else - -- We don't need to get new fuel since there is no cookable item - fuel_totaltime = 0 - src_time = 0 - end - fuel_time = 0 end - elapsed = 0 + if cookable then -- fuel lasts long enough, adjust el to cooking duration + el = math.min(el, cooked.time - src_time) + end + + -- Check if we have enough fuel to burn + active = fuel_time < fuel_totaltime + if cookable and not active then + -- We need to get new fuel + local afterfuel + fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) + + if fuel.time == 0 then + -- No valid fuel in fuel list -- stop + fuel_totaltime = 0 + src_time = 0 + update = false + else + -- Take fuel from fuel list + inv:set_stack("fuel", 1, afterfuel.items[1]) + fuel_time = 0 + fuel_totaltime = fuel.time + el = math.min(el, fuel_totaltime) + active = true + fuellist = inv:get_list("fuel") + end + elseif active then + el = math.min(el, fuel_totaltime - fuel_time) + -- The furnace is currently active and has enough fuel + fuel_time = fuel_time + el + end + + -- If there is a cookable item then check if it is ready yet + if cookable and active then + src_time = src_time + el + -- Place result in dst list if done + if src_time >= cooked.time then + inv:add_item("dst", cooked.item) + inv:set_stack("src", 1, aftercooked.items[1]) + + -- Unique recipe: Pour water into empty bucket after cooking wet sponge successfully + if inv:get_stack("fuel", 1):get_name() == "mcl_buckets:bucket_empty" then + if srclist[1]:get_name() == "mcl_sponges:sponge_wet" then + inv:set_stack("fuel", 1, "mcl_buckets:bucket_water") + fuellist = inv:get_list("fuel") + -- Also for river water + elseif srclist[1]:get_name() == "mcl_sponges:sponge_wet_river_water" then + inv:set_stack("fuel", 1, "mcl_buckets:bucket_river_water") + fuellist = inv:get_list("fuel") + end + end + + srclist = inv:get_list("src") + src_time = 0 + end + end + + elapsed_game_time = elapsed_game_time - el end if fuel and fuel_totaltime > fuel.time then fuel_totaltime = fuel.time end - if srclist[1]:is_empty() then + if srclist and srclist[1]:is_empty() then src_time = 0 end @@ -274,7 +318,7 @@ local function furnace_node_timer(pos, elapsed) local result = false - if fuel_totaltime ~= 0 then + if active then local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100) formspec = active_formspec(fuel_percent, item_percent) swap_node(pos, "mcl_furnaces:furnace_active") @@ -292,7 +336,11 @@ local function furnace_node_timer(pos, elapsed) meta:set_float("fuel_totaltime", fuel_totaltime) meta:set_float("fuel_time", fuel_time) meta:set_float("src_time", src_time) - meta:set_string("src_item", srclist[1]:get_name()) + if srclist then + meta:set_string("src_item", srclist[1]:get_name()) + else + meta:set_string("src_item", "") + end meta:set_string("formspec", formspec) return result @@ -347,17 +395,26 @@ minetest.register_node("mcl_furnaces:furnace", { end, on_metadata_inventory_move = function(pos) + -- Reset accumulated game time when player works with furnace: + furnace_reset_delta_time(pos) minetest.get_node_timer(pos):start(1.0) end, on_metadata_inventory_put = function(pos) + -- Reset accumulated game time when player works with furnace: + furnace_reset_delta_time(pos) -- start timer function, it will sort out whether furnace can burn or not. minetest.get_node_timer(pos):start(1.0) end, + on_metadata_inventory_take = function(pos) + -- Reset accumulated game time when player works with furnace: + furnace_reset_delta_time(pos) + -- start timer function, it will helpful if player clears dst slot + minetest.get_node_timer(pos):start(1.0) + end, allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_move = allow_metadata_inventory_move, allow_metadata_inventory_take = allow_metadata_inventory_take, - on_metadata_inventory_take = on_metadata_inventory_take, on_receive_fields = receive_fields, _mcl_blast_resistance = 3.5, _mcl_hardness = 3.5, From 9537eaead0456ee951be6843e89470c4d5b97511 Mon Sep 17 00:00:00 2001 From: kay27 Date: Mon, 10 Aug 2020 22:04:27 +0400 Subject: [PATCH 2/3] Protect from explosions --- mods/CORE/mcl_explosions/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/CORE/mcl_explosions/init.lua b/mods/CORE/mcl_explosions/init.lua index 242f0518b..84f3322df 100644 --- a/mods/CORE/mcl_explosions/init.lua +++ b/mods/CORE/mcl_explosions/init.lua @@ -195,7 +195,7 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance, fire, break end - if cid ~= minetest.CONTENT_AIR then + if cid ~= minetest.CONTENT_AIR and not minetest.is_protected({x = npos_x, y = npos_y, z = npos_z}, "") then destroy[hash] = idx end end From b8caa2581f14be47037392b5749e47ef4c002dd9 Mon Sep 17 00:00:00 2001 From: kay27 Date: Tue, 11 Aug 2020 01:59:58 +0400 Subject: [PATCH 3/3] Update Russian translation of Brewing --- .../mcl_inventory/locale/mcl_inventory.ru.tr | 2 +- .../mcl_potions/locale/mcl_potions.ru.tr | 54 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/mods/HUD/mcl_inventory/locale/mcl_inventory.ru.tr b/mods/HUD/mcl_inventory/locale/mcl_inventory.ru.tr index ab1c9a420..d378e168b 100644 --- a/mods/HUD/mcl_inventory/locale/mcl_inventory.ru.tr +++ b/mods/HUD/mcl_inventory/locale/mcl_inventory.ru.tr @@ -7,7 +7,7 @@ Building Blocks=Строительные блоки Decoration Blocks=Декоративные блоки Redstone=Редстоун (красный камень) Transportation=Транспорт -Brewing= +Brewing=Зелья Miscellaneous=Прочее Search Items=Искать предметы Foodstuffs=Продовольствие diff --git a/mods/ITEMS/mcl_potions/locale/mcl_potions.ru.tr b/mods/ITEMS/mcl_potions/locale/mcl_potions.ru.tr index d010f4a27..6a1d78c6e 100644 --- a/mods/ITEMS/mcl_potions/locale/mcl_potions.ru.tr +++ b/mods/ITEMS/mcl_potions/locale/mcl_potions.ru.tr @@ -1,12 +1,12 @@ # textdomain: mcl_potions - []= + []=<эффект> <длительность> [<фактор>] -Add a status effect to yourself. Arguments: : name of status effect, e.g. poison. : duration in seconds. : effect strength multiplier (1 @= 100%)= +Add a status effect to yourself. Arguments: : name of status effect, e.g. poison. : duration in seconds. : effect strength multiplier (1 @= 100%)=Добавляет вам эффект состояния. Параметры: <эффект> - название эффекта состояния, например, poison (отравление). <Длительность> - длительность в секундах. <Фактор> - коэффициент силы эффекта (1 @= 100%) -Missing effect parameter!= -Missing or invalid duration parameter!= -Invalid factor parameter!= -@1 is not an available status effect.= +Missing effect parameter!=Отсутствует параметр эффекта! +Missing or invalid duration parameter!=Отсутствует либо неправильно задан параметр длительности! +Invalid factor parameter!=Отсутствует параметр фактора! +@1 is not an available status effect.=@1 не является допустимым эффектом состояния. Fermented Spider Eye=Прокисший паучий глаз Glass Bottle=Стеклянная бутылка Liquid container=Контейнер для жидкостей @@ -46,19 +46,19 @@ Drinking a potion gives you a particular effect.=Выпивание зелья 1 HP/@1s | @2=1 HP/@1с | @2 @1 HP=@1 HP @1 Potion=Зелье @1 -Splash @1 Potion=Взрывающее зелье @1 +Splash @1 Potion=Взрывающееся зелье @1 Lingering @1 Potion=Оседающее зелье @1 -Arrow of @1=Стрельба @1 +Arrow of @1=Стрела @1 II= II IV= IV -@1 Potion@2=@1 Зелье@2 -Splash @1@2 Potion=Взрывающее зелье @1@2 +@1 Potion@2=Зелье @1 @2 +Splash @1@2 Potion=Взрывающееся зелье @1@2 Lingering @1@2 Potion=Оседающее зелье @1@2 -Arrow of @1@2=Стрельба @1@2 -@1 + Potion=@1 + Зелье -Splash @1 + Potion=Взрывающее @1 + Зелье -Lingering @1 + Potion=Оседающее @1 + Зелье -Arrow of @1 +=Стрельба @1 + +Arrow of @1@2=Стрела @1@2 +@1 + Potion=Зелье @1+ +Splash @1 + Potion=Взрывающееся зелье @1+ +Lingering @1 + Potion=Оседающее зелье @1+ +Arrow of @1 +=Стрела @1+ Awkward Potion=Невкусное зелье Awkward Splash Potion=Невкусное взрывающееся зелье Awkward Lingering Potion=Невкусное оседающее зелье @@ -75,31 +75,31 @@ Dragon's Breath=Дыхание дракона This item is used in brewing and can be combined with splash potions to create lingering potions.=Этот предмет используется в зельеварении и может объединяться со взрывающимися зельями, чтобы создать эффект оседания -Healing=Лечение +Healing=исцеления +4 HP=+4 HP +8 HP=+8 HP Instantly heals.=Лечит мгновенно -Harming=Вред +Harming=урона -6 HP=-6 HP -12 HP=-12 HP Instantly deals damage.=Вызывает мгновенную смерть. -Night Vision=Ночное зрение +Night Vision=ночного зрения Grants the ability to see in darkness.=Даёт возможность видеть в темноте -Swiftness=Быстрота +Swiftness=ускорения Increases walking speed.=Увеличивает скорость ходьбы -Slowness=Замедление +Slowness=замедления Decreases walking speed.=Уменьшает скорость ходьбы -Leaping=Прыгучесть +Leaping=прыгучести Increases jump strength.=Увеличивает силу прыжка -Poison=Отрава +Poison=отравления Applies the poison effect which deals damage at a regular interval.=Наносит эффект яда, который вызывает урон через равные промежутки времени. -Regeneration=Восстановление +Regeneration=восстановления Regenerates health over time.=Восстанавливает здоровье со временем. -Invisibility=Невидимость +Invisibility=невидимости Grants invisibility.=Делает невидимым. -Water Breathing=Подводное дыхание +Water Breathing=подводного дыхания Grants limitless breath underwater.=Даёт возможность неограниченно дышать под водой. -Fire Resistance=Огнестойкость +Fire Resistance=огнестойкости Grants immunity to damage from heat sources like fire.=Делает невосприимчивым к урону от источников тепла, например, от огня. Weakness=Слабость Weakness +=Слабость + @@ -109,7 +109,7 @@ Strength +=Сила + Try different combinations to create potions.=Пробуйте разные сочетания для приготовления зелий. No effect=Не оказывает эффекта -A throwable potion that will shatter on impact, where it gives all nearby players and mobs a status effect.=Зелье, которое можно метать. Оно разбивается при ударе и он дает всем ближайшим игрокам и мобам эффект статуса. +A throwable potion that will shatter on impact, where it gives all nearby players and mobs a status effect.=Зелье, которое можно метать. Оно разбивается при ударе и он дает всем ближайшим игрокам и мобам эффект состояния. This particular arrow is tipped and will give an effect when it hits a player or mob.=Эта необычная стрела с обработанным наконечником даёт эффект при попадании в игрока или моба.