2023-11-23 18:17:53 +01:00
|
|
|
-- Registers all energy values
|
|
|
|
|
|
|
|
-- Gets lists of energy values
|
2023-11-10 23:43:10 +01:00
|
|
|
dofile(minetest.get_modpath("_exchangeclone_energy").."/energy_values.lua")
|
2023-03-27 19:13:23 +02:00
|
|
|
|
2023-11-26 16:24:45 +01:00
|
|
|
local function get_cheapest_recipe(recipes, log)
|
2023-11-08 03:00:09 +01:00
|
|
|
if not recipes then return end
|
2023-11-03 00:33:30 +01:00
|
|
|
local cheapest
|
|
|
|
for _, recipe in ipairs(recipes) do
|
|
|
|
local ingredient_cost = 0
|
|
|
|
local output_count = ItemStack(recipe.output):get_count()
|
2023-11-23 18:17:53 +01:00
|
|
|
local output_name = ItemStack(recipe.output):get_name()
|
2023-11-03 00:33:30 +01:00
|
|
|
local skip = false
|
2023-11-10 23:43:10 +01:00
|
|
|
if not recipe.type or recipe.type == "shaped" then
|
2023-11-03 00:33:30 +01:00
|
|
|
for _, row in ipairs(recipe.recipe) do
|
|
|
|
for _, item in ipairs(row) do
|
|
|
|
if item ~= "" then
|
2023-11-23 18:17:53 +01:00
|
|
|
if item == output_name then
|
|
|
|
output_count = output_count - 1
|
2023-11-08 03:00:09 +01:00
|
|
|
else
|
2023-11-23 18:17:53 +01:00
|
|
|
local cost = exchangeclone.get_item_energy(item)
|
|
|
|
if (not cost) or cost == 0 then
|
|
|
|
skip = item
|
|
|
|
else
|
|
|
|
ingredient_cost = ingredient_cost + cost
|
|
|
|
end
|
2023-11-08 03:00:09 +01:00
|
|
|
end
|
2023-11-03 00:33:30 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2023-11-13 02:30:16 +01:00
|
|
|
elseif (recipe.type == "shapeless") or (recipe.type == "technic") then
|
2023-11-03 00:33:30 +01:00
|
|
|
for _, item in ipairs(recipe.recipe) do
|
2023-11-23 18:17:53 +01:00
|
|
|
if item == output_name then
|
|
|
|
output_count = output_count - 1
|
2023-11-08 03:00:09 +01:00
|
|
|
else
|
2023-11-23 18:17:53 +01:00
|
|
|
local cost = exchangeclone.get_item_energy(item)
|
|
|
|
if (not cost) or cost == 0 then
|
|
|
|
skip = item
|
|
|
|
else
|
|
|
|
ingredient_cost = ingredient_cost + cost
|
|
|
|
end
|
2023-11-08 03:00:09 +01:00
|
|
|
end
|
2023-11-03 00:33:30 +01:00
|
|
|
end
|
2023-11-23 18:17:53 +01:00
|
|
|
elseif recipe.type == "cooking" or recipe.type == "stonecutting" then
|
2023-11-03 00:33:30 +01:00
|
|
|
local cost = exchangeclone.get_item_energy(recipe.recipe)
|
2023-11-08 03:00:09 +01:00
|
|
|
if (not cost) or cost == 0 then
|
2023-11-10 23:43:10 +01:00
|
|
|
skip = recipe.recipe
|
2023-11-08 03:00:09 +01:00
|
|
|
else
|
2023-11-23 18:17:53 +01:00
|
|
|
ingredient_cost = cost
|
2023-11-08 03:00:09 +01:00
|
|
|
end
|
2023-11-03 00:33:30 +01:00
|
|
|
end
|
|
|
|
if recipe.replacements and not skip then
|
|
|
|
for _, item in ipairs(recipe.replacements) do
|
|
|
|
local cost = exchangeclone.get_item_energy(item[2])
|
2023-11-08 03:00:09 +01:00
|
|
|
if (not cost) or cost == 0 then
|
2023-11-10 23:43:10 +01:00
|
|
|
skip = item
|
2023-11-08 03:00:09 +01:00
|
|
|
else
|
|
|
|
ingredient_cost = ingredient_cost - cost
|
|
|
|
end
|
2023-11-03 00:33:30 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
if not skip then
|
2023-11-23 18:17:53 +01:00
|
|
|
ingredient_cost = math.floor(ingredient_cost*20/output_count)/20 -- allow .05, won't work with huge numbers
|
2023-11-03 00:33:30 +01:00
|
|
|
if (not cheapest) or (cheapest[1] > ingredient_cost) then
|
|
|
|
cheapest = {ingredient_cost, recipe}
|
|
|
|
end
|
|
|
|
end
|
2023-11-26 16:24:45 +01:00
|
|
|
if log then minetest.log(dump({
|
|
|
|
recipe = recipe,
|
|
|
|
ingredient_cost = ingredient_cost,
|
|
|
|
output_count = output_count
|
|
|
|
})) end
|
2023-04-14 20:44:18 +02:00
|
|
|
end
|
2023-11-03 00:33:30 +01:00
|
|
|
return cheapest and cheapest[1]
|
2023-03-27 19:13:23 +02:00
|
|
|
end
|
|
|
|
|
2023-06-21 23:45:22 +02:00
|
|
|
local function set_item_energy(itemstring, energy_value)
|
2023-11-10 23:43:10 +01:00
|
|
|
if not (energy_value and itemstring) then return end
|
2023-11-22 19:36:16 +01:00
|
|
|
energy_value = math.floor(energy_value*20)/20 -- floor to nearest .05
|
2023-11-10 23:43:10 +01:00
|
|
|
if energy_value < 0 then return end
|
2023-05-13 21:13:22 +02:00
|
|
|
local def = minetest.registered_items[itemstring]
|
|
|
|
if not def then return end
|
2023-11-19 01:48:35 +01:00
|
|
|
local description = def.description or ""
|
|
|
|
local existing_energy_value = description:find("Energy Value: ([%d%.,]+)")
|
2023-05-13 21:13:22 +02:00
|
|
|
if existing_energy_value then
|
2023-11-19 01:48:35 +01:00
|
|
|
description = description:gsub("Energy Value: ([%d%.,]+)", "Energy Value: "..exchangeclone.format_number(energy_value))
|
2023-05-13 21:13:22 +02:00
|
|
|
else
|
|
|
|
if description[#description] ~= "\n" then
|
|
|
|
description = description.."\n"
|
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
description = description.."Energy Value: "..exchangeclone.format_number(energy_value)
|
2023-05-13 21:13:22 +02:00
|
|
|
end
|
|
|
|
minetest.override_item(itemstring, {
|
|
|
|
description = description,
|
|
|
|
energy_value = energy_value,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
local function add_potion_energy(info)
|
2023-11-10 23:43:10 +01:00
|
|
|
local base_cost = exchangeclone.get_item_energy("mcl_potions:water") or 1 --cost of water bottle
|
2023-11-19 01:48:35 +01:00
|
|
|
-- TODO: Change dragon's breath when MineClone does.
|
2023-11-10 23:43:10 +01:00
|
|
|
local dragon_breath_cost = exchangeclone.get_item_energy("mcl_potions:dragon_breath") or 8.5
|
2023-11-08 03:00:09 +01:00
|
|
|
base_cost = math.floor(base_cost + (info.ingredient_cost / 3)) -- /3 because 3 potions/ingredient
|
2023-11-10 23:43:10 +01:00
|
|
|
base_cost = base_cost + (info.custom_base_cost or (exchangeclone.get_item_energy("mcl_nether:nether_wart_item") or 24)/3)
|
|
|
|
local splash_cost = base_cost + (exchangeclone.get_item_energy("mcl_mobitems:gunpowder") or 192)/3
|
2023-05-13 21:13:22 +02:00
|
|
|
local lingering_cost = math.floor(base_cost + (dragon_breath_cost / 3))
|
2023-06-21 23:45:22 +02:00
|
|
|
set_item_energy("mcl_potions:"..info.name, base_cost)
|
|
|
|
set_item_energy("mcl_potions:"..info.name.."_splash", splash_cost)
|
|
|
|
set_item_energy("mcl_potions:"..info.name.."_lingering", lingering_cost)
|
2023-05-13 21:13:22 +02:00
|
|
|
if not info.no_arrow then
|
2023-11-10 23:43:10 +01:00
|
|
|
local arrow_cost = math.floor(lingering_cost/8 + (exchangeclone.get_item_energy("mcl_bows:arrow") or 14))
|
2023-06-21 23:45:22 +02:00
|
|
|
set_item_energy("mcl_potions:"..info.name.."_arrow", arrow_cost)
|
2023-05-13 21:13:22 +02:00
|
|
|
end
|
|
|
|
if info.plus then
|
2023-11-10 23:43:10 +01:00
|
|
|
local plus_base_cost = base_cost + (exchangeclone.get_item_energy("mesecons:redstone") or 64)/3
|
|
|
|
local plus_splash_cost = splash_cost + (exchangeclone.get_item_energy("mesecons:redstone") or 64)/3
|
|
|
|
local plus_lingering_cost = lingering_cost + (exchangeclone.get_item_energy("mesecons:redstone") or 64)/3
|
2023-06-21 23:45:22 +02:00
|
|
|
set_item_energy("mcl_potions:"..info.name.."_plus", plus_base_cost)
|
|
|
|
set_item_energy("mcl_potions:"..info.name.."_plus_splash", plus_splash_cost)
|
|
|
|
set_item_energy("mcl_potions:"..info.name.."_plus_lingering", plus_lingering_cost)
|
2023-11-10 23:43:10 +01:00
|
|
|
if not info.no_arrow then
|
|
|
|
local plus_arrow_cost = math.floor(plus_lingering_cost/8 + (exchangeclone.get_item_energy("mcl_bows:arrow") or 14))
|
|
|
|
set_item_energy("mcl_potions:"..info.name.."_plus_arrow", plus_arrow_cost)
|
|
|
|
end
|
2023-05-13 21:13:22 +02:00
|
|
|
end
|
|
|
|
if info.two then
|
2023-11-10 23:43:10 +01:00
|
|
|
local two_base_cost = base_cost + (exchangeclone.get_item_energy("mcl_nether:glowstone_dust") or 384)/3
|
|
|
|
local two_splash_cost = splash_cost + (exchangeclone.get_item_energy("mcl_nether:glowstone_dust") or 384)/3
|
|
|
|
local two_lingering_cost = lingering_cost + (exchangeclone.get_item_energy("mcl_nether:glowstone_dust") or 384)/3
|
2023-06-21 23:45:22 +02:00
|
|
|
set_item_energy("mcl_potions:"..info.name.."_2", two_base_cost)
|
|
|
|
set_item_energy("mcl_potions:"..info.name.."_2_splash", two_splash_cost)
|
|
|
|
set_item_energy("mcl_potions:"..info.name.."_2_lingering", two_lingering_cost)
|
2023-11-10 23:43:10 +01:00
|
|
|
if not info.no_arrow then
|
|
|
|
local two_arrow_cost = math.floor(two_lingering_cost/8 + (exchangeclone.get_item_energy("mcl_bows:arrow") or 14))
|
|
|
|
set_item_energy("mcl_potions:"..info.name.."_2_arrow", two_arrow_cost)
|
|
|
|
end
|
2023-04-14 20:44:18 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-11-08 03:00:09 +01:00
|
|
|
-- Wait until all mods are loaded (to make sure all nodes have been registered)
|
|
|
|
-- This is much easier than making it depend on every single mod.
|
2023-11-10 03:35:23 +01:00
|
|
|
-- Actually, I'm kind of surprised that override_item still works...
|
2023-03-27 19:36:54 +02:00
|
|
|
minetest.register_on_mods_loaded(function()
|
2023-11-19 01:48:35 +01:00
|
|
|
minetest.log("action", "ExchangeClone: Registering energy values")
|
2023-11-26 23:25:00 +01:00
|
|
|
<<<<<<< HEAD
|
2023-11-10 23:43:10 +01:00
|
|
|
local auto = {}
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-11-23 18:17:53 +01:00
|
|
|
-- Register group energy values
|
2023-11-03 00:33:30 +01:00
|
|
|
local groupnames = {}
|
|
|
|
for index, group in ipairs(exchangeclone.group_values) do
|
|
|
|
groupnames[#groupnames + 1] = group[1] --Get list of group names
|
|
|
|
end
|
|
|
|
local grouped_items = exchangeclone.get_group_items(groupnames, true, true)
|
|
|
|
for index, group in ipairs(exchangeclone.group_values) do
|
|
|
|
for i, item in pairs(grouped_items[group[1]]) do
|
|
|
|
set_item_energy(item, group[2])
|
2023-04-14 20:44:18 +02:00
|
|
|
end
|
2023-11-03 00:33:30 +01:00
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-11-23 18:17:53 +01:00
|
|
|
-- Register energy aliases
|
2023-11-10 23:43:10 +01:00
|
|
|
if exchangeclone.mcl then
|
2023-05-13 21:13:22 +02:00
|
|
|
for i = 0, 31 do
|
2023-11-19 01:48:35 +01:00
|
|
|
exchangeclone.register_energy_alias("mcl_compass:18", "mcl_compass:"..i)
|
2023-11-20 01:01:56 +01:00
|
|
|
exchangeclone.register_energy_alias("mcl_compass:18", "mcl_compass:"..i.."_lodestone")
|
2023-05-13 21:13:22 +02:00
|
|
|
end
|
|
|
|
for i = 0, 63 do
|
2023-11-19 01:48:35 +01:00
|
|
|
exchangeclone.register_energy_alias("mcl_clock:clock", "mcl_clock:clock_"..i)
|
2023-05-13 21:13:22 +02:00
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
exchangeclone.register_energy_alias("doc_identifier:identifier_solid", "doc_identifier:identifier_liquid")
|
2023-11-03 00:33:30 +01:00
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-11-10 23:43:10 +01:00
|
|
|
for itemstring, energy_value in pairs(exchangeclone.energy_values) do
|
|
|
|
set_item_energy(itemstring, energy_value)
|
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-11-23 18:17:53 +01:00
|
|
|
-- Should energy values be automatically registered?
|
2023-11-03 00:33:30 +01:00
|
|
|
for itemstring, def in pairs(minetest.registered_items) do
|
2023-11-10 03:35:23 +01:00
|
|
|
if def.exchangeclone_custom_energy then
|
|
|
|
set_item_energy(itemstring, def.exchangeclone_custom_energy)
|
|
|
|
else
|
|
|
|
local _, _, mod_name, item_name = itemstring:find("([%d_%l]+):([%d_%l]+)")
|
2023-11-10 23:43:10 +01:00
|
|
|
if (
|
2023-11-10 03:35:23 +01:00
|
|
|
def
|
|
|
|
and item_name
|
|
|
|
and mod_name
|
|
|
|
and def.description
|
|
|
|
and def.description ~= ""
|
2023-11-23 18:48:11 +01:00
|
|
|
-- Recovery compasses are annoying.
|
2023-11-19 01:48:35 +01:00
|
|
|
and ((minetest.get_item_group(itemstring, "not_in_creative_inventory") < 1) or (mod_name == "mcl_compass"))
|
|
|
|
and (not exchangeclone.get_item_energy(itemstring))
|
2023-11-26 23:25:00 +01:00
|
|
|
and exchangeclone.recipes[itemstring]
|
2023-11-10 03:35:23 +01:00
|
|
|
) then
|
2023-11-10 23:43:10 +01:00
|
|
|
auto[itemstring] = true
|
2023-03-27 19:36:54 +02:00
|
|
|
end
|
2023-04-14 20:44:18 +02:00
|
|
|
end
|
|
|
|
end
|
2023-11-26 23:25:00 +01:00
|
|
|
=======
|
|
|
|
>>>>>>> origin/MoreManualStuff
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-11-23 18:17:53 +01:00
|
|
|
-- Handle stonecutter recipes
|
|
|
|
if exchangeclone.mineclonia then
|
|
|
|
-- TODO: Check this for every Mineclonia update
|
|
|
|
local recipe_yield = { --maps itemgroup to the respective recipe yield, default is 1
|
|
|
|
["slab"] = 2,
|
|
|
|
}
|
|
|
|
for name, def in pairs(minetest.registered_items) do
|
|
|
|
if def._mcl_stonecutter_recipes then
|
|
|
|
local yield = 1
|
|
|
|
for k,v in pairs(recipe_yield) do if minetest.get_item_group(name,k) > 0 then yield = v end end
|
|
|
|
for _, result in pairs(def._mcl_stonecutter_recipes) do
|
|
|
|
if minetest.get_item_group(name,"not_in_creative_inventory") == 0 then
|
|
|
|
if not exchangeclone.recipes[result] then exchangeclone.recipes[result] = {} end
|
|
|
|
table.insert(exchangeclone.recipes[result],{output = name.." "..yield, type = "stonecutting", recipe = result})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-11-10 23:43:10 +01:00
|
|
|
local auto = {}
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-11-23 18:17:53 +01:00
|
|
|
-- Register group energy values
|
2023-11-03 00:33:30 +01:00
|
|
|
local groupnames = {}
|
2023-11-26 16:24:45 +01:00
|
|
|
for _, group in ipairs(exchangeclone.group_values) do
|
2023-11-03 00:33:30 +01:00
|
|
|
groupnames[#groupnames + 1] = group[1] --Get list of group names
|
|
|
|
end
|
|
|
|
local grouped_items = exchangeclone.get_group_items(groupnames, true, true)
|
2023-11-26 16:24:45 +01:00
|
|
|
for _, group in ipairs(exchangeclone.group_values) do
|
|
|
|
for _, item in pairs(grouped_items[group[1]]) do
|
|
|
|
item = exchangeclone.handle_alias(item)
|
2023-11-03 00:33:30 +01:00
|
|
|
set_item_energy(item, group[2])
|
2023-04-14 20:44:18 +02:00
|
|
|
end
|
2023-11-03 00:33:30 +01:00
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-11-25 00:51:46 +01:00
|
|
|
-- Register energy aliases and certain energy values
|
2023-11-10 23:43:10 +01:00
|
|
|
if exchangeclone.mcl then
|
2023-05-13 21:13:22 +02:00
|
|
|
for i = 0, 31 do
|
2023-11-19 01:48:35 +01:00
|
|
|
exchangeclone.register_energy_alias("mcl_compass:18", "mcl_compass:"..i)
|
2023-11-20 01:01:56 +01:00
|
|
|
exchangeclone.register_energy_alias("mcl_compass:18", "mcl_compass:"..i.."_lodestone")
|
2023-05-13 21:13:22 +02:00
|
|
|
end
|
|
|
|
for i = 0, 63 do
|
2023-11-19 01:48:35 +01:00
|
|
|
exchangeclone.register_energy_alias("mcl_clock:clock", "mcl_clock:clock_"..i)
|
2023-05-13 21:13:22 +02:00
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
exchangeclone.register_energy_alias("doc_identifier:identifier_solid", "doc_identifier:identifier_liquid")
|
2023-11-26 16:24:45 +01:00
|
|
|
exchangeclone.register_energy_alias("mcl_books:writable_book", "mcl_books:written_book")
|
2023-11-25 00:51:46 +01:00
|
|
|
|
|
|
|
for _, coral_type in ipairs({"brain", "bubble", "fire", "horn", "tube"}) do
|
|
|
|
for thing, value in pairs({[coral_type.."_coral"] = 16, [coral_type.."_coral_block"] = 64, [coral_type.."_coral_fan"] = 16}) do
|
|
|
|
set_item_energy("mcl_ocean:"..thing, value)
|
|
|
|
set_item_energy("mcl_ocean:dead_"..thing, value/16)
|
|
|
|
end
|
|
|
|
end
|
2023-11-03 00:33:30 +01:00
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-11-10 23:43:10 +01:00
|
|
|
for itemstring, energy_value in pairs(exchangeclone.energy_values) do
|
|
|
|
set_item_energy(itemstring, energy_value)
|
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-11-26 16:24:45 +01:00
|
|
|
if exchangeclone.mcl then
|
|
|
|
local cheapest = get_cheapest_recipe(exchangeclone.recipes["mcl_copper:block"])
|
|
|
|
if cheapest then
|
|
|
|
set_item_energy("mcl_copper:block", cheapest)
|
|
|
|
minetest.log(cheapest)
|
|
|
|
minetest.log(dump(exchangeclone.get_item_energy("mcl_copper:block")))
|
|
|
|
end
|
|
|
|
for _, state in ipairs({"exposed", "weathered", "oxidized"}) do
|
|
|
|
set_item_energy("mcl_copper:block_"..state, exchangeclone.get_item_energy("mcl_copper:block"))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2023-11-19 01:48:35 +01:00
|
|
|
-- handle aliases in exchangeclone.recipes
|
|
|
|
for itemstring, recipes in pairs(exchangeclone.recipes) do
|
2023-11-26 16:24:45 +01:00
|
|
|
local new_name = exchangeclone.handle_alias(itemstring)
|
2023-11-19 01:48:35 +01:00
|
|
|
if new_name ~= itemstring then
|
|
|
|
exchangeclone.recipes[new_name] = recipes
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-11-23 18:17:53 +01:00
|
|
|
-- Should energy values be automatically registered?
|
2023-11-03 00:33:30 +01:00
|
|
|
for itemstring, def in pairs(minetest.registered_items) do
|
2023-11-26 16:24:45 +01:00
|
|
|
itemstring = exchangeclone.handle_alias(itemstring) or itemstring
|
2023-11-10 03:35:23 +01:00
|
|
|
if def.exchangeclone_custom_energy then
|
|
|
|
set_item_energy(itemstring, def.exchangeclone_custom_energy)
|
|
|
|
else
|
|
|
|
local _, _, mod_name, item_name = itemstring:find("([%d_%l]+):([%d_%l]+)")
|
2023-11-10 23:43:10 +01:00
|
|
|
if (
|
2023-11-10 03:35:23 +01:00
|
|
|
def
|
|
|
|
and item_name
|
|
|
|
and mod_name
|
|
|
|
and def.description
|
|
|
|
and def.description ~= ""
|
2023-11-19 01:48:35 +01:00
|
|
|
-- I hate recovery compasses.
|
|
|
|
and ((minetest.get_item_group(itemstring, "not_in_creative_inventory") < 1) or (mod_name == "mcl_compass"))
|
|
|
|
and (not exchangeclone.get_item_energy(itemstring))
|
2023-11-26 16:24:45 +01:00
|
|
|
and exchangeclone.recipes[itemstring]
|
2023-11-10 03:35:23 +01:00
|
|
|
-- This does mean that other items in mcl_potions will be ignored unless explicitly specified,
|
|
|
|
-- and items that are in groups mentioned above.
|
|
|
|
) then
|
2023-11-10 23:43:10 +01:00
|
|
|
auto[itemstring] = true
|
2023-03-27 19:36:54 +02:00
|
|
|
end
|
2023-04-14 20:44:18 +02:00
|
|
|
end
|
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-11-10 23:43:10 +01:00
|
|
|
for i = 1, exchangeclone.num_passes do
|
2023-11-20 01:01:56 +01:00
|
|
|
minetest.log("action", "ExchangeClone: \tPASS #"..i)
|
2023-11-10 23:43:10 +01:00
|
|
|
if auto == {} then break end
|
|
|
|
for itemstring, _ in pairs(auto) do
|
2023-11-03 00:33:30 +01:00
|
|
|
local cheapest = get_cheapest_recipe(exchangeclone.recipes[itemstring])
|
|
|
|
if cheapest then
|
|
|
|
set_item_energy(itemstring, cheapest)
|
2023-11-10 23:43:10 +01:00
|
|
|
auto[itemstring] = nil
|
2023-11-03 00:33:30 +01:00
|
|
|
end
|
|
|
|
end
|
2021-08-27 00:22:54 +02:00
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
|
|
|
|
--minetest.log(dump(auto))
|
|
|
|
|
2023-11-08 03:00:09 +01:00
|
|
|
if exchangeclone.mcl then
|
2023-11-22 19:36:16 +01:00
|
|
|
exchangeclone.mcl_potion_data = exchangeclone.mcl_potion_data or {}
|
|
|
|
table.insert_all(exchangeclone.mcl_potion_data, { -- automatically assumes base cost is awkward potion if not specified
|
|
|
|
{name = "water", ingredient_cost = 0, custom_base_cost = 0, no_arrow = true},
|
|
|
|
{name = "awkward", ingredient_cost = 0, no_arrow = true},
|
|
|
|
{name = "fire_resistance", ingredient_cost = 768, plus = true},
|
|
|
|
{name = "poison", ingredient_cost = 128, plus = true, two = true},
|
|
|
|
{name = "harming", ingredient_cost = 192, custom_base_cost = 52, two = true},
|
|
|
|
{name = "healing", ingredient_cost = 1852, two = true},
|
|
|
|
{name = "leaping", ingredient_cost = 64, plus = true, two = true},
|
|
|
|
{name = "mundane", ingredient_cost = 32, no_arrow = true, custom_base_cost = 0},
|
|
|
|
{name = "night_vision", ingredient_cost = 1840, plus = true},
|
|
|
|
{name = "regeneration", ingredient_cost = 4096, plus = true, two = true},
|
|
|
|
{name = "slowness", ingredient_cost = 192, custom_base_cost = 20, plus = true, two = true},
|
|
|
|
{name = "swiftness", ingredient_cost = 32, plus = true, two = true},
|
|
|
|
{name = "thick", ingredient_cost = 384, no_arrow = true, custom_base_cost = 0},
|
|
|
|
{name = "water_breathing", ingredient_cost = 64, plus = true},
|
|
|
|
{name = "invisibility", ingredient_cost = 192, custom_base_cost = 623, plus = true},
|
|
|
|
{name = "withering", ingredient_cost = 128, plus = true, two = true}
|
|
|
|
})
|
2023-11-08 03:00:09 +01:00
|
|
|
for _, info in ipairs(exchangeclone.mcl_potion_data) do
|
|
|
|
add_potion_energy(info)
|
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
-- Concrete and banners/shields (don't remember why the shields don't work)
|
2023-11-26 16:24:45 +01:00
|
|
|
for _, color in ipairs({"red", "orange", "yellow", "lime", "dark_green", "cyan", "light_blue", "blue", "purple", "magenta", "pink", "black", "white", "silver", "grey", "brown"}) do
|
2023-11-10 23:43:10 +01:00
|
|
|
set_item_energy("mcl_colorblocks:concrete_"..color, exchangeclone.get_item_energy("mcl_colorblocks:concrete_powder_"..color) or 2)
|
2023-11-26 16:24:45 +01:00
|
|
|
set_item_energy("mcl_stairs:stair_concrete_"..color, get_cheapest_recipe(exchangeclone.recipes["mcl_stairs:stair_concrete_"..color]))
|
|
|
|
set_item_energy("mcl_stairs:slab_concrete_"..color, get_cheapest_recipe(exchangeclone.recipes["mcl_stairs:slab_concrete_"..color]))
|
2023-11-10 23:43:10 +01:00
|
|
|
set_item_energy("mcl_shields:shield_"..color, (exchangeclone.get_item_energy("mcl_banners:banner_item_"..color) or 340) + (exchangeclone.get_item_energy("mcl_shields:shield") or 304))
|
|
|
|
end
|
2023-11-26 16:24:45 +01:00
|
|
|
-- Enchanted/netherite tools
|
2023-11-19 01:48:35 +01:00
|
|
|
for name, def in pairs(minetest.registered_items) do
|
|
|
|
if def._mcl_enchanting_enchanted_tool then
|
|
|
|
exchangeclone.register_energy_alias(name, def._mcl_enchanting_enchanted_tool)
|
|
|
|
end
|
|
|
|
if def._mcl_upgrade_item then
|
|
|
|
if not name:find("enchanted") then
|
|
|
|
set_item_energy(def._mcl_upgrade_item, (exchangeclone.get_item_energy(name) or 0)+(exchangeclone.get_item_energy("mcl_nether:netherite_ingot") or 73728))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- Recovery compasses use a random compass frame for the crafting recipe... Incredibly irritating.
|
|
|
|
for i = 0, 31 do
|
|
|
|
if exchangeclone.get_item_energy("mcl_compass:"..i.."_recovery") then
|
|
|
|
for j = 0, 31 do
|
|
|
|
exchangeclone.register_energy_alias("mcl_compass:"..i.."_recovery", "mcl_compass:"..j.."_recovery")
|
|
|
|
end
|
|
|
|
break
|
2023-11-13 02:30:16 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-11-19 01:48:35 +01:00
|
|
|
-- Adds energy values to aliased items, even though they're not used (just so it's displayed)
|
|
|
|
for alias, itemstring in pairs(exchangeclone.energy_aliases) do
|
|
|
|
set_item_energy(alias, exchangeclone.get_item_energy(itemstring))
|
|
|
|
end
|
|
|
|
|
2023-11-03 00:33:30 +01:00
|
|
|
-- Free up memory (I assume this will do that?)
|
|
|
|
exchangeclone.recipes = nil
|
2023-11-10 23:43:10 +01:00
|
|
|
exchangeclone.energy_values = nil
|
2023-11-19 01:48:35 +01:00
|
|
|
minetest.log("action", "ExchangeClone: Done registering energy values.")
|
|
|
|
end)
|