Compare commits

...

2 Commits

Author SHA1 Message Date
ThePython c39ff263d9 Update readme 2023-12-20 17:14:04 -08:00
ThePython 0058a05069 Features complete! Time for testing... :( 2023-12-20 16:52:46 -08:00
20 changed files with 345 additions and 141 deletions

View File

@ -38,8 +38,10 @@ Dependencies: Minetest Game or MineClone.
## Known issues: ## Known issues:
* It is impossible to die from most things when wearing DM/RM armor in MineClon(e/ia)... There's some rounding thing that happens when the player has 1 health or something. I can't figur it out. * Dark/Red Matter armor don't work they way they should, especially in MTG. I would greatly appreciate a PR that makes them work more like ProjectE.
* The sword/katar AOE ability does not take upgrades into account. This will probably not be fixed (MCL)
* When machines are exploded, they (and the items inside) do not drop. I can't figure out why. * When machines are exploded, they (and the items inside) do not drop. I can't figure out why.
* For technical reasons (making them work with MCL hoppers), Exchange Orbs and Upgrades can be used as fuel. This isn't really a problem, but it will be removed once I decide the new hopper API is new enough that most people are using it.
* Dark/Red matter shears will sometimes (randomly) be treated as normal shears when used by MCL dispensers. This will not be fixed. * Dark/Red matter shears will sometimes (randomly) be treated as normal shears when used by MCL dispensers. This will not be fixed.
**If you have a suggestion or notice a bug, visit the [GitHub issues page](https://github.com/thepython10110/exchangeclone/issues).** **If you have a suggestion or notice a bug, visit the [GitHub issues page](https://github.com/thepython10110/exchangeclone/issues).**
@ -64,23 +66,20 @@ Dependencies: Minetest Game or MineClone.
### TODO: ### TODO:
* Figure out what's going to happen with Technic (the PR probably won't be merged) * Figure out what's going to happen with Technic (the PR probably won't be merged)
* Fix tools updating surrounding nodes * Test everything in MTG, MCL2, and MCLA (and 5.7)
* Code for covalence dust * Finish changelog
* Improve multidig * Finish wiki
* Add more Energy Collectors
* Fix MCL2 hoppers
\* Not actually added yet
### v6.0 (The Compatibility Update) ### v6.0 (The Compatibility Update)
**The biggest changes:** **The biggest changes:**
* I'm naming updates now for some reason. * I'm naming updates now for some reason.
* Automatic energy values! This means I don't have to manually add energy values for every single item. If it's craftable (and even if it's not in many cases), ExchangeClone will automatically figure out an energy value for it. * Automatic energy values! This means I don't have to manually add energy values for every single item. If it's craftable (and even if it's not in many cases), ExchangeClone will automatically figure out an energy value for it.
* The minimum Minetest version has been changed to 5.7.0, because I'm never going to test on any older versions. Of course, it will probably still work (at least mostly) on other versions, but I can't promise anything. * The minimum Minetest version has been changed to 5.7.0, because I'm never going to test on any older versions. Of course, it will probably still work (at least mostly) on other versions, but I can't promise anything.
* Players can now have up to 1 trillion personal energy! * Players can now have up to 1 trillion personal energy!
* Energy values now better match ProjectE's. * Energy values now better match ProjectE's.
* **The PESA will be removed in version 7.0.** * Changed A LOT of things internally. Any mods depending on ExchangeClone (probably not very many, which is good) will probably need to update stuff.
* **The PESA will be removed in version 7.0.**
**Full Changelog** **Full Changelog**
* New Features: * New Features:
@ -89,45 +88,43 @@ Dependencies: Minetest Game or MineClone.
* Technic recipe types (grinding, alloying, etc.) will also work, as long as their `output_size` is 1 (meaning they only output one item at a time, so not the centrifuge or separator). * Technic recipe types (grinding, alloying, etc.) will also work, as long as their `output_size` is 1 (meaning they only output one item at a time, so not the centrifuge or separator).
* Also supports Mineclonia's stonecutter recipes, Netherite upgrades, and more. * Also supports Mineclonia's stonecutter recipes, Netherite upgrades, and more.
* Added various ways of adding custom energy values or energy recipes (`exchangeclone.register_alias`, `exchangeclone.register_craft_type`, and `exchangeclone.register_craft`) * Added various ways of adding custom energy values or energy recipes (`exchangeclone.register_alias`, `exchangeclone.register_craft_type`, and `exchangeclone.register_craft`)
* Support for Pipeworks and Hopper mods! (MCL hoppers already worked)
* Added energy values for More Ores and Technic. * Added energy values for More Ores and Technic.
* Infinite food (costs 64 energy to use, but isn't consumed, equal to MCL steak) * Infinite food (costs 64 energy to use, but isn't consumed, equal to MCL steak)
* Alchemical Chests, Alchemical Bags, and Advanced Alchemical Chests * Alchemical Chests, Alchemical Bags, and Advanced Alchemical Chests
* Labels on items in the Transmutation GUI showing how many items can be created. * Labels on items in the Transmutation GUI showing how many items can be created.
* Added comma separators when energy is shown (to make it easier to identify large numbers) * Added comma separators when energy is shown (to make it easier to identify large numbers)
* Support for Pipeworks and Hopper mods! (MCL hoppers already worked) * Covalence Dust
* Covalence Dust (left-click with Philosopher's Stone to open repairing menu; only tools with an energy value can be repaired)\* * Left-click (or aux1-left-click in MCL) with Philosopher's Stone to open repairing menu; only tools with an energy value can be repaired)
* Mind, Life, Body, and Soul Stones (although MTG only has the soul stone).\*
* 5 more Energy Collectors (to go with the increased energy limit) * 5 more Energy Collectors (to go with the increased energy limit)
* Chat commands to set/add/remove energy from a player (requires `privs` privilege): * Chat commands to set/add/remove energy from a player (requires `privs` privilege):
* `/add_player_energy [player] value` (player defaults to self, value can be negative) * `/add_player_energy [player] value` (player defaults to self, value can be negative)
* `/set_player_energy [player] value` (player defaults to self) * `/set_player_energy [player] value` (player defaults to self, value can be "limit" to set to the limit)
* Changes: * Changes:
* Energy values are now in `zzzz_exchangeclone_init/base_energy_values.lua`, and are laid out differently, and aliases now work.
* ExchangeClone is now a modpack for [annoying reasons](https://forum.minetest.net/viewtopic.php?f=47&p=429775s). * ExchangeClone is now a modpack for [annoying reasons](https://forum.minetest.net/viewtopic.php?f=47&p=429775s).
* Energy values are now in `zzzz_exchangeclone_init/base_energy_values.lua`, and are laid out differently, and aliases now work.
* The default energy value is no longer 1 but none. * The default energy value is no longer 1 but none.
* The 2.14-billion-ish personal energy limit is has been increased to 1,000,000,000,000 (1 trillion). Any higher (literally ANY higher) and there are precision-based exploits like being able to create an unlimited amount of anything with an energy value less than 1. I considered finding some library for arbitrary precision in Lua, but decided it was too much work (and nobody really needs more than a trillion energy anyway). * The 2.14-billion-ish personal energy limit is has been increased to 1,000,000,000,000 (1 trillion). Any higher (literally ANY higher) and there are precision-based exploits like being able to create an unlimited amount of anything with an energy value less than 1. I considered finding some library for arbitrary precision in Lua, but decided it was too much work (and nobody really needs more than a trillion energy anyway).
* MineClon(e2/ia) energy values now (mostly) match ProjectE's, with a few minor differences. * Energy values are now multiples of 0.05 instead of 0.25, for no real reason.
* MineClon(e2/ia) energy values now (mostly) match ProjectE's, with a few minor differences, including these:
* Emeralds are still worth less than diamonds because of villager trades (in my opinion, this should be changed in ProjectE as well) * Emeralds are still worth less than diamonds because of villager trades (in my opinion, this should be changed in ProjectE as well)
* Bamboo is worth less so things make more sense.
* Dyes are worth different amounts based on their crafting recipes, so different colors of things are worth different amounts. * Dyes are worth different amounts based on their crafting recipes, so different colors of things are worth different amounts.
* Since fractional energy values are allowed, some energy values may be slightly different. * Since fractional energy values are allowed, some energy values may be slightly different.
* Energy values are now multiples of 0.05 instead of 0.25, for no real reason.
* Tools that break multiple nodes at once (hammers, hoes, katar, and morningstar) use a better method that may (?) slightly decrease lag.\*
* A couple changes involving the Philosopher's Stone: * A couple changes involving the Philosopher's Stone:
* Ender pearls can now be crafted with 4 iron and the Philosopher's Stone (MCL). * Ender pearls can now be crafted with 4 iron and the Philosopher's Stone (MCL).
* Copper's energy value has been changed (128 instead of 85), and the recipe has been changed accordingly. * Copper's energy value has been changed (128 instead of 85), and the recipe has been changed accordingly.
* Ice and obsidian can now be transmuted into water and lava, respectively. * Ice and obsidian can now be transmuted into water and lava, respectively.
* It is now impossible to transmute between bedrock and barriers (MCL). I thought it was funny originally, but now I'm realizing that I don't want this to be annoying to people who run servers (are there any servers with this mod?) * It is now impossible to transmute between bedrock and barriers (MCL). I thought it was funny originally, but now I'm realizing that I don't want this to be annoying to people who run servers (are there any servers with this mod?)
* It now costs 4 dark/red matter to make a block, which is great news if you already have some (because they're now worth more), but not so great if you don't. Sorry and you're welcome. * It now costs 4 dark/red matter to make a block, which is great news if you already have some (because they're now worth more), but not so great if you don't. Sorry or you're welcome.
* Tool abilities now have no energy cost (to match ProjectE). * Tool abilities now have no energy cost (to match ProjectE).
* Tool abilities now take upgrades into account (silk touch, fortune, etc.) except for the sword AOE ability (which would require more irritating hacky workarounds). * Tool abilities now take upgrades into account (silk touch, fortune, etc.) except for the sword AOE ability (which would require irritating hacky workarounds).
* Several neutral mobs (endermen, spiders, piglins) are now affected by the dark/red matter sword in "slay all" mode, to match ProjectE. * Several neutral mobs (endermen, spiders, piglins) are now affected by the dark/red matter sword in "slay hostile" mode, to match ProjectE.
* Bugfixes: * Bugfixes:
* Fixed potion energy values * Fixed potion energy values (MCL)
* Fixed Red Matter Shield recipe * Fixed Red Matter Shield recipe (MTG)
* Fixed other modes of DM/RM tools not having energy values * Fixed other modes of DM/RM tools not having energy values
* Deconstructors and Constructors now use node timers again (but better than before), meaning they won't ever stop. (Previously, they would stop if there was too much energy to deconstruct or too little energy to construct.) * Deconstructors and Constructors will now continue trying to work instead of just stopping when there is too much or too little energy.
* Tool abilities now update nodes that require support (torches, sand, etc.)\*. * Tool abilities now update nodes that require support (torches, sand, etc.).
* MCL raw copper, iron, and gold blocks now correctly double in DM/RM furnaces. * MCL raw copper, iron, and gold blocks now correctly double in DM/RM furnaces.
### v5.4 ### v5.4

View File

@ -29,7 +29,7 @@ local function alchemical_on_construct(color)
return function(pos) return function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", alchemical_formspec(color)) meta:set_string("formspec", alchemical_formspec(color))
meta:set_string("infotext", color.." Alchemical Chest") meta:set_string("infotext", color.." Advanced Alchemical Chest")
end end
end end

View File

@ -2,13 +2,14 @@ local S = minetest.get_translator()
-- true = blocks all damage -- true = blocks all damage
-- {base_block, block_per_rm}: Amount blocked by full dark matter, extra amount per red matter armor piece -- {base_block, block_per_rm}: Amount blocked by full dark matter, extra amount per red matter armor piece
-- only applies in MCL
local blocked_damage_types = { local blocked_damage_types = {
drown = true, drown = true,
lava = true, lava = true,
in_fire = true, in_fire = true,
on_fire = true, on_fire = true,
hot_floor = true, hot_floor = true,
fall = {0.9, 0.0125}, fall = {0.8, exchangeclone.mcl and 0.025 or 0.02},
} }
local function get_armor_texture(type, matter, preview) local function get_armor_texture(type, matter, preview)
@ -49,7 +50,7 @@ if exchangeclone.mcl then
mcl_armor.register_set({ mcl_armor.register_set({
name = "dark_matter", name = "dark_matter",
description = "Dark Matter", description = "Dark Matter",
descriptions = exchangeclone.mineclonia and { descriptions = exchangeclone.mcla and {
head = S("Dark Matter Helmet"), head = S("Dark Matter Helmet"),
torso = S("Dark Matter Chestplate"), torso = S("Dark Matter Chestplate"),
legs = S("Dark Matter Leggings"), legs = S("Dark Matter Leggings"),
@ -77,7 +78,7 @@ if exchangeclone.mcl then
mcl_armor.register_set({ mcl_armor.register_set({
name = "red_matter", name = "red_matter",
description = "Red Matter", description = "Red Matter",
descriptions = exchangeclone.mineclonia and { descriptions = exchangeclone.mcla and {
head = S("Red Matter Helmet"), head = S("Red Matter Helmet"),
torso = S("Red Matter Chestplate"), torso = S("Red Matter Chestplate"),
legs = S("Red Matter Leggings"), legs = S("Red Matter Leggings"),
@ -103,8 +104,8 @@ if exchangeclone.mcl then
cook_material = "exchangeclone:dark_matter", cook_material = "exchangeclone:dark_matter",
}) })
for _, matter in ipairs({"dark", "red"}) do for _, matter in pairs({"dark", "red"}) do
for _, type in ipairs({"helmet", "chestplate", "leggings", "boots"}) do for _, type in pairs({"helmet", "chestplate", "leggings", "boots"}) do
minetest.override_item("exchangeclone:"..type.."_"..matter.."_matter", { minetest.override_item("exchangeclone:"..type.."_"..matter.."_matter", {
inventory_image = get_armor_texture("inv_"..type, matter), inventory_image = get_armor_texture("inv_"..type, matter),
wield_image = get_armor_texture("inv_"..type, matter), wield_image = get_armor_texture("inv_"..type, matter),

View File

@ -155,7 +155,7 @@ minetest.register_node("exchangeclone:constructor", {
"exchangeclone_constructor_right.png", "exchangeclone_constructor_right.png",
"exchangeclone_constructor_right.png" "exchangeclone_constructor_right.png"
}, },
groups = {cracky = 2, container = 4, pickaxey = 2, tubedevice = 1, tubedevice_receiver = 1}, groups = {cracky = 2, container = exchangeclone.mcl2 and 2 or 4, pickaxey = 2, tubedevice = 1, tubedevice_receiver = 1},
_mcl_hardness = 3, _mcl_hardness = 3,
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
sounds = exchangeclone.sound_mod.node_sound_metal_defaults(), sounds = exchangeclone.sound_mod.node_sound_metal_defaults(),
@ -167,7 +167,7 @@ minetest.register_node("exchangeclone:constructor", {
local meta2 = meta:to_table() local meta2 = meta:to_table()
meta:from_table(oldmetadata) meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _, listname in ipairs({"src", "dst", "fuel"}) do for _, listname in pairs({"src", "dst", "fuel"}) do
local stack = inv:get_stack(listname, 1) local stack = inv:get_stack(listname, 1)
if not stack:is_empty() then if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
@ -195,6 +195,11 @@ minetest.register_node("exchangeclone:constructor", {
allow_metadata_inventory_move = allow_metadata_inventory_move, allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take, allow_metadata_inventory_take = allow_metadata_inventory_take,
on_timer = constructor_action, on_timer = constructor_action,
_mcl_hoppers_on_try_pull = exchangeclone.hoppers_on_try_pull,
_mcl_hoppers_on_try_push = exchangeclone.hoppers_on_try_push,
_mcl_hoppers_on_after_push = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
}) })
if exchangeclone.pipeworks then if exchangeclone.pipeworks then

View File

@ -1,20 +1,43 @@
local S = minetest.get_translator() local S = minetest.get_translator()
exchangeclone.tool_types = exchangeclone.tool_types or {}
for group, amount in pairs({
pickaxe = 3,
pick = 3,
sword = 2,
axe = 3,
shovel = 1,
hoe = 2,
hammer = 2,
shears = 2,
helmet = 5,
chestplate = 8,
leggings = 7,
boots = 4,
shield = exchangeclone.mcl and 1 or 7,
}) do
exchangeclone.tool_types[group] = exchangeclone.tool_types[group] or amount
end
local charcoal_itemstring = exchangeclone.mcl and "mcl_core:charcoal_lump" or "group:tree" local charcoal_itemstring = exchangeclone.mcl and "mcl_core:charcoal_lump" or "group:tree"
minetest.register_craftitem("exchangeclone:low_covalence_dust", { minetest.register_craftitem("exchangeclone:low_covalence_dust", {
description = S("Low Covalence Dust"), description = S("Low Covalence Dust"),
groups = {covalence_dust = 1},
inventory_image = "exchangeclone_dust.png^[colorize:#00ff00:128", inventory_image = "exchangeclone_dust.png^[colorize:#00ff00:128",
wield_image = "exchangeclone_dust.png^[colorize:#00ff00:128", wield_image = "exchangeclone_dust.png^[colorize:#00ff00:128",
}) })
minetest.register_craftitem("exchangeclone:medium_covalence_dust", { minetest.register_craftitem("exchangeclone:medium_covalence_dust", {
description = S("Medium Covalence Dust"), description = S("Medium Covalence Dust"),
groups = {covalence_dust = 2},
inventory_image = "exchangeclone_dust.png^[colorize:#00ffff:128", inventory_image = "exchangeclone_dust.png^[colorize:#00ffff:128",
wield_image = "exchangeclone_dust.png^[colorize:#00ffff:128", wield_image = "exchangeclone_dust.png^[colorize:#00ffff:128",
}) })
minetest.register_craftitem("exchangeclone:high_covalence_dust", { minetest.register_craftitem("exchangeclone:high_covalence_dust", {
description = S("High Covalence Dust"), description = S("High Covalence Dust"),
groups = {covalence_dust = 3},
inventory_image = "exchangeclone_dust.png^[colorize:#0000ff:128", inventory_image = "exchangeclone_dust.png^[colorize:#0000ff:128",
wield_image = "exchangeclone_dust.png^[colorize:#0000ff:128", wield_image = "exchangeclone_dust.png^[colorize:#0000ff:128",
}) })
@ -50,3 +73,77 @@ minetest.register_craft({
exchangeclone.itemstrings.diamond, exchangeclone.itemstrings.coal exchangeclone.itemstrings.diamond, exchangeclone.itemstrings.coal
} }
}) })
local listnames = {exchangeclone_covalence_dust = true, exchangeclone_covalence_gear = true, exchangeclone_covalence_output = true}
local function is_repairable_gear(item)
item = ItemStack(item)
if item:get_wear() <= 0 then return end
if (exchangeclone.get_item_energy(item) or 0) <= 0 then return end
local result = 0
for group, amount in pairs(exchangeclone.tool_types) do
if minetest.get_item_group(item:get_name(), group) > 0 then
result = result + amount
end
end
return (result > 0) and result
end
-- Doesn't even get to repairable_gear function
minetest.register_allow_player_inventory_action(function(player, action, inventory, info)
if action == "take" and listnames[info.listname] then
return info.stack:get_count()
elseif action == "move" and listnames[info.to_list] then
if info.to_list == "exchangeclone_covalence_output" then
return 0
elseif info.to_list == "exchangeclone_covalence_gear" then
local stack = inventory:get_stack(info.from_list, info.from_index)
return is_repairable_gear(stack) and info.count or 0
elseif info.to_list == "exchangeclone_covalence_dust" then
local stack = inventory:get_stack(info.from_list, info.from_index)
return (minetest.get_item_group(stack:get_name(), "covalence_dust") > 0) and info.count or 0
end
elseif action == "put" and listnames[info.listname] then
if info.listname == "exchangeclone_covalence_output" then
return 0
elseif info.listname == "exchangeclone_covalence_gear" then
return is_repairable_gear(info.stack) and info.stack:get_count() or 0
elseif info.listname == "exchangeclone_covalence_dust" then
return (minetest.get_item_group(info.stack:get_name(), "covalence_dust") > 0) and info.stack:get_count() or 0
end
end
end)
-- I'm aware that this does not account for tools that can stack, but that's just because I don't think that's even possible.
minetest.register_on_player_inventory_action(function(player, action, inventory, info)
if ((action == "take" or action == "put") and listnames[info.listname])
or (action == "move" and (listnames[info.to_list] or listnames[info.from_list])) then
local gear_stack = inventory:get_stack("exchangeclone_covalence_gear", 1)
local dust_stack = inventory:get_stack("exchangeclone_covalence_dust", 1)
if gear_stack:is_empty() or dust_stack:is_empty() then return end
if not inventory:room_for_item("exchangeclone_covalence_output", gear_stack) then return end
local amount = is_repairable_gear(gear_stack)
local energy_value = exchangeclone.get_item_energy(gear_stack)
local tier = 3
if energy_value/amount < 50 then
tier = 1
elseif energy_value/amount < 6000 then
tier = 2
end
if minetest.get_item_group(dust_stack:get_name(), "covalence_dust") >= tier and dust_stack:get_count() >= amount then
local new_stack = ItemStack(gear_stack)
new_stack:set_wear(0)
inventory:add_item("exchangeclone_covalence_output", new_stack)
inventory:set_stack("exchangeclone_covalence_gear", 1, ItemStack(""))
dust_stack:set_count(dust_stack:get_count() - amount)
inventory:set_stack("exchangeclone_covalence_dust", 1, dust_stack)
end
end
end)
minetest.register_on_joinplayer(function(player, time_since_whatever)
for listname, _ in pairs(listnames) do
player:get_inventory():set_size(listname, 1)
end
end)

View File

@ -57,8 +57,8 @@ local function deconstructor_action(pos, elapsed)
local individual_energy_value = exchangeclone.get_item_energy(stack:get_name()) local individual_energy_value = exchangeclone.get_item_energy(stack:get_name())
if not (individual_energy_value and individual_energy_value > 0) then return end if not (individual_energy_value and individual_energy_value > 0) then return end
local wear = stack:get_wear() local wear = stack:get_wear()
if wear and wear > 1 then if wear and wear > 0 then
individual_energy_value = math.floor(individual_energy_value * (65536 / wear)) individual_energy_value = math.max(math.floor(individual_energy_value * (65536 / wear)), 1)
end end
if stack:get_name() == "exchangeclone:exchange_orb" then if stack:get_name() == "exchangeclone:exchange_orb" then
individual_energy_value = individual_energy_value + exchangeclone.get_orb_itemstack_energy(stack) individual_energy_value = individual_energy_value + exchangeclone.get_orb_itemstack_energy(stack)
@ -167,7 +167,7 @@ minetest.register_node("exchangeclone:deconstructor", {
local meta2 = meta:to_table() local meta2 = meta:to_table()
meta:from_table(oldmetadata) meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _, listname in ipairs({"src", "fuel"}) do for _, listname in pairs({"src", "fuel"}) do
local stack = inv:get_stack(listname, 1) local stack = inv:get_stack(listname, 1)
if not stack:is_empty() then if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
@ -198,6 +198,11 @@ minetest.register_node("exchangeclone:deconstructor", {
allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move, allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take, allow_metadata_inventory_take = allow_metadata_inventory_take,
_mcl_hoppers_on_try_pull = exchangeclone.hoppers_on_try_pull,
_mcl_hoppers_on_try_push = exchangeclone.hoppers_on_try_push,
_mcl_hoppers_on_after_push = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
}) })
if exchangeclone.pipeworks then if exchangeclone.pipeworks then

View File

@ -24,7 +24,7 @@ minetest.register_lbm({
local function check_for_furnaces(pos, set_furnace, start) local function check_for_furnaces(pos, set_furnace, start)
local found = false local found = false
for _, check_pos in ipairs(exchangeclone.neighbors) do for _, check_pos in pairs(exchangeclone.neighbors) do
local new_pos = vector.add(pos, check_pos) local new_pos = vector.add(pos, check_pos)
local node = minetest.get_node(new_pos) local node = minetest.get_node(new_pos)
local furnace = minetest.get_item_group(node.name, "exchangeclone_furnace") local furnace = minetest.get_item_group(node.name, "exchangeclone_furnace")
@ -221,7 +221,6 @@ function exchangeclone.register_energy_collector(itemstring, name, amount, modif
input_inventory = "main", input_inventory = "main",
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}, connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1},
insert_object = function(pos, node, stack, direction) insert_object = function(pos, node, stack, direction)
minetest.log(dump(direction))
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:add_item("main", stack) return inv:add_item("main", stack)
@ -270,7 +269,7 @@ exchangeclone.register_energy_collector("exchangeclone:energy_collector_mk3", S(
} }
) )
exchangeclone.register_energy_collector("exchangeclone:energy_collector_mk4", S("Energy Collector MK4"), 160, "^[multiply:#777700", { exchangeclone.register_energy_collector("exchangeclone:energy_collector_mk4", S("Energy Collector MK4"), 160, "^[multiply:#aa7700", {
{iron_block, iron_block, iron_block}, {iron_block, iron_block, iron_block},
{"exchangeclone:energy_collector_mk3", "exchangeclone:energy_collector_mk3", "exchangeclone:energy_collector_mk3"}, {"exchangeclone:energy_collector_mk3", "exchangeclone:energy_collector_mk3", "exchangeclone:energy_collector_mk3"},
{iron_block, iron_block, iron_block} {iron_block, iron_block, iron_block}

View File

@ -514,7 +514,7 @@ local inactive_def = {
"exchangeclone_dark_matter_furnace.png", "exchangeclone_dark_matter_furnace.png",
}, },
paramtype2 = "4dir", paramtype2 = "4dir",
groups = {pickaxey=5, cracky = 3, container=4, material_stone=1, level = get_level(4), exchangeclone_furnace = 1, tubedevice = 1, tubedevice_receiver = 1}, groups = {pickaxey=5, cracky = 3, container = exchangeclone.mcl2 and 2 or 4, material_stone=1, level = get_level(4), exchangeclone_furnace = 1, tubedevice = 1, tubedevice_receiver = 1},
is_ground_content = false, is_ground_content = false,
sounds = exchangeclone.sound_mod.node_sound_stone_defaults(), sounds = exchangeclone.sound_mod.node_sound_stone_defaults(),
@ -524,7 +524,7 @@ local inactive_def = {
local meta2 = meta:to_table() local meta2 = meta:to_table()
meta:from_table(oldmetadata) meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _, listname in ipairs({"src", "dst", "fuel"}) do for _, listname in pairs({"src", "dst", "fuel"}) do
if listname == "src" or listname == "dst" then if listname == "src" or listname == "dst" then
for i = 1,7 do for i = 1,7 do
local stack = inv:get_stack(listname, i) local stack = inv:get_stack(listname, i)
@ -591,7 +591,12 @@ local inactive_def = {
_mcl_blast_resistance = 1500, _mcl_blast_resistance = 1500,
_mcl_hardness = 75, _mcl_hardness = 75,
on_rotate = on_rotate, on_rotate = on_rotate,
after_place_node = exchangeclone.pipeworks and pipeworks.after_place after_place_node = exchangeclone.pipeworks and pipeworks.after_place,
_mcl_hoppers_on_try_pull = exchangeclone.hoppers_on_try_pull,
_mcl_hoppers_on_try_push = exchangeclone.hoppers_on_try_push,
_mcl_hoppers_on_after_push = function(pos)
minetest.get_node_timer(pos):start(0.45)
end,
} }
local active_def = { local active_def = {
@ -608,7 +613,7 @@ local active_def = {
parammatter_type = "light", parammatter_type = "light",
light_source = LIGHT_ACTIVE_FURNACE, light_source = LIGHT_ACTIVE_FURNACE,
drop = "exchangeclone:dark_matter_furnace", drop = "exchangeclone:dark_matter_furnace",
groups = {pickaxey=5, not_in_creative_inventory = 1, container = 4, material_stone=1, cracky = 3, level = get_level(4), exchangeclone_furnace = 1, tubedevice = 1, tubedevice_receiver = 1}, groups = {pickaxey=5, not_in_creative_inventory = 1, container = exchangeclone.mcl2 and 2 or 4, material_stone=1, cracky = 3, level = get_level(4), exchangeclone_furnace = 1, tubedevice = 1, tubedevice_receiver = 1},
is_ground_content = false, is_ground_content = false,
sounds = exchangeclone.sound_mod.node_sound_stone_defaults(), sounds = exchangeclone.sound_mod.node_sound_stone_defaults(),
on_timer = furnace_node_timer, on_timer = furnace_node_timer,
@ -618,7 +623,7 @@ local active_def = {
local meta2 = meta:to_table() local meta2 = meta:to_table()
meta:from_table(oldmetadata) meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _, listname in ipairs({"src", "dst", "fuel"}) do for _, listname in pairs({"src", "dst", "fuel"}) do
if listname == "src" or listname == "dst" then if listname == "src" or listname == "dst" then
for i = 1,7 do for i = 1,7 do
local stack = inv:get_stack(listname, i) local stack = inv:get_stack(listname, i)
@ -661,7 +666,9 @@ local active_def = {
_mcl_hardness = 75, _mcl_hardness = 75,
on_rotate = on_rotate, on_rotate = on_rotate,
after_rotate = after_rotate_active, after_rotate = after_rotate_active,
after_place_node = exchangeclone.pipeworks and pipeworks.after_place after_place_node = exchangeclone.pipeworks and pipeworks.after_place,
_mcl_hoppers_on_try_pull = exchangeclone.hoppers_on_try_pull,
_mcl_hoppers_on_try_push = exchangeclone.hoppers_on_try_push,
} }
if exchangeclone.pipeworks then if exchangeclone.pipeworks then
@ -706,7 +713,7 @@ minetest.override_item("exchangeclone:red_matter_furnace", {
"exchangeclone_red_matter_block.png", "exchangeclone_red_matter_block.png",
"exchangeclone_red_matter_furnace.png", "exchangeclone_red_matter_furnace.png",
}, },
groups = {pickaxey=5, cracky = 3, container=4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2, tubedevice = 1, tubedevice_receiver = 1}, groups = {pickaxey=5, cracky = 3, container = exchangeclone.mcl2 and 2 or 4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2, tubedevice = 1, tubedevice_receiver = 1},
_mcl_hardness = 100, _mcl_hardness = 100,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
@ -746,7 +753,7 @@ minetest.override_item("exchangeclone:red_matter_furnace", {
local meta2 = meta:to_table() local meta2 = meta:to_table()
meta:from_table(oldmetadata) meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _, listname in ipairs({"src", "dst", "fuel"}) do for _, listname in pairs({"src", "dst", "fuel"}) do
if listname == "src" or listname == "dst" then if listname == "src" or listname == "dst" then
for i = 1,10 do for i = 1,10 do
local stack = inv:get_stack(listname, i) local stack = inv:get_stack(listname, i)
@ -768,6 +775,11 @@ minetest.override_item("exchangeclone:red_matter_furnace", {
pipeworks.after_dig(pos) pipeworks.after_dig(pos)
end end
end, end,
_mcl_hoppers_on_try_pull = exchangeclone.hoppers_on_try_pull,
_mcl_hoppers_on_try_push = exchangeclone.hoppers_on_try_push,
_mcl_hoppers_on_after_push = function(pos)
minetest.get_node_timer(pos):start(0.16)
end,
}) })
@ -782,7 +794,7 @@ minetest.override_item("exchangeclone:red_matter_furnace_active", {
"exchangeclone_red_matter_furnace.png", "exchangeclone_red_matter_furnace.png",
}, },
drop = "exchangeclone:red_matter_furnace", drop = "exchangeclone:red_matter_furnace",
groups = {pickaxey=5, not_in_creative_inventory = 1, cracky = 3, container=4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2, tubedevice = 1, tubedevice_receiver = 1}, groups = {pickaxey=5, not_in_creative_inventory = 1, cracky = 3, container = exchangeclone.mcl2 and 2 or 4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2, tubedevice = 1, tubedevice_receiver = 1},
_mcl_hardness = 100, _mcl_hardness = 100,
on_construct = function(pos) on_construct = function(pos)
@ -799,7 +811,7 @@ minetest.override_item("exchangeclone:red_matter_furnace_active", {
local meta2 = meta:to_table() local meta2 = meta:to_table()
meta:from_table(oldmetadata) meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _, listname in ipairs({"src", "dst", "fuel"}) do for _, listname in pairs({"src", "dst", "fuel"}) do
if listname == "src" or listname == "dst" then if listname == "src" or listname == "dst" then
for i = 1,10 do for i = 1,10 do
local stack = inv:get_stack(listname, i) local stack = inv:get_stack(listname, i)

View File

@ -1,5 +1,8 @@
local S = minetest.get_translator() local S = minetest.get_translator()
local stamina_exists = minetest.get_modpath("stamina")
local stamina_max = minetest.settings:get("stamina.visual_max") or 20
local function infinite_food_function(itemstack, player, pointed_thing) local function infinite_food_function(itemstack, player, pointed_thing)
local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing)
local original = ItemStack(itemstack) local original = ItemStack(itemstack)
@ -8,7 +11,13 @@ local function infinite_food_function(itemstack, player, pointed_thing)
end end
local player_energy = exchangeclone.get_player_energy(player) local player_energy = exchangeclone.get_player_energy(player)
if player_energy >= 64 then if player_energy >= 64 then
local hunger_restore = minetest.item_eat(8, original) if stamina_exists and stamina.get_saturation(player) >= stamina_max then
return nil
elseif not exchangeclone.mcl and player:get_hp() >= player:get_properties().hp_max then
return nil
end
-- no idea why this is different between games but it works
local hunger_restore = minetest.item_eat(8, exchangeclone.mcl and ItemStack("") or original)
hunger_restore(itemstack, player, pointed_thing) hunger_restore(itemstack, player, pointed_thing)
end end
return nil return nil

View File

@ -2,7 +2,8 @@ if not exchangeclone then
error("Disable and re-enable the ExchangeClone modpack.") error("Disable and re-enable the ExchangeClone modpack.")
end end
minetest.log("action", "ExchangeClone: Registering own stuff") local start_time = minetest.get_us_time()
minetest.log("action", "[ExchangeClone] Registering own stuff")
-- Decides what mod to use for sounds -- Decides what mod to use for sounds
exchangeclone.sound_mod = exchangeclone.mcl and mcl_sounds or default exchangeclone.sound_mod = exchangeclone.mcl and mcl_sounds or default
@ -135,12 +136,11 @@ dofile(modpath.."/alchemical_chests.lua")
dofile(modpath.."/transmutation_table.lua") dofile(modpath.."/transmutation_table.lua")
dofile(modpath.."/furnaces.lua") dofile(modpath.."/furnaces.lua")
minetest.log("action", "ExchangeClone: Done.")
minetest.register_on_mods_loaded(function() minetest.register_on_mods_loaded(function()
local start_time = minetest.get_us_time() local energy_start_time = minetest.get_us_time()
minetest.log("action", "ExchangeClone: Registering energy values") minetest.log("action", "[ExchangeClone] Registering energy values")
dofile(modpath.."/register_energy.lua") dofile(modpath.."/register_energy.lua")
local total_time = minetest.get_us_time() - start_time minetest.log("action", "[ExchangeClone] Done registering energy values ("..((minetest.get_us_time() - energy_start_time)/1000000).." seconds)")
minetest.log("action", "ExchangeClone: Done registering energy values ("..(total_time/1000000).." seconds)")
end) end)
minetest.log("action", "[ExchangeClone] Done ("..((minetest.get_us_time() - start_time)/1000).." milliseconds)")

View File

@ -6,7 +6,7 @@ local dirt_group = exchangeclone.mcl and "shovely" or "crumbly"
local function dig_if_group(pos, player, groups) local function dig_if_group(pos, player, groups)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
for _, group in ipairs(groups) do for _, group in pairs(groups) do
if minetest.get_item_group(node.name, group) > 0 then if minetest.get_item_group(node.name, group) > 0 then
minetest.node_dig(pos, minetest.get_node(pos), player) minetest.node_dig(pos, minetest.get_node(pos), player)
end end

View File

@ -9,6 +9,33 @@ local function show_enchanting(player)
mcl_enchanting.show_enchanting_formspec(player) mcl_enchanting.show_enchanting_formspec(player)
end end
local width = (exchangeclone.mcl and 9) or 8
local repairing_formspec =
"size["..tostring(width)..", 7]"..
"label[0.5,0.5;Repairing]"..
"label["..tostring(width/3-0.5)..",0.5;Covalence Dust]"..
"list[current_player;exchangeclone_covalence_dust;"..tostring(width/3-0.5)..",1;1,1]"..
"label["..tostring(width/2-0.5)..",0.5;Gear]"..
"list[current_player;exchangeclone_covalence_gear;"..tostring(width/2-0.5)..",1;1,1]"..
"label["..tostring(2*width/3-0.5)..",0.5;Output]"..
"list[current_player;exchangeclone_covalence_output;"..tostring(2*width/3-0.5)..",1;1,1]"..
exchangeclone.inventory_formspec(0,2.75)..
"listring[current_player;main]"..
"listring[context;src]"..
"listring[current_player;main]"..
"listring[context;fuel]"..
"listring[current_player;main]"..
"listring[context;dst]"..
"listring[current_player;main]"
if exchangeclone.mcl then
repairing_formspec = repairing_formspec..
mcl_formspec.get_itemslot_bg(width/3-0.5,1,1,1)..
mcl_formspec.get_itemslot_bg(width/2-0.5,1,1,1)..
mcl_formspec.get_itemslot_bg(2*width/3-0.5,1,1,1)
end
exchangeclone.node_transmutations = { exchangeclone.node_transmutations = {
{ --use { --use
["mcl_core:stone"] = "mcl_core:cobble", ["mcl_core:stone"] = "mcl_core:cobble",
@ -18,10 +45,8 @@ exchangeclone.node_transmutations = {
["mcl_core:sand"] = "mcl_core:dirt_with_grass", ["mcl_core:sand"] = "mcl_core:dirt_with_grass",
["mcl_core:podzol"] = "mcl_core:redsand", ["mcl_core:podzol"] = "mcl_core:redsand",
["mcl_core:redsand"] = "mcl_core:podzol", ["mcl_core:redsand"] = "mcl_core:podzol",
["mcl_flowers:tallgrass"] = "mcl_core:deadbush", ["mcl_flowers:tallgrass"] = "mcl_flowers:fern",
["mcl_nether:netherrack"] = "mcl_core:cobble", ["mcl_flowers:fern"] = "mcl_flowers:tallgrass",
["mcl_core:gravel"] = "mcl_core:sandstone",
["mcl_core:sandstone"] = "mcl_core:gravel",
["mcl_core:redsandstone"] = "mcl_core:gravel", ["mcl_core:redsandstone"] = "mcl_core:gravel",
["mcl_farming:pumpkin"] = "mcl_farming:melon", ["mcl_farming:pumpkin"] = "mcl_farming:melon",
["mcl_farming:melon"] = "mcl_farming:pumpkin", ["mcl_farming:melon"] = "mcl_farming:pumpkin",
@ -61,7 +86,7 @@ exchangeclone.node_transmutations = {
["mcl_core:glass"] = "mcl_core:sand", ["mcl_core:glass"] = "mcl_core:sand",
["mcl_blackstone:blackstone"] = "mcl_blackstone:basalt", ["mcl_blackstone:blackstone"] = "mcl_blackstone:basalt",
["mcl_blackstone:basalt"] = "mcl_blackstone:blackstone", ["mcl_blackstone:basalt"] = "mcl_blackstone:blackstone",
["mcl_flowers:double_grass"] = "mcl_core:deadbush", ["mcl_flowers:double_grass"] = "mcl_flowers:fern",
--["mcl_flowers:double_grass_top"] = "air", --["mcl_flowers:double_grass_top"] = "air",
["mcl_core:andesite"] = "mcl_core:diorite", ["mcl_core:andesite"] = "mcl_core:diorite",
["mcl_core:diorite"] = "mcl_core:granite", ["mcl_core:diorite"] = "mcl_core:granite",
@ -238,13 +263,17 @@ if exchangeclone.mcl then
if player:get_player_control().sneak then if player:get_player_control().sneak then
show_enchanting(player) show_enchanting(player)
else else
--[[if player:get_player_control().aux1 then if player:get_player_control().aux1 then
minetest.show_formspec(player:get_player_name(), "exchangeclone_smelting", smelting_formspec) minetest.show_formspec(player:get_player_name(), "exchangeclone_repairing", repairing_formspec)
else --]] else
mcl_crafting_table.show_crafting_form(player) mcl_crafting_table.show_crafting_form(player)
--end end
end end
end end
else
on_left_click = function(itemstack, player, pointed_thing)
minetest.show_formspec(player:get_player_name(), "exchangeclone_repairing", repairing_formspec)
end
end end
local function on_right_click(itemstack, player, pointed_thing) local function on_right_click(itemstack, player, pointed_thing)

View File

@ -1,17 +1,16 @@
local S = minetest.get_translator() local S = minetest.get_translator()
function exchangeclone.mine_vein(player, start_pos, node_name, pos, depth) function exchangeclone.mine_vein(player, start_pos, node_name, pos, depth)
-- Not very efficient, but it works. -- Not the most efficient, but it works.
if not player then return end if not player then return end
if not start_pos then return end if not start_pos then return end
if not pos then pos = start_pos end pos = pos or start_pos
depth = depth or 0 depth = depth or 0
--minetest.log(dump(pos))
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if not node_name then node_name = node.name end if not node_name then node_name = node.name end
local distance = vector.distance(pos, start_pos)
if node_name == node.name then if node_name == node.name then
exchangeclone.drop_items_on_player(pos, minetest.get_node_drops(node.name, "exchangeclone:red_matter_pickaxe"), player) exchangeclone.drop_items_on_player(pos, minetest.get_node_drops(node.name, "exchangeclone:red_matter_pickaxe"), player)
exchangeclone.check_nearby_falling(pos)
minetest.set_node(pos, {name = "air"}) minetest.set_node(pos, {name = "air"})
for x = pos.x-1,pos.x+1 do for y = pos.y-1,pos.y+1 do for z = pos.z-1,pos.z+1 do for x = pos.x-1,pos.x+1 do for y = pos.y-1,pos.y+1 do for z = pos.z-1,pos.z+1 do
if depth <= 10 then if depth <= 10 then
@ -75,23 +74,6 @@ local function pickaxe_on_use(itemstack, player, pointed_thing)
end end
end end
for name, def in pairs(minetest.registered_nodes) do
if name:find("_ore")
or name:find("stone_with")
or name:find("deepslate_with")
or name:find("diorite_with")
or name:find("andesite_with")
or name:find("granite_with")
or name:find("tuff_with")
or name:find("mineral_")
or (name == "mcl_blackstone:nether_gold")
or (name == "mcl_nether:ancient_debris") then
local groups = table.copy(def.groups)
groups.exchangeclone_ore = 1
minetest.override_item(name, {groups = groups})
end
end
local pick_def = { local pick_def = {
description = S("Dark Matter Pickaxe").."\n"..S("Single node mode"), description = S("Dark Matter Pickaxe").."\n"..S("Single node mode"),
wield_image = "exchangeclone_dark_matter_pickaxe.png", wield_image = "exchangeclone_dark_matter_pickaxe.png",
@ -178,3 +160,22 @@ minetest.register_craft({
{"", "exchangeclone:dark_matter", ""} {"", "exchangeclone:dark_matter", ""}
} }
}) })
minetest.register_on_mods_loaded(function()
for name, def in pairs(minetest.registered_nodes) do
if name:find("_ore")
or name:find("stone_with")
or name:find("deepslate_with")
or name:find("diorite_with")
or name:find("andesite_with")
or name:find("granite_with")
or name:find("tuff_with")
or name:find("mineral_")
or (name == "mcl_blackstone:nether_gold")
or (name == "mcl_nether:ancient_debris") then
local groups = table.copy(def.groups)
groups.exchangeclone_ore = 1
minetest.override_item(name, {groups = groups})
end
end
end)

View File

@ -6,21 +6,21 @@ local function get_cheapest_recipe(itemstring, log)
local recipes = exchangeclone.recipes[itemstring] local recipes = exchangeclone.recipes[itemstring]
if not recipes then return end if not recipes then return end
local cheapest local cheapest
for _, recipe in ipairs(recipes) do for _, recipe in pairs(recipes) do
local ingredient_cost = 0 local ingredient_cost = 0
local output_count = ItemStack(recipe.output):get_count() local output_count = ItemStack(recipe.output):get_count()
local skip = false local skip = false
local identical_replacements = {} local identical_replacements = {}
if recipe.replacements then if recipe.replacements then
for _, replacement in ipairs(recipe.replacements) do for _, replacement in pairs(recipe.replacements) do
if replacement[1] == replacement[2] then if replacement[1] == replacement[2] then
identical_replacements[replacement[1]] = (identical_replacements[replacement[1]] or 0) + 1 identical_replacements[replacement[1]] = (identical_replacements[replacement[1]] or 0) + 1
end end
end end
end end
if not recipe.type or exchangeclone.craft_types[recipe.type].type == "shaped" then if not recipe.type or exchangeclone.craft_types[recipe.type].type == "shaped" then
for _, row in ipairs(recipe.recipe) do for _, row in pairs(recipe.recipe) do
for _, item in ipairs(row) do for _, item in pairs(row) do
if item ~= "" then if item ~= "" then
if item == itemstring then if item == itemstring then
output_count = math.max(0, output_count - 1) output_count = math.max(0, output_count - 1)
@ -41,7 +41,7 @@ local function get_cheapest_recipe(itemstring, log)
end end
end end
elseif exchangeclone.craft_types[recipe.type].type == "shapeless" then elseif exchangeclone.craft_types[recipe.type].type == "shapeless" then
for _, item in ipairs(recipe.recipe) do for _, item in pairs(recipe.recipe) do
if item ~= "" then if item ~= "" then
if item == itemstring then if item == itemstring then
output_count = math.max(0, output_count - 1) output_count = math.max(0, output_count - 1)
@ -83,7 +83,7 @@ local function get_cheapest_recipe(itemstring, log)
ingredient_cost = recipe.recipe ingredient_cost = recipe.recipe
end end
if recipe.replacements and not skip then if recipe.replacements and not skip then
for _, item in ipairs(recipe.replacements) do for _, item in pairs(recipe.replacements) do
if item[1] ~= item[2] then if item[1] ~= item[2] then
local cost = exchangeclone.get_item_energy(item[2]) local cost = exchangeclone.get_item_energy(item[2])
if (not cost) or cost == 0 then if (not cost) or cost == 0 then
@ -157,7 +157,7 @@ for index, group in ipairs(exchangeclone.group_values) do
end end
-- Handle stonecutter recipes and decaychains in Mineclonia -- Handle stonecutter recipes and decaychains in Mineclonia
if exchangeclone.mineclonia then if exchangeclone.mcla then
exchangeclone.register_craft_type("stonecutting", "cooking") exchangeclone.register_craft_type("stonecutting", "cooking")
-- TODO: Check recipe_yield for every Mineclonia update -- TODO: Check recipe_yield for every Mineclonia update
local recipe_yield = { --maps itemgroup to the respective recipe yield, default is 1 local recipe_yield = { --maps itemgroup to the respective recipe yield, default is 1
@ -206,7 +206,7 @@ if exchangeclone.mcl then
exchangeclone.register_alias("doc_identifier:identifier_solid", "doc_identifier:identifier_liquid") exchangeclone.register_alias("doc_identifier:identifier_solid", "doc_identifier:identifier_liquid")
exchangeclone.register_alias("mcl_books:writable_book", "mcl_books:written_book") exchangeclone.register_alias("mcl_books:writable_book", "mcl_books:written_book")
for _, coral_type in ipairs({"brain", "bubble", "fire", "horn", "tube"}) do for _, coral_type in pairs({"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 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:"..thing, value)
set_item_energy("mcl_ocean:dead_"..thing, value/16) set_item_energy("mcl_ocean:dead_"..thing, value/16)
@ -217,7 +217,7 @@ if exchangeclone.mcl then
exchangeclone.register_craft_type("brewing", "shapeless") exchangeclone.register_craft_type("brewing", "shapeless")
local function add_potion_recipe(info) local function add_potion_recipe(info)
if not info.bases then info.bases = {"mcl_potions:awkward"} end if not info.bases then info.bases = {"mcl_potions:awkward"} end
for _, base in ipairs(info.bases) do for _, base in pairs(info.bases) do
local ingredient = info.ingredient local ingredient = info.ingredient
local normal = "mcl_potions:"..info.name local normal = "mcl_potions:"..info.name
local splash = normal.."_splash" local splash = normal.."_splash"
@ -237,7 +237,7 @@ if exchangeclone.mcl then
end end
end end
end end
for _, info in ipairs(exchangeclone.mcl_potion_data) do for _, info in pairs(exchangeclone.mcl_potion_data) do
add_potion_recipe(info) add_potion_recipe(info)
end end
@ -256,7 +256,7 @@ if exchangeclone.mcl then
exchangeclone.register_craft_type("hardening", "cooking") exchangeclone.register_craft_type("hardening", "cooking")
-- Concrete and banners/shields (don't remember why the shields don't work) -- Concrete and banners/shields (don't remember why the shields don't work)
for _, color in ipairs({"red", "orange", "yellow", "lime", "dark_green", "cyan", "light_blue", "blue", "purple", "magenta", "pink", "black", "white", "silver", "grey", "brown"}) do for color, color_data in pairs(exchangeclone.colors) do
exchangeclone.register_craft({output = "mcl_colorblocks:concrete_"..color, type = "hardening", recipe = "mcl_colorblocks:concrete_powder_"..color}) exchangeclone.register_craft({output = "mcl_colorblocks:concrete_"..color, type = "hardening", recipe = "mcl_colorblocks:concrete_powder_"..color})
exchangeclone.register_craft({output = "mcl_shields:shield_"..color, type = "shapeless", recipe = {"mcl_banners:banner_item_"..color, "mcl_shields:shield"}}) exchangeclone.register_craft({output = "mcl_shields:shield_"..color, type = "shapeless", recipe = {"mcl_banners:banner_item_"..color, "mcl_shields:shield"}})
end end
@ -280,7 +280,7 @@ if exchangeclone.mcl then
end end
-- Register copper block/stonecutting energy recipes in MineClone2 -- Register copper block/stonecutting energy recipes in MineClone2
if exchangeclone.mcl and not exchangeclone.mineclonia then if exchangeclone.mcl2 then
exchangeclone.register_craft_type("oxidation", "cooking") exchangeclone.register_craft_type("oxidation", "cooking")
local cheapest = get_cheapest_recipe("mcl_copper:block") local cheapest = get_cheapest_recipe("mcl_copper:block")
if cheapest then if cheapest then
@ -347,7 +347,7 @@ local same = false
local i = 1 local i = 1
-- Automatically register energy values -- Automatically register energy values
while not same do while not same do
minetest.log("action", "ExchangeClone: \tIteration #"..i) minetest.log("action", "[ExchangeClone] \tIteration #"..i)
if auto == {} then break end if auto == {} then break end
if old_auto then if old_auto then
same = true same = true
@ -359,7 +359,7 @@ while not same do
end end
end end
if same then if same then
minetest.log("action", "ExchangeClone:\tNo change, stopping.") minetest.log("action", "[ExchangeClone]\tNo change, stopping.")
break break
end end
old_auto = table.copy(auto) old_auto = table.copy(auto)
@ -373,8 +373,6 @@ while not same do
i = i + 1 i = i + 1
end end
--minetest.log(dump(auto))
if exchangeclone.mcl then if exchangeclone.mcl then
set_item_energy("mcl_campfires:campfire", exchangeclone.get_item_energy("mcl_campfires:campfire_lit")) set_item_energy("mcl_campfires:campfire", exchangeclone.get_item_energy("mcl_campfires:campfire_lit"))
set_item_energy("mcl_campfires:soul_campfire", exchangeclone.get_item_energy("mcl_campfires:soul_campfire_lit")) set_item_energy("mcl_campfires:soul_campfire", exchangeclone.get_item_energy("mcl_campfires:soul_campfire_lit"))

View File

@ -238,7 +238,7 @@ minetest.registered_entities["mobs_mc:mooshroom"].on_rightclick = function(self,
end end
local old_honey_harvest = minetest.registered_items["mcl_beehives:bee_nest_5"].on_rightclick local old_honey_harvest = minetest.registered_items["mcl_beehives:bee_nest_5"].on_rightclick
for _, itemstring in ipairs({"mcl_beehives:bee_nest_5", "mcl_beehives:beehive_5"}) do for _, itemstring in pairs({"mcl_beehives:bee_nest_5", "mcl_beehives:beehive_5"}) do
minetest.registered_items[itemstring].on_rightclick = function(pos, node, player, itemstack, pointed_thing) minetest.registered_items[itemstring].on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local held_name = player:get_wielded_item():get_name() local held_name = player:get_wielded_item():get_name()
local shears = special_shears[held_name] local shears = special_shears[held_name]
@ -384,7 +384,7 @@ local new_dispenser_function = function(pos, node)
old_dispenser_function(pos, node) old_dispenser_function(pos, node)
end end
for _, itemstring in ipairs({"mcl_dispensers:dispenser", "mcl_dispensers:dispenser_up", "mcl_dispensers:dispenser_down"}) do for _, itemstring in pairs({"mcl_dispensers:dispenser", "mcl_dispensers:dispenser_up", "mcl_dispensers:dispenser_down"}) do
minetest.registered_items[itemstring].mesecons.effector.action_on = new_dispenser_function minetest.registered_items[itemstring].mesecons.effector.action_on = new_dispenser_function
end end

View File

@ -5,7 +5,7 @@ local upgrader_formspec =
"label[0.5,0.5;Upgrader]".. "label[0.5,0.5;Upgrader]"..
"label["..tostring(width/3-0.5)..",0.5;Upgrade]".. "label["..tostring(width/3-0.5)..",0.5;Upgrade]"..
"list[context;fuel;"..tostring(width/3-0.5)..",1;1,1]".. "list[context;fuel;"..tostring(width/3-0.5)..",1;1,1]"..
"label["..tostring(width/2-0.5)..",0.5;Tool/Armor]".. "label["..tostring(width/2-0.5)..",0.5;Gear]"..
"list[context;src;"..tostring(width/2-0.5)..",1;1,1]".. "list[context;src;"..tostring(width/2-0.5)..",1;1,1]"..
"label["..tostring(2*width/3-0.5)..",0.5;Output]".. "label["..tostring(2*width/3-0.5)..",0.5;Output]"..
"list[context;dst;"..tostring(2*width/3-0.5)..",1;1,1]".. "list[context;dst;"..tostring(2*width/3-0.5)..",1;1,1]"..
@ -134,7 +134,7 @@ local after_dig_node = function(pos, oldnode, oldmetadata, player)
local meta2 = meta:to_table() local meta2 = meta:to_table()
meta:from_table(oldmetadata) meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _, listname in ipairs({"fuel", "dst", "src"}) do for _, listname in pairs({"fuel", "dst", "src"}) do
local stack = inv:get_stack(listname, 1) local stack = inv:get_stack(listname, 1)
if not stack:is_empty() then if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
@ -185,7 +185,7 @@ minetest.register_node("exchangeclone:upgrader", {
meta:set_string("infotext", "Upgrader") meta:set_string("infotext", "Upgrader")
meta:set_string("formspec", upgrader_formspec) meta:set_string("formspec", upgrader_formspec)
end, end,
groups = {pickaxey=5, material_stone=1, cracky = 3, container = 4, level = get_level(4), tubedevice = 1, tubedevice_receiver = 1}, groups = {pickaxey=5, material_stone=1, cracky = 3, container = exchangeclone.mcl2 and 2 or 4, level = get_level(4), tubedevice = 1, tubedevice_receiver = 1},
allow_metadata_inventory_move = allow_metadata_inventory_move, allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take, allow_metadata_inventory_take = allow_metadata_inventory_take,
allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_put = allow_metadata_inventory_put,

View File

@ -137,7 +137,7 @@ local function handle_inventory(player, inventory, to_list)
if not individual_energy_value or individual_energy_value <= 0 then return end if not individual_energy_value or individual_energy_value <= 0 then return end
local wear = stack:get_wear() local wear = stack:get_wear()
if wear and wear > 1 then if wear and wear > 1 then
individual_energy_value = math.floor(individual_energy_value * (65536 / wear)) individual_energy_value = math.max(math.floor(individual_energy_value * (65536 / wear)), 1)
end end
if itemstring == "exchangeclone:exchange_orb" then if itemstring == "exchangeclone:exchange_orb" then
individual_energy_value = individual_energy_value + exchangeclone.get_orb_itemstack_energy(stack) individual_energy_value = individual_energy_value + exchangeclone.get_orb_itemstack_energy(stack)

View File

@ -62,8 +62,7 @@ if exchangeclone.mcl then
["mcl_core:cobble"] = 1, ["mcl_core:cobble"] = 1,
["mcl_core:cobweb"] = 12, ["mcl_core:cobweb"] = 12,
["mcl_core:crying_obsidian"] = 768, ["mcl_core:crying_obsidian"] = 768,
["mcl_core:dead_bush"] = 1, -- don't know which one of these is right; maybe both? ["mcl_core:deadbush"] = 8,
["mcl_core:deadbush"] = 1, --MCLA
["mcl_core:diamond"] = 8192, ["mcl_core:diamond"] = 8192,
["mcl_core:diorite"] = 16, ["mcl_core:diorite"] = 16,
["mcl_core:dirt"] = 1, ["mcl_core:dirt"] = 1,

View File

@ -6,7 +6,8 @@ else
exchangeclone.mcl = minetest.get_modpath("mcl_core") exchangeclone.mcl = minetest.get_modpath("mcl_core")
end end
exchangeclone.mineclonia = minetest.get_game_info().id == "mineclonia" -- if exchangeclone.mineclonia, exchangeclone.mcl is also defined. exchangeclone.mcla = minetest.get_game_info().id == "mineclonia" -- if exchangeclone.mcla, exchangeclone.mcl is also defined.
exchangeclone.mcl2 = minetest.get_game_info().id == "mineclone2"
exchangeclone.pipeworks = minetest.get_modpath("pipeworks") exchangeclone.pipeworks = minetest.get_modpath("pipeworks")
exchangeclone.orb_max = minetest.settings:get("exchangeclone.orb_max") or 51200000 -- Max capacity of Klein Star Omega in ProjectE exchangeclone.orb_max = minetest.settings:get("exchangeclone.orb_max") or 51200000 -- Max capacity of Klein Star Omega in ProjectE
exchangeclone.keep_data = minetest.settings:get_bool("exchangeclone.keep_data", false) exchangeclone.keep_data = minetest.settings:get_bool("exchangeclone.keep_data", false)
@ -22,12 +23,12 @@ function minetest.register_craft(data, ...)
-- Skip thousands of banner recipes in MCL2 -- Skip thousands of banner recipes in MCL2
-- This does mean that if other banner recipes exist that don't use wool (or carpet), -- This does mean that if other banner recipes exist that don't use wool (or carpet),
-- they will be ignored in MCL2... but I can't think of a better way to do this. -- they will be ignored in MCL2... but I can't think of a better way to do this.
if exchangeclone.mcl and not exchangeclone.mineclonia then if exchangeclone.mcl then
if itemstring:sub(1, #"mcl_banners:") == "mcl_banners:" then if itemstring:sub(1, #"mcl_banners:") == "mcl_banners:" then
allowed = false allowed = false
if data.type and data.type == "shaped" then if data.type and data.type == "shaped" then
for _, row in ipairs(data.recipe) do for _, row in pairs(data.recipe) do
for _, item in ipairs(row) do for _, item in pairs(row) do
if item:sub(1, #"mcl_wool:") == "mcl_wool:" then if item:sub(1, #"mcl_wool:") == "mcl_wool:" then
allowed = true allowed = true
break break

View File

@ -2,7 +2,7 @@
local S = minetest.get_translator() local S = minetest.get_translator()
-- Rounds to the nearest integer --- Rounds to the nearest integer
function exchangeclone.round(num) function exchangeclone.round(num)
if num % 1 < 0.5 then if num % 1 < 0.5 then
return math.floor(num) return math.floor(num)
@ -11,12 +11,12 @@ function exchangeclone.round(num)
end end
end end
-- Don't think this even works correctly. --- Adds all items in a certain list to a table.
function exchangeclone.get_inventory_drops(pos, inventory, drops) function exchangeclone.get_inventory_drops(pos, listname, drops)
local inv = minetest.get_meta(pos):get_inventory() local inv = minetest.get_meta(pos):get_inventory()
local n = #drops local n = #drops
for i = 1, inv:get_size(inventory) do for i = 1, inv:get_size(listname) do
local stack = inv:get_stack(inventory, i) local stack = inv:get_stack(listname, i)
if stack:get_count() > 0 then if stack:get_count() > 0 then
drops[n+1] = stack:to_table() drops[n+1] = stack:to_table()
n = n + 1 n = n + 1
@ -24,19 +24,19 @@ function exchangeclone.get_inventory_drops(pos, inventory, drops)
end end
end end
-- Gets the energy value of an itemstring or ItemStack --- Gets the energy value of an itemstring or ItemStack
-- Handles "group:foo" syntax (although it goes through every item) --- Handles "group:group_name" syntax (although it goes through every item), returns cheapest item in group
function exchangeclone.get_item_energy(item) function exchangeclone.get_item_energy(item, ignore_wear)
if (item == "") or not item then return end if (item == "") or not item then return end
-- handle groups -- handle groups
if type(item) == "string" and item:sub(1,6) == "group:" and exchangeclone.group_values then if type(item) == "string" and item:sub(1,6) == "group:" and exchangeclone.group_values then
local item_group = item:sub(7,-1) local item_group = item:sub(7,-1)
for _, group in ipairs(exchangeclone.group_values) do for _, group in pairs(exchangeclone.group_values) do
if item_group == group[1] then return group[2] end if item_group == group[1] then return group[2] end
end end
local group_items = exchangeclone.get_group_items(item_group) local group_items = exchangeclone.get_group_items(item_group)
local cheapest local cheapest
for _, group_item in ipairs(group_items[item_group]) do for _, group_item in pairs(group_items[item_group]) do
if group_item then if group_item then
local energy_value = exchangeclone.get_item_energy(group_item) local energy_value = exchangeclone.get_item_energy(group_item)
if energy_value then if energy_value then
@ -245,7 +245,7 @@ function exchangeclone.get_group_items(groups, allow_duplicates, include_no_grou
local grp = groups[i] local grp = groups[i]
local subgroups = exchangeclone.split(grp, ",") local subgroups = exchangeclone.split(grp, ",")
local success = true local success = true
for _, subgroup in ipairs(subgroups) do for _, subgroup in pairs(subgroups) do
if not def.groups[subgroup] then if not def.groups[subgroup] then
success = false success = false
break break
@ -415,7 +415,7 @@ function exchangeclone.drop_items_on_player(pos, drops, player) -- modified from
if player and player:is_player() and minetest.is_creative_enabled(player:get_player_name()) then if player and player:is_player() and minetest.is_creative_enabled(player:get_player_name()) then
local inv = player:get_inventory() local inv = player:get_inventory()
if inv then if inv then
for _, item in ipairs(drops) do for _, item in pairs(drops) do
if not inv:contains_item("main", item, true) then if not inv:contains_item("main", item, true) then
inv:add_item("main", item) inv:add_item("main", item)
end end
@ -495,7 +495,7 @@ local enchantments = tool and mcl_enchanting.get_enchantments(tool)
end end
end end
for _, item in ipairs(drops) do for _, item in pairs(drops) do
local count local count
if type(item) == "string" then if type(item) == "string" then
count = ItemStack(item):get_count() count = ItemStack(item):get_count()
@ -669,7 +669,7 @@ exchangeclone.neighbors = {
} }
function exchangeclone.check_nearby_falling(pos) function exchangeclone.check_nearby_falling(pos)
for i=1, #exchangeclone.neighbors do for i = 1, 6 do
local new_pos = vector.add(pos, exchangeclone.neighbors[i]) local new_pos = vector.add(pos, exchangeclone.neighbors[i])
if exchangeclone.mcl then if exchangeclone.mcl then
local node = minetest.get_node(new_pos) local node = minetest.get_node(new_pos)
@ -677,15 +677,15 @@ function exchangeclone.check_nearby_falling(pos)
mcl_core.check_vines_supported(new_pos, node) mcl_core.check_vines_supported(new_pos, node)
end end
end end
minetest.check_single_for_falling(new_pos)
end end
minetest.check_for_falling(pos)
end end
function exchangeclone.remove_nodes(positions) function exchangeclone.remove_nodes(positions)
for _, pos in ipairs(positions) do minetest.bulk_set_node(positions, {name = "air"})
for _, pos in pairs(positions) do
exchangeclone.check_nearby_falling(pos) exchangeclone.check_nearby_falling(pos)
end end
minetest.bulk_set_node(positions, {name = "air"})
end end
--[[ --[[
@ -732,3 +732,54 @@ function exchangeclone.register_craft(data)
end end
end end
end end
-- Returns true if item (itemstring or ItemStack) can be used as a furnace fuel.
-- Returns false otherwise
function exchangeclone.is_fuel(item)
return minetest.get_craft_result({method = "fuel", width = 1, items = {item}}).time ~= 0
end
-- Returns true if item (itemstring or ItemStack) can't be used as a furnace fuel.
-- Returns false otherwise
function exchangeclone.isnt_fuel(item)
return not (minetest.get_craft_result({method = "fuel", width = 1, items = {item}}).time ~= 0)
end
--- Selects item stack to transfer from
--- @param src_inventory InvRef Source innentory to pull from
--- @param src_list string Name of source inventory list to pull from
--- @param dst_inventory InvRef Destination inventory to push to
--- @param dst_list string Name of destination inventory list to push to
--- @param condition? fun(stack: ItemStack) Condition which items are allowed to be transfered.
--- @return integer Item stack number to be transfered
function exchangeclone.select_stack(src_inventory, src_list, dst_inventory, dst_list, condition)
local src_size = src_inventory:get_size(src_list)
local stack
for i = 1, src_size do
stack = src_inventory:get_stack(src_list, i)
if not stack:is_empty() and dst_inventory:room_for_item(dst_list, stack) and ((condition == nil or condition(stack))) then
return i
end
end
return nil
end
function exchangeclone.hoppers_on_try_pull(pos, hop_pos, hop_inv, hop_list)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if exchangeclone.select_stack(inv, "dst", hop_inv, hop_list) then
return inv, "dst", exchangeclone.select_stack(inv, "dst", hop_inv, hop_list)
else
return inv, "fuel", exchangeclone.select_stack(inv, "fuel", hop_inv, hop_list, exchangeclone.isnt_fuel)
end
end
function exchangeclone.hoppers_on_try_push(pos, hop_pos, hop_inv, hop_list)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if math.abs(pos.y - hop_pos.y) > math.abs(pos.x - hop_pos.x) and math.abs(pos.y - hop_pos.y) > math.abs(pos.z - hop_pos.z) then
return inv, "src", exchangeclone.select_stack(hop_inv, hop_list, inv, "src")
else
return inv, "fuel", exchangeclone.select_stack(hop_inv, hop_list, inv, "fuel", exchangeclone.is_fuel)
end
end