diff --git a/README.md b/README.md index f9a7ec4..2bfe7af 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ All energy values are in `energy.lua`. You can also change the speed at which th ## New features added by ThePython10110 * Support for MineClone -* Better energy values (originally, you could convert a single diamond into a diamond block... incredibly OP). +* COMPLETELY redone energy values (originally, you could convert a single diamond into a diamond block... incredibly OP). * Shift-clicking works (`listring`s) * Fixed a bug where items could be placed in the output slot of the Element Constructor * Added the ability to add energy values by group @@ -33,15 +33,14 @@ All energy values are in `energy.lua`. You can also change the speed at which th * Aux1-left-click to open enchanting table (MineClone only) * Aux1-right-click to open crafting table (MineClone only) * Ability to exchange charcoal/coal/iron/copper/tin/gold/mese/emerald/diamond by crafting (the Philosopher's Stone is always returned) - * Alchemical Coal, Mobius Fuel, and Aeternalis Fuel - * Dark Matter Orbs, Blocks, and tools - * Red Matter Orbs and Blocks -I don't actually own MineCraft, meaning I don't know how the original mod (Equivalent Exchange) works. I will probably make some minor mistakes, since all I have to go on is the internet. +* Alchemical Coal, Mobius Fuel, and Aeternalis Fuel +* Dark and Red Matter Orbs, Blocks, and tools +I don't actually own MineCraft, meaning I don't know exactly how the original mod (Equivalent Exchange) works. I will probably make some minor mistakes, since all I have to go on is the internet. ## Known issues: * When items are inserted into the Energy Collector, Deconstructor, or Constructor with MineClone hoppers, it does not trigger the machines to start. * When machines are exploded, they (and the items inside) do not drop. -* Dark Matter Shears will sometimes be treated as +* Dark/Red matter shears will sometimes be treated as normal shears. If you have a suggestion or notice a bug, visit the [GitHub issues page](https://github.com/thepython10110/exchangeclone/issues). diff --git a/axes.lua b/axes.lua new file mode 100644 index 0000000..b181bc2 --- /dev/null +++ b/axes.lua @@ -0,0 +1,154 @@ +local axe_break_cube = function(player, center, distance, strip) + exchangeclone.play_ability_sound(player) + local player_pos = player:get_pos() + local player_energy = exchangeclone.get_player_energy(player) + local energy_cost = 0 + local pos = center + pos.x = exchangeclone.round(pos.x) + pos.y = math.floor(pos.y) --make sure y is node BELOW player's feet + pos.z = exchangeclone.round(pos.z) + + for x = pos.x-distance, pos.x+distance do + if energy_cost + 8 > player_energy then + break + end + for y = pos.y-distance, pos.y+distance do + if energy_cost + 8 > player_energy then + break + end + for z = pos.z-distance, pos.z+distance do + if energy_cost + 8 > player_energy then + break + end + local new_pos = {x=x,y=y,z=z} + local node = minetest.get_node(new_pos) or {name="air"} + local node_def = minetest.registered_items[node.name] + if (node_def.groups.tree or node_def.groups.leaves) then + if minetest.is_protected(new_pos, player:get_player_name()) then + minetest.record_protection_violation(new_pos, player:get_player_name()) + else + energy_cost = energy_cost + 8 + if strip then + if node_def._mcl_stripped_variant ~= nil then + minetest.swap_node(new_pos, {name=node_def._mcl_stripped_variant, param2=node.param2}) + end + else + local drops = minetest.get_node_drops(node.name, "exchangeclone:red_matter_axe") + exchangeclone.drop_items_on_player(new_pos, drops, player) + minetest.set_node(new_pos, {name = "air"}) + end + end + end + end + end + end + exchangeclone.set_player_energy(player, player_energy - energy_cost) +end + +local function axe_on_place(itemstack, player, pointed_thing) + local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) + if click_test ~= false then + return click_test + end + + if player:get_player_control().aux1 then + if itemstack:get_name():find("dark") then + return exchangeclone.range_update(itemstack, player, 3) + else + return exchangeclone.range_update(itemstack, player, 4) + end + end + + local range = itemstack:get_meta():get_int("exchangeclone_item_range") + + if pointed_thing.type == "node" then + local node = minetest.get_node(pointed_thing.under) + local node_def = minetest.registered_nodes[node.name] + + if range == 0 then + if node_def._mcl_stripped_variant ~= nil then + minetest.swap_node(pointed_thing.under, {name=node_def._mcl_stripped_variant, param2=node.param2}) + return itemstack + end + end + end + + local center = player:get_pos() + if pointed_thing.type == "node" then + center = pointed_thing.under + end + if player:get_player_control().sneak and exchangeclone.mineclone then + axe_break_cube(player, center, range, true) -- strip when holding shift + else + axe_break_cube(player, center, range) + end + return itemstack +end + +minetest.register_tool("exchangeclone:dark_matter_axe", { + description = "Dark Matter Axe", + wield_image = "exchangeclone_dark_matter_axe.png", + inventory_image = "exchangeclone_dark_matter_axe.png", + groups = { tool=1, axe=1, dig_speed_class=7, enchantability=0 }, + wield_scale = exchangeclone.wield_scale, + tool_capabilities = { + -- 1/1.2 + full_punch_interval = 0.5, + max_drop_level=5, + damage_groups = {fleshy=16}, + punch_attack_uses = 0, + groupcaps={ + choppy = {times={[1]=1.5, [2]=0.75, [3]=0.38}, uses=0, maxlevel=4}, + }, + }, + sound = { breaks = "default_tool_breaks" }, + on_place = axe_on_place, + on_secondary_use = axe_on_place, + _mcl_toollike_wield = true, + _mcl_diggroups = { + axey = { speed = 16, level = 7, uses = 0 } + }, +}) + +minetest.register_tool("exchangeclone:red_matter_axe", { + description = "Red Matter Axe", + wield_image = "exchangeclone_red_matter_axe.png", + inventory_image = "exchangeclone_red_matter_axe.png", + groups = { tool=1, axe=1, dig_speed_class=8, enchantability=0 }, + wield_scale = exchangeclone.wield_scale, + tool_capabilities = { + -- 1/1.2 + full_punch_interval = 0.4, + max_drop_level=5, + damage_groups = {fleshy=19}, + punch_attack_uses = 0, + groupcaps={ + choppy = {times={[1]=1, [2]=0.5, [3]=0.25}, uses=0, maxlevel=5}, + }, + }, + sound = { breaks = "default_tool_breaks" }, + on_place = axe_on_place, + on_secondary_use = axe_on_place, + _mcl_toollike_wield = true, + _mcl_diggroups = { + axey = { speed = 20, level = 8, uses = 0 } + }, +}) + +minetest.register_craft({ + output = "exchangeclone:dark_matter_axe", + recipe = { + {"exchangeclone:dark_matter", "exchangeclone:dark_matter", ""}, + {"exchangeclone:dark_matter", exchangeclone.diamond_itemstring, ""}, + {"", exchangeclone.diamond_itemstring, ""} + } +}) + +minetest.register_craft({ + output = "exchangeclone:red_matter_axe", + recipe = { + {"exchangeclone:red_matter", "exchangeclone:red_matter", ""}, + {"exchangeclone:red_matter", "exchangeclone:dark_matter_axe", ""}, + {"", "exchangeclone:dark_matter", ""} + } +}) \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index da1b6f1..f88cd1f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -12,17 +12,15 @@ 2.0 New features: - Added a changelog (you're reading it now) + Added a changelog (you're reading it now!) Added all items from Why (a MineClone modpack I made) Added Philosopher's Stone Left click to increase range (minimum = 0, maximum = 4). Shift+left click to decrease range. Aux1+left click to open enchanting table (MineClone only). - Right click to transmute blocks in range. - Shift+right click transmute blocks in range (mode 2, some differences). + Right click to transmute blocks in range (mode 1). + Shift+right click to transmute blocks in range (mode 2, has some differences). Aux1+right click to open crafting table (MineClone only). - Crafted with a diamond in the middle, glowstone dust in the corners, and redstone dust on the sides (MineClone) - Crafted with a diamond in the middle, tin ingots in the corners, and obsidian on the sides (Minetest Game) Can use to craft coal into iron, mese into diamonds, etc. Changes: Changed version numbers from x.x.x to x.x. @@ -35,22 +33,50 @@ Ghost Blocks (from Why) are now worth 0 instead of 1 (to prevent infinite energy) Fixed stairs and slabs not working in Minetest Game -3.0 +3.0 (the most interesting release so far) New features: - Added Alchemical Coal, Mobius Fuel, Aeternalis Fuel, Dark Matter, and Red Matter + Added Alchemical Coal, Mobius Fuel, Aeternalis Fuel, Dark Matter (blocks and orbs), and Red Matter (blocks and orbs) + Added PESA (Personal Energy Storage Accessor) + A single inventory slot in which an orb can be placed. Energy from the orb is used for special abilities. Added Dark and Red Matter tools + Faster than any other tools (in unmodded MTG/MCL), each has an ability + Special abilities that break blocks (as well as shearing) drop items directly on the player. + Swords: + Can damage all mobs within a radius (Red Matter sword can toggle between hostile/all mobs), costing 384 energy. + Pickaxes: + Has 3x1 modes (long, tall, and wide, all slightly slower) + Can mine a full vein of ores, dropping items and experience on the player + Axes: + Can break all wood and leaves within a radius, costing 8 energy per block broken. + Shovels: + Can break all sand/gravel-like blocks within a radius, or all dirt-like blocks *on one level* within a radius, costing 8 energy per block broken + Hoes: + Breaks dirt incredibly quickly (and unfortunately all other shovely blocks because I can't figure out how to avoid it) + Has a 3x3 mode for digging dirt (slightly slower) + Can till all dirt within a radius, costs 2 energy per block + Hammers: + Breaks pickaxey blocks in a 3x3 area + Can break all pickaxey blocks within a radius + Shears: + More wool/mushrooms dropped when shearing, chance of cloning sheep/mooshrooms + Can shear all shearable plants/cobwebs within a radius, costing 8 energy per block broken. + Changes: + Added a mod whitelist in energy.lua, any item from a mod NOT in the whitelist (exchangeclone.whitelisted_mods) will have an energy value of 0 + Orbs now show their energy on right click instead of left click + Changed Philosopher's Stone controls to make everything more consistant The Energy Collector setting is now energy/second instead of second/energy to fit much higher costs than Element Exchange (default is 5 energy/s). Set gravel value to 1 to match sand/stone/dirt/etc (MineClone). Tuff, blackstone, and basalt are now transmutable (MineClone). A couple of minor transmutation changes (MineClone). Changed emerald value to 4096 (MineClone). Gold cannot be crafted into diamonds using the PS; it can now be crafted into emeralds and emeralds into diamonds (MineClone). - The PS's enchanting table now is limited to 8-bookshelf enchantments to make it more balanced. - Bugfixes: - Copper blocks are now worth 4 times as much as copper ingots instead of 9 (MineClone). + The PS's enchanting table now is limited to 8-bookshelf enchantments to make it more balanced (MineClone). Fixed terracotta values (MineClone) - The Energy Collector now drops its contents when broken in MineClone. + Bugfixes: + Fixed freezing when attempting to deconstruct 0-energy items + The Constructor, Deconstructor, and Energy Collector are now not unbreakable in MineClone (I really should test in survival). + Copper blocks are now worth 4 times as much as copper ingots instead of 9 (MineClone). + The Energy Collector now drops its contents when broken (MineClone) Fixed Exchange Orb energy value (forgot to change it after changing the recipe) - Changed constructor, deconstructor, and collector recipes and energy values to make them cheaper. - The Constructor, Deconstructor, and Energy Collector are now not unbreakable in MineClone (I really should test in survival). \ No newline at end of file + Changed Constructor, Deconstructor, and Collector recipes and energy values to make them cheaper. \ No newline at end of file diff --git a/constructor.lua b/constructor.lua index 02434bf..d61e6df 100644 --- a/constructor.lua +++ b/constructor.lua @@ -1,6 +1,11 @@ -local sound_mod = mcl_sounds or default +local sound_mod +if mcl_sounds then + sound_mod = mcl_sounds +else + sound_mod = default +end -function get_element_constructor_formspec() +local function get_element_constructor_formspec() if not exchangeclone.mineclone then local formspec = { "size[8,9]", @@ -169,7 +174,7 @@ minetest.register_node("exchangeclone:element_constructor", { sounds = sound_mod.node_sound_metal_defaults(), is_ground_content = false, can_dig = can_dig, - after_dig_node = function(pos, oldnode, oldmetadata, digger) + after_dig_node = function(pos, oldnode, oldmetadata, player) if exchangeclone.mineclone then local meta = minetest.get_meta(pos) local meta2 = meta:to_table() diff --git a/craftitems.lua b/craftitems.lua index 340b601..a914952 100644 --- a/craftitems.lua +++ b/craftitems.lua @@ -1,4 +1,9 @@ -local sound_mod = mcl_sounds or default +local sound_mod +if mcl_sounds then + sound_mod = mcl_sounds +else + sound_mod = default +end local function get_level(level) if exchangeclone.mineclone then @@ -83,24 +88,25 @@ minetest.register_node("exchangeclone:red_matter_block", { _mcl_blast_resistance = 1500, _mcl_hardness = 100, }) - -minetest.register_craft({ - output = "exchangeclone:dark_matter", - recipe = { - {"exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel"}, - {"exchangeclone:aeternalis_fuel", "mcl_core:diamondblock", "exchangeclone:aeternalis_fuel"}, - {"exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel"} - } -}) - -minetest.register_craft({ - output = "exchangeclone:dark_matter", - recipe = { - {"exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel"}, - {"exchangeclone:aeternalis_fuel", "default:diamondblock", "exchangeclone:aeternalis_fuel"}, - {"exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel"} - } -}) +if exchangeclone.mineclone then + minetest.register_craft({ + output = "exchangeclone:dark_matter", + recipe = { + {"exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel"}, + {"exchangeclone:aeternalis_fuel", "mcl_core:diamondblock", "exchangeclone:aeternalis_fuel"}, + {"exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel"} + } + }) +else + minetest.register_craft({ + output = "exchangeclone:dark_matter", + recipe = { + {"exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel"}, + {"exchangeclone:aeternalis_fuel", "default:diamondblock", "exchangeclone:aeternalis_fuel"}, + {"exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel", "exchangeclone:aeternalis_fuel"} + } + }) +end minetest.register_craft({ output = "exchangeclone:red_matter", @@ -130,15 +136,15 @@ minetest.register_craft({ minetest.register_craft({ output = "exchangeclone:dark_matter 4", recipe = { - {"exchangeclone:dark_matter_block","exchangeclone:dark_matter_block}"}, - {"exchangeclone:dark_matter_block","exchangeclone:dark_matter_block}"} + {"exchangeclone:dark_matter_block","exchangeclone:dark_matter_block"}, + {"exchangeclone:dark_matter_block","exchangeclone:dark_matter_block"} } }) minetest.register_craft({ output = "exchangeclone:red_matter 4", recipe = { - {"exchangeclone:red_matter_block","exchangeclone:red_matter_block}"}, - {"exchangeclone:red_matter_block","exchangeclone:red_matter_block}"} + {"exchangeclone:red_matter_block","exchangeclone:red_matter_block"}, + {"exchangeclone:red_matter_block","exchangeclone:red_matter_block"} } }) \ No newline at end of file diff --git a/deconstructor.lua b/deconstructor.lua index 453b369..7a8f221 100644 --- a/deconstructor.lua +++ b/deconstructor.lua @@ -1,4 +1,9 @@ -local sound_mod = mcl_sounds or default +local sound_mod +if mcl_sounds then + sound_mod = mcl_sounds +else + sound_mod = default +end --Renamed "fuel" inventory to "main" to (almost) work with hoppers @@ -61,10 +66,12 @@ local function on_timer(pos, elapsed) else energy_value = exchangeclone.get_item_energy(fuel_stack:get_name()) end - if energy_value ~= 0 then + if energy_value == 0 then + break + else local wear = fuel_stack:get_wear() if wear and wear > 1 then - energy_value = math.floor(energy_value * (65536 / wear)) + energy_value = math.ceil(energy_value * (65536 / wear)) end -- only get 1 orb as we can only use one local stored = exchangeclone.get_orb_energy(inv, "dst", 1) @@ -150,7 +157,7 @@ minetest.register_node("exchangeclone:element_deconstructor", { sounds = sound_mod.node_sound_metal_defaults(), is_ground_content = false, can_dig = can_dig, - after_dig_node = function(pos, oldnode, oldmetadata, digger) + after_dig_node = function(pos, oldnode, oldmetadata, player) if exchangeclone.mineclone then local meta = minetest.get_meta(pos) local meta2 = meta:to_table() diff --git a/energy.lua b/energy.lua index 34c853a..6725e33 100644 --- a/energy.lua +++ b/energy.lua @@ -1272,63 +1272,171 @@ exchangeclone.mcl_potion_data = { {name = "invisibility", ingredient_cost = 192, custom_base_cost = 623, plus = true} } -local function get_group_items(groups, allow_duplicates, include_no_group) - if type(groups) ~= "table" then - return nil - end +exchangeclone.whitelisted_mods = { + ["exchangeclone"] = true, + ["beds"] = true, + ["binoculars"] = true, + ["boats"] = true, + ["bones"] = true, + ["bucket"] = true, + ["butterflies"] = true, + ["carts"] = true, + ["default"] = true, + ["doors"] = true, + ["dye"] = true, + ["farming"] = true, + ["fire"] = true, + ["fireflies"] = true, + ["flowers"] = true, + ["keys"] = true, + ["mapping_kit"] = true, + ["moreswords"] = true, + ["stairs"] = true, + ["tnt"] = true, + ["vessels"] = true, + ["walls"] = true, + ["wool"] = true, + ["xpanes"] = true, + ["doc_identifier"] = true, + ["fake_liquids"] = true, + ["ghost_blocks"] = true, + ["lava_sponge"] = true, + ["mcl_amethyst"] = true, + ["mcl_anvils"] = true, + ["mcl_armor"] = true, + ["mcl_armor_stand"] = true, + ["mcl_bamboo"] = true, + ["mcl_banners"] = true, + ["mcl_barrels"] = true, + ["mcl_beacons"] = true, + ["mcl_beds"] = true, + ["mcl_books"] = true, + ["mcl_bows"] = true, + ["mcl_cauldrons"] = true, + ["mcl_chests"] = true, + ["mcl_clock"] = true, + ["mcl_cocoas"] = true, + ["mcl_colorblocks"] = true, + ["mcl_colors"] = true, + ["mcl_comparators"] = true, + ["mcl_compass"] = true, + ["mcl_composters"] = true, + ["mcl_copper"] = true, + ["mcl_core"] = true, + ["mcl_crafting_table"] = true, + ["mcl_crimson"] = true, + ["mcl_deepslate"] = true, + ["mcl_dispensers"] = true, + ["mcl_doors"] = true, + ["mcl_droppers"] = true, + ["mcl_dye"] = true, + ["mcl_enchanting"] = true, + ["mcl_end"] = true, + ["mcl_experience"] = true, + ["mcl_farming"] = true, + ["mcl_fences"] = true, + ["mcl_fire"] = true, + ["mcl_fireworks"] = true, + ["mcl_fishing"] = true, + ["mcl_fletching_table"] = true, + ["mcl_flowerpots"] = true, + ["mcl_flowers"] = true, + ["mcl_furnaces"] = true, + ["mcl_grindstone"] = true, + ["mcl_hamburger"] = true, + ["mcl_heads"] = true, + ["mcl_honey"] = true, + ["mcl_hoppers"] = true, + ["mcl_itemframes"] = true, + ["mcl_jukebox"] = true, + ["mcl_lanterns"] = true, + ["mcl_lectern"] = true, + ["mcl_lightning_rods"] = true, + ["mcl_loom"] = true, + ["mcl_mangrove"] = true, + ["mcl_maps"] = true, + ["mcl_minecarts"] = true, + ["mcl_mobitems"] = true, + ["mcl_mud"] = true, + ["mcl_mushrooms"] = true, + ["mcl_nether"] = true, + ["mcl_observers"] = true, + ["mcl_ocean"] = true, + ["mcl_paintings"] = true, + ["mcl_potions"] = true, + ["mcl_raw_ores"] = true, + ["mcl_sculk"] = true, + ["mcl_shields"] = true, + ["mcl_signs"] = true, + ["mcl_smithing_table"] = true, + ["mcl_smoker"] = true, + ["mcl_sponges"] = true, + ["mcl_spyglass"] = true, + ["mcl_stairs"] = true, + ["mcl_stonecutter"] = true, + ["mcl_sus_stew"] = true, + ["mcl_target"] = true, + ["mcl_tnt"] = true, + ["mcl_tools"] = true, + ["mcl_throwing"] = true, + ["mcl_torches"] = true, + ["mcl_totems"] = true, + ["mcl_villages"] = true, + ["mcl_walls"] = true, + ["mcl_wool"] = true, + ["mclx_core"] = true, + ["mclx_fences"] = true, + ["mclx_stairs"] = true, + ["meat_blocks"] = true, + ["screwdriver"] = true, + ["slime_things"] = true, + ["small_why_things"] = true, + ["sound_machine"] = true, + ["sticky_things"] = true, +} - allow_duplicates = allow_duplicates or false - include_no_group = include_no_group or false - local g_cnt = #groups - - local result = {} - for i = 1, g_cnt do - result[groups[i]] = {} - end - if include_no_group then - result["NO_GROUP"] = {} +--only allow Mesecons in MineClone +if exchangeclone.mineclone then + for k, v in pairs({ + ["mesecons"] = true, + ["mesecons_button"] = true, + ["mesecons_delayer"] = true, + ["mesecons_lightstone"] = true, + ["mesecons_noteblock"] = true, + ["mesecons_pistons"] = true, + ["mesecons_pressureplates"] = true, + ["mesecons_solarpanel"] = true, + ["mesecons_torch"] = true, + ["mesecons_walllever"] = true, + ["mesecons_wires"] = true, + }) do + exchangeclone.whitelisted_mods[k] = v end - local in_group = false - - for name, def in pairs(minetest.registered_items) do - in_group = false - for i = 1, g_cnt do - local grp = groups[i] - if def.groups[grp] ~= nil then - result[grp][#result[grp]+1] = name - in_group = true - if allow_duplicates == false then - break - end - end - end - if include_no_group and in_group == false then - result["NO_GROUP"][#result["NO_GROUP"]+1] = name - end - end - - return result end -function exchangeclone.set_item_energy(itemstring, energy_value) +local function set_item_energy(itemstring, energy_value) local def = minetest.registered_items[itemstring] if not def then return end if not def.groups then return end if not def.description or def.description == "" then return end local _, _, mod_name, item_name = itemstring:find("([%d_%l]+):([%d_%l]+)") if not (item_name and mod_name) then return end - if mod_name == "ghost_blocks" then - energy_value = 0 --I don't know what to do about ghost blocks. - end - if exchangeclone.mineclone then - if exchangeclone.mcl_energy_values[mod_name] then - energy_value = exchangeclone.mcl_energy_values[mod_name][item_name] or energy_value --override if possible + if exchangeclone.whitelisted_mods[mod_name] then + if mod_name == "ghost_blocks" then + energy_value = 0 --I don't know what to do about ghost blocks. + end + if exchangeclone.mineclone then + if exchangeclone.mcl_energy_values[mod_name] then + energy_value = exchangeclone.mcl_energy_values[mod_name][item_name] or energy_value --override if possible + end + else + if exchangeclone.mtg_energy_values[mod_name] then + energy_value = exchangeclone.mtg_energy_values[mod_name][item_name] or energy_value --override if possible + end end else - if exchangeclone.mtg_energy_values[mod_name] then - energy_value = exchangeclone.mtg_energy_values[mod_name][item_name] or energy_value --override if possible - end + energy_value = 0 end local description = def.description local groups = table.copy(def.groups) @@ -1374,38 +1482,38 @@ end local function add_potion_energy(info) local base_cost = 2 --cost of water bottle - --TODO: Change when MineClone does. + --TODO: Change dragon's breath when MineClone does. local dragon_breath_cost = 8.5 base_cost = math.floor(base_cost + (info.ingredient_cost / 3)) --/3 because 3 potions/ingredient base_cost = base_cost + (info.custom_base_cost or 8) --8 = 1/3 of nether wart. local splash_cost = base_cost + 64 local lingering_cost = math.floor(base_cost + (dragon_breath_cost / 3)) - exchangeclone.set_item_energy("mcl_potions:"..info.name, base_cost) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_splash", splash_cost) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_lingering", lingering_cost) + 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) if not info.no_arrow then local arrow_cost = math.floor(lingering_cost / 8 + 3) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_arrow", arrow_cost) + set_item_energy("mcl_potions:"..info.name.."_arrow", arrow_cost) end if info.plus then local plus_base_cost = base_cost + 21 local plus_splash_cost = splash_cost + 21 local plus_lingering_cost = lingering_cost + 21 local plus_arrow_cost = math.floor(plus_lingering_cost / 8 + 3) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_plus", plus_base_cost) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_plus_splash", plus_splash_cost) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_plus_lingering", plus_lingering_cost) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_plus_arrow", plus_arrow_cost) + 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) + set_item_energy("mcl_potions:"..info.name.."_plus_arrow", plus_arrow_cost) end if info.two then local two_base_cost = base_cost + 21 local two_splash_cost = splash_cost + 21 local two_lingering_cost = lingering_cost + 21 local two_arrow_cost = math.floor(two_lingering_cost / 8 + 3) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_2", two_base_cost) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_2_splash", two_splash_cost) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_2_lingering", two_lingering_cost) - exchangeclone.set_item_energy("mcl_potions:"..info.name.."_2_arrow", two_arrow_cost) + 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) + set_item_energy("mcl_potions:"..info.name.."_2_arrow", two_arrow_cost) end end @@ -1417,28 +1525,28 @@ minetest.register_on_mods_loaded(function() for index, group in ipairs(exchangeclone.mcl_group_values) do groupnames[#groupnames + 1] = group[1] --Get list of group names end - local grouped_items = get_group_items(groupnames, true, true) + local grouped_items = exchangeclone.get_group_items(groupnames, true, true) for index, group in ipairs(exchangeclone.mcl_group_values) do for i, item in pairs(grouped_items[group[1]]) do - exchangeclone.set_item_energy(item, group[2]) + set_item_energy(item, group[2]) end end for i = 0, 31 do - exchangeclone.set_item_energy("mcl_compass:"..i.."_recovery", 443456) + set_item_energy("mcl_compass:"..i.."_recovery", 443456) end for i = 0, 31 do - exchangeclone.set_item_energy("mcl_compass:"..i, 1088) + set_item_energy("mcl_compass:"..i, 1088) end - exchangeclone.set_item_energy("mcl_compass:compass", 1088) + set_item_energy("mcl_compass:compass", 1088) for i = 0, 63 do - exchangeclone.set_item_energy("mcl_clock:clock_"..i, 8256) + set_item_energy("mcl_clock:clock_"..i, 8256) end - exchangeclone.set_item_energy("mcl_clock:clock", 8256) + set_item_energy("mcl_clock:clock", 8256) --It's almost like the "compass" and "clock" groups don't exist. I tried using them, but it just didn't work. - exchangeclone.set_item_energy("mcl_bone_meal:bone_meal", 48) + set_item_energy("mcl_bone_meal:bone_meal", 48) --Bone meal just doesn't work either, for some reason. for i = 1, 8 do --faster than doing everything individually. - exchangeclone.set_item_energy("mcl_jukebox:record_"..i, 1024) + set_item_energy("mcl_jukebox:record_"..i, 1024) end for _, info in ipairs(exchangeclone.mcl_potion_data) do add_potion_energy(info) @@ -1449,16 +1557,16 @@ minetest.register_on_mods_loaded(function() for index, group in ipairs(exchangeclone.mtg_group_values) do groupnames[#groupnames + 1] = group[1] --Get list of group names end - local grouped_items = get_group_items(groupnames, true, true) + local grouped_items = exchangeclone.get_group_items(groupnames, true, true) for index, group in ipairs(exchangeclone.mtg_group_values) do for i, item in pairs(grouped_items[group[1]]) do - exchangeclone.set_item_energy(item, group[2]) + set_item_energy(item, group[2]) end end end for _, item in ipairs(slabs_and_stairs) do - exchangeclone.set_item_energy(item[1], item[2]) + set_item_energy(item[1], item[2]) end end ) \ No newline at end of file diff --git a/energy_collector.lua b/energy_collector.lua index 94ffe79..0ee9657 100644 --- a/energy_collector.lua +++ b/energy_collector.lua @@ -1,4 +1,9 @@ -local sound_mod = mcl_sounds or default +local sound_mod +if mcl_sounds then + sound_mod = mcl_sounds +else + sound_mod = default +end local function get_energy_collector_formspec() local formspec @@ -104,7 +109,7 @@ local function on_blast(pos) return drops end -local function on_dig_node(pos, oldnode, oldmetadata, digger) +local function on_dig_node(pos, oldnode, oldmetadata, player) if exchangeclone.mineclone then local meta = minetest.get_meta(pos) local meta2 = meta:to_table() @@ -176,7 +181,7 @@ minetest.register_node("exchangeclone:energy_collector", { end end, }, - after_place_node = function(pos, placer) + after_place_node = function(pos, player) pipeworks.after_place(pos) end, after_dig_node = pipeworks.after_dig, diff --git a/hammers.lua b/hammers.lua new file mode 100644 index 0000000..d34ab39 --- /dev/null +++ b/hammers.lua @@ -0,0 +1,267 @@ +local stone_group = "cracky" +if exchangeclone.mineclone then + stone_group = "pickaxey" +end + +local players_digging = {} + +local hammer_break_cube = function(player, center, distance) + players_digging[player:get_player_name()] = true -- to prevent doing 3x3 as well as AOE + exchangeclone.play_ability_sound(player) + local player_pos = player:get_pos() + local player_energy = exchangeclone.get_player_energy(player) + local energy_cost = 0 + local pos = center + pos.x = exchangeclone.round(pos.x) + pos.y = math.floor(pos.y) --make sure y is node BELOW player's feet + pos.z = exchangeclone.round(pos.z) + + for x = pos.x-distance, pos.x+distance do + if energy_cost + 8 > player_energy then + break + end + for y = pos.y-distance, pos.y+distance do + if energy_cost + 8 > player_energy then + break + end + for z = pos.z-distance, pos.z+distance do + if energy_cost + 8 > player_energy then + break + end + local new_pos = {x=x,y=y,z=z} + local node = minetest.get_node(new_pos) or {name="air"} + if minetest.get_item_group(node.name, stone_group) ~= 0 then + if minetest.is_protected(new_pos, player:get_player_name()) then + minetest.record_protection_violation(new_pos, player:get_player_name()) + else + energy_cost = energy_cost + 8 + local drops = minetest.get_node_drops(node.name, "exchangeclone:red_matter_hammer") + exchangeclone.drop_items_on_player(new_pos, drops, player) + minetest.set_node(new_pos, {name = "air"}) + end + end + end + end + end + exchangeclone.set_player_energy(player, player_energy - energy_cost) + players_digging[player:get_player_name()] = nil +end + +local function hammer_on_place(itemstack, player, pointed_thing) + local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) + if click_test ~= false then + return click_test + end + + if player:get_player_control().aux1 then + if itemstack:get_name():find("dark") then + return exchangeclone.range_update(itemstack, player, 3) + else + return exchangeclone.range_update(itemstack, player, 4) + end + end + + if player:get_player_control().sneak then + local current_name = itemstack:get_name() + if string.sub(current_name, -4, -1) == "_3x3" then + itemstack:set_name(string.sub(current_name, 1, -5)) + minetest.chat_send_player(player:get_player_name(), "Single block mode") + else + itemstack:set_name(current_name.."_3x3") + minetest.chat_send_player(player:get_player_name(), "3x3 mode") + end + return itemstack + end + + local range = itemstack:get_meta():get_int("exchangeclone_item_range") + local center = player:get_pos() + if pointed_thing.type == "node" then + center = pointed_thing.under + end + hammer_break_cube(player, center, range) +end + +minetest.register_tool("exchangeclone:dark_matter_hammer", { + description = "Dark Matter Hammer", + wield_image = "exchangeclone_dark_matter_hammer.png", + inventory_image = "exchangeclone_dark_matter_hammer.png", + groups = { tool=1, hammer=1, dig_speed_class=7, enchantability=0, dark_matter_hammer = 1 }, + wield_scale = exchangeclone.wield_scale, + tool_capabilities = { + -- 1/1.2 + full_punch_interval = 0.5, + max_drop_level=5, + damage_groups = {fleshy=7}, + punch_attack_uses = 0, + groupcaps={ + cracky = {times={[1]=1.5, [2]=0.75, [3]=0.325}, uses=0, maxlevel=4}, + }, + }, + sound = { breaks = "default_tool_breaks" }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 16, level = 7, uses = 0 } + }, + on_place = hammer_on_place, + on_secondary_use = hammer_on_place, +}) + +minetest.register_tool("exchangeclone:dark_matter_hammer_3x3", { + description = "Dark Matter Hammer", + wield_image = "exchangeclone_dark_matter_hammer.png", + inventory_image = "exchangeclone_dark_matter_hammer.png", + groups = { tool=1, hammer=1, dig_speed_class=7, enchantability=0, dark_matter_hammer = 1, not_in_creative_inventory = 1 }, + wield_scale = exchangeclone.wield_scale, + tool_capabilities = { + -- 1/1.2 + full_punch_interval = 0.5, + max_drop_level=5, + damage_groups = {fleshy=7}, + punch_attack_uses = 0, + groupcaps={ + cracky = {times={[1]=1.8, [2]=0.9, [3]=0.5}, uses=0, maxlevel=4}, + }, + }, + sound = { breaks = "default_tool_breaks" }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 12, level = 7, uses = 0 } + }, + on_place = hammer_on_place, + on_secondary_use = hammer_on_place, +}) + +minetest.register_tool("exchangeclone:red_matter_hammer", { + description = "Red Matter Hammer", + wield_image = "exchangeclone_red_matter_hammer.png", + inventory_image = "exchangeclone_red_matter_hammer.png", + groups = { tool=1, hammer=1, dig_speed_class=7, enchantability=0, red_matter_hammer = 1 }, + wield_scale = exchangeclone.wield_scale, + tool_capabilities = { + -- 1/1.2 + full_punch_interval = 0.3, + max_drop_level=5, + damage_groups = {fleshy=9}, + punch_attack_uses = 0, + groupcaps={ + cracky = {times={[1]=1, [2]=0.5, [3]=0.2}, uses=0, maxlevel=5}, + }, + }, + sound = { breaks = "default_tool_breaks" }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 19, level = 8, uses = 0 } + }, + on_place = hammer_on_place, + on_secondary_use = hammer_on_place, +}) + +minetest.register_tool("exchangeclone:red_matter_hammer_3x3", { + description = "Red Matter Hammer", + wield_image = "exchangeclone_red_matter_hammer.png", + inventory_image = "exchangeclone_red_matter_hammer.png", + groups = { tool=1, hammer=1, dig_speed_class=7, enchantability=0, red_matter_hammer = 1, not_in_creative_inventory = 1 }, + wield_scale = exchangeclone.wield_scale, + tool_capabilities = { + -- 1/1.2 + full_punch_interval = 0.3, + max_drop_level=5, + damage_groups = {fleshy=9}, + punch_attack_uses = 0, + groupcaps={ + cracky = {times={[1]=1.25, [2]=0.6, [3]=0.3}, uses=0, maxlevel=5}, + }, + }, + sound = { breaks = "default_tool_breaks" }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 14, level = 8, uses = 0 } + }, + on_place = hammer_on_place, + on_secondary_use = hammer_on_place, +}) + +-- adapted from https://github.com/cultom/hammermod/blob/master/init.lua + +local function dig_if_stone(pos, player) + local node = minetest.get_node(pos) + if minetest.get_item_group(node.name, stone_group) ~= 0 then + minetest.node_dig(pos, minetest.get_node(pos), player) + end +end + +minetest.register_on_dignode( + function(pos, oldnode, player) + if player == nil or (player:get_wielded_item():get_name() ~= "exchangeclone:dark_matter_hammer_3x3" + and player:get_wielded_item():get_name() ~= "exchangeclone:red_matter_hammer_3x3") then + return + end + + local playerName = player:get_player_name() + if(playerName == "" or players_digging[playerName]) then + return + end + players_digging[playerName] = true + + local player_rotation = exchangeclone.get_face_direction(player) + + local dir1 + local dir2 + + if player_rotation.y ~= 0 then + dir1 = "x" + dir2 = "z" + elseif player_rotation.x ~= 0 then + dir1 = "y" + dir2 = "z" + elseif player_rotation.z ~= 0 then + dir1 = "x" + dir2 = "y" + end + + --[[ + 123 + 4 5 + 678 + ]] + + pos[dir1] = pos[dir1] - 1 --7 + dig_if_stone(pos, player) + pos[dir2] = pos[dir2] - 1 --6 + dig_if_stone(pos, player) + pos[dir1] = pos[dir1] + 1 --4 + dig_if_stone(pos, player) + pos[dir1] = pos[dir1] + 1 --1 + dig_if_stone(pos, player) + pos[dir2] = pos[dir2] + 1 --2 + dig_if_stone(pos, player) + pos[dir2] = pos[dir2] + 1 --3 + dig_if_stone(pos, player) + pos[dir1] = pos[dir1] - 1 --5 + dig_if_stone(pos, player) + pos[dir1] = pos[dir1] - 1 --8 + dig_if_stone(pos, player) + + players_digging[playerName] = nil + end +) + +-- end copied code + +minetest.register_craft({ + output = "exchangeclone:dark_matter_hammer", + recipe = { + {"exchangeclone:dark_matter", exchangeclone.diamond_itemstring, "exchangeclone:dark_matter"}, + {"", exchangeclone.diamond_itemstring, ""}, + {"", exchangeclone.diamond_itemstring, ""} + } +}) + +minetest.register_craft({ + output = "exchangeclone:red_matter_hammer", + recipe = { + {"exchangeclone:red_matter", "exchangeclone:dark_matter", "exchangeclone:red_matter"}, + {"", "group:dark_matter_hammer", ""}, + {"", "exchangeclone:dark_matter", ""} + } +}) \ No newline at end of file diff --git a/hoes.lua b/hoes.lua new file mode 100644 index 0000000..e967914 --- /dev/null +++ b/hoes.lua @@ -0,0 +1,288 @@ +local function create_soil(itemstack, player, pointed_thing) + if not pointed_thing.under then return end + if not pointed_thing.under.x then return end + local pos = pointed_thing.under + local name = minetest.get_node(pos).name + local above_name = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name + + if minetest.is_protected(pointed_thing.under, player:get_player_name()) then + minetest.record_protection_violation(pointed_thing.under, player:get_player_name()) + return itemstack + end + if minetest.get_item_group(name, "cultivatable") == 2 then + if above_name == "air" then + name = "mcl_farming:soil" + minetest.set_node(pos, {name=name}) + minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.5 }, true) + end + elseif minetest.get_item_group(name, "cultivatable") == 1 then + if above_name == "air" then + name = "mcl_core:dirt" + minetest.set_node(pos, {name=name}) + minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.6 }, true) + end + end + return itemstack +end + +local hoe_function + +if exchangeclone.mineclone then + hoe_function = create_soil +else + hoe_function = farming.hoe_on_use -- assuming farming exists +end + +local hoe_on_place = function(itemstack, player, pointed_thing) + + local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) + if click_test ~= false then + return click_test + end + + if player:get_player_control().aux1 then + if itemstack:get_name():find("dark") then + return exchangeclone.range_update(itemstack, player, 3) + else + return exchangeclone.range_update(itemstack, player, 4) + end + end + if player:get_player_control().sneak then + local current_name = itemstack:get_name() + if string.sub(current_name, -4, -1) == "_3x3" then + itemstack:set_name(string.sub(current_name, 1, -5)) + minetest.chat_send_player(player:get_player_name(), "Single block mode") + else + itemstack:set_name(current_name.."_3x3") + minetest.chat_send_player(player:get_player_name(), "3x3 mode") + end + return itemstack + end + local range = itemstack:get_meta():get_int("exchangeclone_item_range") + if range == 0 and pointed_thing.type == "node" and pointed_thing.under and pointed_thing.under.x then + --minetest.log(dump(pointed_thing)) + hoe_function(itemstack, player, pointed_thing) + return itemstack + end + exchangeclone.play_ability_sound(player) + local start_pos = player:get_pos() + local player_energy = exchangeclone.get_player_energy(player) + local energy_cost = 0 + if pointed_thing.type == "node" and pointed_thing.under and pointed_thing.under.x then + start_pos = pointed_thing.under + end + --minetest.log(dump(start_pos)) + start_pos.x = exchangeclone.round(start_pos.x) + start_pos.y = math.floor(start_pos.y) --make sure y is node BELOW player's feet + start_pos.z = exchangeclone.round(start_pos.z) + + for x = start_pos.x - range, start_pos.x + range do + if energy_cost + 2 > player_energy then + break + end + for y = start_pos.y - range, start_pos.y + range do + if energy_cost + 2 > player_energy then + break + end + for z = start_pos.z - range, start_pos.z + range do + if energy_cost + 2 > player_energy then + break + end + local new_pos = {x=x,y=y,z=z} + local new_pointed_thing = {type = "node", under = new_pos, above = {x=x,y=x+1,z=z}} + energy_cost = energy_cost + 2 + hoe_function(itemstack, player, new_pointed_thing) + end + end + end + exchangeclone.set_player_energy(player, player_energy - energy_cost) + return itemstack +end + +if exchangeclone.mineclone then + mcl_autogroup.register_diggroup("exchangeclone_dirt") +end +for name, def in pairs(minetest.registered_nodes) do + local is_dirt = minetest.get_item_group(name, "cultivatable") + minetest.get_item_group(name, "soil") + if is_dirt > 0 then + if not name:find("sand") then + local item_groups = table.copy(def.groups) + item_groups.exchangeclone_dirt = 1 + minetest.override_item(name, {groups = item_groups}) + end + end +end + +minetest.register_tool("exchangeclone:dark_matter_hoe", { + description = "Dark Matter Hoe", + wield_image = "exchangeclone_dark_matter_hoe.png", + inventory_image = "exchangeclone_dark_matter_hoe.png", + wield_scale = exchangeclone.wield_scale, + on_place = hoe_on_place, + on_secondary_use = hoe_on_place, + groups = { tool=1, hoe=1, enchantability=0, dark_matter_hoe = 1 }, + tool_capabilities = { + full_punch_interval = 0.25, + damage_groups = { fleshy = 7, }, + groupcaps={ + exchangeclone_dirt = {times={[1]=0.25, [2]=0.25, [3]=0.25}, uses=0, maxlevel=4}, + }, + }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + exchangeclone_dirt = { speed = 12, level = 7, uses = 0 }, + hoey = { speed = 12, level = 7, uses = 0 } + }, +}) + +minetest.register_tool("exchangeclone:dark_matter_hoe_3x3", { + description = "Dark Matter Hoe", + wield_image = "exchangeclone_dark_matter_hoe.png", + inventory_image = "exchangeclone_dark_matter_hoe.png", + wield_scale = exchangeclone.wield_scale, + on_place = hoe_on_place, + on_secondary_use = hoe_on_place, + groups = { tool=1, hoe=1, enchantability=0, dark_matter_hoe = 1, not_in_creative_inventory = 1 }, + tool_capabilities = { + full_punch_interval = 0.25, + damage_groups = { fleshy = 7, }, + groupcaps={ + exchangeclone_dirt = {times={[1]=0.4, [2]=0.4, [3]=0.4}, uses=0, maxlevel=4}, + }, + }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + exchangeclone_dirt = { speed = 8, level = 7, uses = 0 }, + hoey = { speed = 8, level = 7, uses = 0 } + }, +}) + +minetest.register_tool("exchangeclone:red_matter_hoe", { + description = "Red Matter Hoe", + wield_image = "exchangeclone_red_matter_hoe.png", + inventory_image = "exchangeclone_red_matter_hoe.png", + wield_scale = exchangeclone.wield_scale, + on_place = hoe_on_place, + on_secondary_use = hoe_on_place, + groups = { tool=1, hoe=1, enchantability=0, red_matter_hoe = 1 }, + tool_capabilities = { + full_punch_interval = 0.25, + damage_groups = { fleshy = 8, }, + groupcaps={ + exchangeclone_dirt = {times={[1]=0.15, [2]=0.15, [3]=0.15}, uses=0, maxlevel=4}, + }, + }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + exchangeclone_dirt = { speed = 13, level = 8, uses = 0 }, + hoey = { speed = 13, level = 8, uses = 0 } + }, +}) + +minetest.register_tool("exchangeclone:red_matter_hoe_3x3", { + description = "Red Matter Hoe", + wield_image = "exchangeclone_red_matter_hoe.png", + inventory_image = "exchangeclone_red_matter_hoe.png", + wield_scale = exchangeclone.wield_scale, + on_place = hoe_on_place, + on_secondary_use = hoe_on_place, + groups = { tool=1, hoe=1, enchantability=0, red_matter_hoe = 1, not_in_creative_inventory = 1 }, + tool_capabilities = { + full_punch_interval = 0.25, + damage_groups = { fleshy = 8, }, + groupcaps={ + exchangeclone_dirt = {times={[1]=0.25, [2]=0.25, [3]=0.25}, uses=0, maxlevel=4}, + }, + }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + exchangeclone_dirt = { speed = 9, level = 8, uses = 0 }, + hoey = { speed = 9, level = 8, uses = 0 } + }, +}) + +-- adapted from https://github.com/cultom/hammermod/blob/master/init.lua +local players_digging = {} + +local function dig_if_dirt(pos, player) + local node = minetest.get_node(pos) + if minetest.get_item_group(node.name, "exchangeclone_dirt") ~= 0 then + minetest.node_dig(pos, minetest.get_node(pos), player) + end +end + +minetest.register_on_dignode( + function(pos, oldnode, player) + if player == nil or (player:get_wielded_item():get_name() ~= "exchangeclone:dark_matter_hoe_3x3" + and player:get_wielded_item():get_name() ~= "exchangeclone:red_matter_hoe_3x3") then + return + end + + local playerName = player:get_player_name() + if (playerName == "" or players_digging[playerName]) then + return + end + players_digging[playerName] = true + + local player_rotation = exchangeclone.get_face_direction(player) + + local dir1 + local dir2 + + if player_rotation.y ~= 0 then + dir1 = "x" + dir2 = "z" + elseif player_rotation.x ~= 0 then + dir1 = "y" + dir2 = "z" + elseif player_rotation.z ~= 0 then + dir1 = "x" + dir2 = "y" + end + + --[[ + 123 + 4 5 + 678 + ]] + + pos[dir1] = pos[dir1] - 1 --7 + dig_if_dirt(pos, player) + pos[dir2] = pos[dir2] - 1 --6 + dig_if_dirt(pos, player) + pos[dir1] = pos[dir1] + 1 --4 + dig_if_dirt(pos, player) + pos[dir1] = pos[dir1] + 1 --1 + dig_if_dirt(pos, player) + pos[dir2] = pos[dir2] + 1 --2 + dig_if_dirt(pos, player) + pos[dir2] = pos[dir2] + 1 --3 + dig_if_dirt(pos, player) + pos[dir1] = pos[dir1] - 1 --5 + dig_if_dirt(pos, player) + pos[dir1] = pos[dir1] - 1 --8 + dig_if_dirt(pos, player) + + players_digging[playerName] = nil + end +) + +-- end copied code + +minetest.register_craft({ + output = "exchangeclone:dark_matter_hoe", + recipe = { + {"exchangeclone:dark_matter", "exchangeclone:dark_matter", ""}, + {"", exchangeclone.diamond_itemstring, ""}, + {"", exchangeclone.diamond_itemstring, ""} + } +}) + +minetest.register_craft({ + output = "exchangeclone:red_matter_hoe", + recipe = { + {"exchangeclone:red_matter", "exchangeclone:red_matter", ""}, + {"", "group:dark_matter_hoe", ""}, + {"", "exchangeclone:dark_matter", ""} + } +}) \ No newline at end of file diff --git a/init.lua b/init.lua index df881fc..2fbfc4b 100644 --- a/init.lua +++ b/init.lua @@ -5,26 +5,11 @@ else exchangeclone.mineclone = minetest.get_modpath("mcl_core") end -function exchangeclone.get_inventory_drops(pos, inventory, drops) --removes default dependency - local inv = minetest.get_meta(pos):get_inventory() - local n = #drops - for i = 1, inv:get_size(inventory) do - local stack = inv:get_stack(inventory, i) - if stack:get_count() > 0 then - drops[n+1] = stack:to_table() - n = n + 1 - end - end -end - local default_path = minetest.get_modpath("exchangeclone") -function exchangeclone.get_item_energy(name) - return minetest.registered_items[name].energy_value -end - exchangeclone.collector_speed = minetest.settings:get("exchangeclone.energy_collector_speed") or 5 +dofile(default_path.."/lib.lua") dofile(default_path.."/constructor.lua") dofile(default_path.."/deconstructor.lua") dofile(default_path.."/energy_collector.lua") @@ -35,6 +20,10 @@ if exchangeclone.mineclone then dofile(default_path.."/shears.lua") end dofile(default_path.."/swords.lua") +dofile(default_path.."/axes.lua") +dofile(default_path.."/hoes.lua") +dofile(default_path.."/pickaxes.lua") +dofile(default_path.."/hammers.lua") dofile(default_path.."/philosophers_stone.lua") dofile(default_path.."/pesa.lua") dofile(default_path.."/energy.lua") \ No newline at end of file diff --git a/lib.lua b/lib.lua new file mode 100644 index 0000000..63085ec --- /dev/null +++ b/lib.lua @@ -0,0 +1,281 @@ +function exchangeclone.get_inventory_drops(pos, inventory, drops) --removes default dependency + local inv = minetest.get_meta(pos):get_inventory() + local n = #drops + for i = 1, inv:get_size(inventory) do + local stack = inv:get_stack(inventory, i) + if stack:get_count() > 0 then + drops[n+1] = stack:to_table() + n = n + 1 + end + end +end + +function exchangeclone.get_item_energy(name) + return minetest.registered_items[name].energy_value +end + +function exchangeclone.round(num) + if num % 1 < 0.5 then + return math.floor(num) + else + return math.ceil(num) + end +end + +function exchangeclone.get_orb_energy(inventory, listname, index) + if not inventory then return end + if not listname then listname = "main" end + if not index then index = 1 end + local itemstack = inventory:get_stack(listname, index) + if not itemstack then return 0 end + if not itemstack:get_name() then return 0 end + return itemstack:get_meta():get_float("stored_energy") +end + +function exchangeclone.set_orb_energy(inventory, listname, index, amount) + if (not inventory) or (not amount) or (amount < 0) then return end + if not listname then listname = "main" end + if not index then index = 1 end + local itemstack = inventory:get_stack(listname, index) + if not itemstack then return end + if not itemstack:get_name() then return end + itemstack:get_meta():set_float("stored_energy", amount) + itemstack:get_meta():set_string("description", "Exchange Orb\nCurrent Charge: "..amount) + inventory:set_stack(listname, index, itemstack) +end + +function exchangeclone.get_player_energy(player) + return exchangeclone.get_orb_energy(player:get_inventory(), "exchangeclone_pesa", 1) +end + +function exchangeclone.set_player_energy(player, amount) + exchangeclone.set_orb_energy(player:get_inventory(), "exchangeclone_pesa", 1, amount) +end + +function exchangeclone.get_group_items(groups, allow_duplicates, include_no_group) + if type(groups) ~= "table" then + return nil + end + + allow_duplicates = allow_duplicates or false + include_no_group = include_no_group or false + + local g_cnt = #groups + + local result = {} + for i = 1, g_cnt do + result[groups[i]] = {} + end + if include_no_group then + result["NO_GROUP"] = {} + end + local in_group = false + + for name, def in pairs(minetest.registered_items) do + in_group = false + for i = 1, g_cnt do + local grp = groups[i] + if def.groups[grp] ~= nil then + result[grp][#result[grp]+1] = name + in_group = true + if allow_duplicates == false then + break + end + end + end + if include_no_group and in_group == false then + result["NO_GROUP"][#result["NO_GROUP"]+1] = name + end + end + + return result +end + +function exchangeclone.play_ability_sound(player, base_pitch) + if not player then return end + if not base_pitch then base_pitch = 1 end + local new_pitch = base_pitch + (math.random(-100, 100) / 500) + minetest.sound_play("exchangeclone_ability", {pitch = new_pitch, pos = player:get_pos(), max_hear_distance = 20, }) +end + +function exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) + if pointed_thing.type ~= "node" then return false end + if player:get_player_control().sneak then return false end + local node = minetest.get_node(pointed_thing.under) + if player and not player:get_player_control().sneak then + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then + return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, player, itemstack) or itemstack + end + end + return false +end + +function exchangeclone.range_update(itemstack, player, max) + if not max then max = 4 end + local range = tonumber(itemstack:get_meta():get_int("exchangeclone_item_range")) + if player:get_player_control().sneak then + if range == 0 then + range = max + else + range = range - 1 + end + else + if range == max then + range = 0 + else + range = range + 1 + end + end + minetest.chat_send_player(player:get_player_name(), "Current Range: "..range) + itemstack:get_meta():set_int("exchangeclone_item_range", range) + return itemstack +end + + +exchangeclone.wield_scale = {x=1,y=1,z=1} +if exchangeclone.mineclone then + exchangeclone.wield_scale = mcl_vars.tool_wield_scale +end + +exchangeclone.diamond_itemstring = "default:diamond" +if exchangeclone.mineclone then + exchangeclone.diamond_itemstring = "mcl_core:diamond" +end + +local doTileDrops = minetest.settings:get_bool("mcl_doTileDrops", true) + +function exchangeclone.drop_items_on_player(pos, drops, player) --copied from MineClone's code + if not exchangeclone.mineclone then + return minetest.handle_node_drops(pos, drops, player) + end + -- NOTE: This function override allows player to be nil. + -- This means there is no player. This is a special case which allows this function to be called + -- by hand. Creative Mode is intentionally ignored in this case. + if player and player:is_player() and minetest.is_creative_enabled(player:get_player_name()) then + local inv = player:get_inventory() + if inv then + for _, item in ipairs(drops) do + if not inv:contains_item("main", item, true) then + inv:add_item("main", item) + end + end + end + return + elseif not doTileDrops then return end + + -- Check if node will yield its useful drop by the player's tool + local dug_node = minetest.get_node(pos) + local tooldef + local tool + if player then + tool = player:get_wielded_item() + tooldef = minetest.registered_items[tool:get_name()] + + if not mcl_autogroup.can_harvest(dug_node.name, tool:get_name(), player) then + return + end + end + + local diggroups = tooldef and tooldef._mcl_diggroups + local shearsy_level = diggroups and diggroups.shearsy and diggroups.shearsy.level + + --[[ Special node drops when dug by shears by reading _mcl_shears_drop or with a silk touch tool reading _mcl_silk_touch_drop + from the node definition. + Definition of _mcl_shears_drop / _mcl_silk_touch_drop: + * true: Drop itself when dug by shears / silk touch tool + * table: Drop every itemstring in this table when dug by shears _mcl_silk_touch_drop + ]] + + local enchantments = tool and mcl_enchanting.get_enchantments(tool) + + local silk_touch_drop = false + local nodedef = minetest.registered_nodes[dug_node.name] + if not nodedef then return end + + if shearsy_level and shearsy_level > 0 and nodedef._mcl_shears_drop then + if nodedef._mcl_shears_drop == true then + drops = { dug_node.name } + else + drops = nodedef._mcl_shears_drop + end + elseif tool and enchantments.silk_touch and nodedef._mcl_silk_touch_drop then + silk_touch_drop = true + if nodedef._mcl_silk_touch_drop == true then + drops = { dug_node.name } + else + drops = nodedef._mcl_silk_touch_drop + end + end + + -- if tool and nodedef._mcl_fortune_drop and enchantments.fortune then + -- local fortune_level = enchantments.fortune + -- local fortune_drop = nodedef._mcl_fortune_drop + -- if fortune_drop.discrete_uniform_distribution then + -- local min_count = fortune_drop.min_count + -- local max_count = fortune_drop.max_count + fortune_level * (fortune_drop.factor or 1) + -- local chance = fortune_drop.chance or fortune_drop.get_chance and fortune_drop.get_chance(fortune_level) + -- if not chance or math.random() < chance then + -- drops = discrete_uniform_distribution(fortune_drop.multiply and drops or fortune_drop.items, min_count, max_count, + -- fortune_drop.cap) + -- elseif fortune_drop.override then + -- drops = {} + -- end + -- else + -- -- Fixed Behavior + -- local drop = get_fortune_drops(fortune_drop, fortune_level) + -- drops = get_drops(drop, tool:get_name(), dug_node.param2, nodedef.paramtype2) + -- end + -- end + + if player and mcl_experience.throw_xp and not silk_touch_drop then + local experience_amount = minetest.get_item_group(dug_node.name, "xp") + if experience_amount > 0 then + mcl_experience.throw_xp(pos, experience_amount) + end + end + + for _, item in ipairs(drops) do + local count + if type(item) == "string" then + count = ItemStack(item):get_count() + else + count = item:get_count() + end + local drop_item = ItemStack(item) + drop_item:set_count(1) + for i = 1, count do + -- Spawn item + local obj = minetest.add_item(player:get_pos(), drop_item) + if obj then + -- set the velocity multiplier to the stored amount or if the game dug this node, apply a bigger velocity + obj:get_luaentity().age = 0.65 + obj:get_luaentity()._insta_collect = true + end + end + end +end + +function exchangeclone.get_face_direction(player) + local h_look = player:get_look_horizontal() + local v_look = player:get_look_vertical() + + local result = {x = 0, y = 0, z = 0} + + if h_look <= math.pi / 4 or h_look >= (7*math.pi)/4 then + result.z = 1 + elseif h_look > math.pi / 4 and h_look <= (3*math.pi)/4 then + result.x = -1 + elseif h_look > (3*math.pi)/4 and h_look <= (5*math.pi)/4 then + result.z = -1 + else + result.x = 1 + end + + if v_look < -1 then + result.y = 1 + elseif v_look > 1 then + result.y = -1 + end + + return result +end \ No newline at end of file diff --git a/mod.conf b/mod.conf index 23a3066..8e7a254 100644 --- a/mod.conf +++ b/mod.conf @@ -2,5 +2,5 @@ name = exchangeclone title = ExchangeClone description = Exchange nodes into other nodes min_minetest_version = 5.5 -optional_depends = mcl_core, default, moreswords, mcl_stairs, pipeworks, meat_blocks, ghost_blocks, sticky_things, fake_liquids, sound_machine, stairs, mcl_dispensers +optional_depends = mcl_core, default, moreswords, mcl_stairs, pipeworks, meat_blocks, ghost_blocks, sticky_things, fake_liquids, sound_machine, stairs, mcl_dispensers, farming author = ThePython10110 \ No newline at end of file diff --git a/orb.lua b/orb.lua index 13643d5..b8b897b 100644 --- a/orb.lua +++ b/orb.lua @@ -1,34 +1,21 @@ -function exchangeclone.read_orb_charge(itemstack, user, pointed_thing) +local function read_orb_charge(itemstack, player, pointed_thing) + local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) + if click_test ~= false then + return click_test + end + local stored = itemstack:get_meta():get_float("stored_charge") or 0 - minetest.chat_send_player(user:get_player_name(), "Current Charge: "..stored) + minetest.chat_send_player(player:get_player_name(), "Current Charge: "..stored) return itemstack end -function exchangeclone.get_orb_energy(inventory, listname, index) - if not inventory then return end - if not listname then listname = "main" end - if not index then index = 1 end - local itemstack = inventory:get_stack(listname, index) - if not itemstack then return end - return itemstack:get_meta():get_float("stored_energy") -end - -function exchangeclone.set_orb_energy(inventory, listname, index, amount) - if (not inventory) or (not amount) or (amount < 0) then return end - if not listname then listname = "main" end - if not index then index = 1 end - local itemstack = inventory:get_stack(listname, index) - if not itemstack then return end - itemstack:get_meta():set_float("stored_energy", amount) - itemstack:get_meta():set_string("description", "Exchange Orb\nCurrent Charge: "..amount) - inventory:set_stack(listname, index, itemstack) -end - minetest.register_tool("exchangeclone:exchange_orb", { description = "Exchange Orb\nCurrent Charge: 0", inventory_image = "exchangeclone_exchange_orb.png", --energy_value = 33792, - on_use = exchangeclone.read_orb_charge, + on_secondary_use = read_orb_charge, + on_place = read_orb_charge, + groups = {exchange_orb = 1, disable_repair = 1} }) local recipe_item_1 = "default:steel_ingot" diff --git a/pesa.lua b/pesa.lua index 3bf6d85..e55401b 100644 --- a/pesa.lua +++ b/pesa.lua @@ -26,21 +26,18 @@ else end formspec = table.concat(formspec, "") -local function on_rightclick(itemstack, user, pointed_thing) - if pointed_thing.type == "node" then - -- Use pointed node's on_rightclick function first, if present - local node = minetest.get_node(pointed_thing.under) - if user and not user:get_player_control().sneak then - if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then - return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack - end - end +local function on_rightclick(itemstack, player, pointed_thing) + local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) + if click_test ~= false then + return click_test end - minetest.show_formspec(user:get_player_name(), "exchangeclone_pesa", formspec) + minetest.show_formspec(player:get_player_name(), "exchangeclone_pesa", formspec) end minetest.register_tool("exchangeclone:pesa", { description = "Personal Energy Storage Accessor (PESA)", + wield_image = "exchangeclone_pesa.png", + inventory_image = "exchangeclone_pesa.png", on_secondary_use = on_rightclick, on_place = on_rightclick, }) @@ -69,10 +66,17 @@ minetest.register_allow_player_inventory_action(function(player, action, inv, in end end) -function exchangeclone.get_player_energy(player) - return exchangeclone.get_orb_energy(player:get_inventory(), "exchangeclone_pesa", 1) +local chest_itemstring = "default:chest" +if exchangeclone.mineclone then + chest_itemstring = "mcl_chests:chest" end -function exchangeclone.set_player_energy(player, amount) - exchangeclone.set_orb_energy(player:get_inventory(), "exchangeclone_pesa", 1, amount) -end \ No newline at end of file +minetest.register_craft({ + output = "exchangeclone:pesa", + type = "shapeless", + recipe = { + "exchangeclone:philosophers_stone", + chest_itemstring + }, + replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}} +}) \ No newline at end of file diff --git a/philosophers_stone.lua b/philosophers_stone.lua index 8b5353a..bb18484 100644 --- a/philosophers_stone.lua +++ b/philosophers_stone.lua @@ -1,33 +1,10 @@ local function show_enchanting(player) local player_meta = player:get_meta() - player_meta:set_int("mcl_enchanting:num_bookshelves", 8) + player_meta:set_int("mcl_enchanting:num_bookshelves", 8) -- 15 for max enchantments player_meta:set_string("mcl_enchanting:table_name", "Enchanting Table") mcl_enchanting.show_enchanting_formspec(player) end -local function call_on_rightclick(itemstack, player, pointed_thing) - -- Call on_rightclick if the pointed node defines it - if pointed_thing and pointed_thing.type == "node" then - local pos = pointed_thing.under - local node = minetest.get_node(pos) - if player and not player:get_player_control().sneak then - local nodedef = minetest.registered_nodes[node.name] - local on_rightclick = nodedef and nodedef.on_rightclick - if on_rightclick then - return on_rightclick(pos, node, player, itemstack, pointed_thing) or itemstack - end - end - end -end - -local function round(num) - if num % 1 < 0.5 then - return math.floor(num) - else - return math.ceil(num) - end -end - exchangeclone.node_transmutations = { { --use ["mcl_core:stone"] = "mcl_core:cobble", @@ -215,11 +192,12 @@ exchangeclone.node_transmutations = { } } -function exchangeclone.transmute_nodes(player, distance, mode) - local pos = player:get_pos() - pos.x = round(pos.x) +local function transmute_nodes(player, center, distance, mode) + exchangeclone.play_ability_sound(player) + local pos = center + pos.x = exchangeclone.round(pos.x) pos.y = math.floor(pos.y) --make sure y is node BELOW player's feet - pos.z = round(pos.z) + pos.z = exchangeclone.round(pos.z) for x = pos.x-distance, pos.x+distance do for y = pos.y-distance, pos.y+distance do for z = pos.z-distance, pos.z+distance do @@ -242,39 +220,35 @@ function exchangeclone.transmute_nodes(player, distance, mode) end end -local function on_left_click(itemstack, player, pointed_thing) - if player:get_player_control().sneak then - local range = tonumber(itemstack:get_meta():get_int("exchangeclone_item_range")) - if range == 0 then range = 5 end - range = range - 1 - itemstack:get_meta():set_int("exchangeclone_item_range", range or 0) - minetest.chat_send_player(player:get_player_name(), "Current Range: "..range) - return itemstack - elseif not player:get_player_control().aux1 then - local new_stack = call_on_rightclick(itemstack, player, pointed_thing) - if new_stack then - return new_stack +local on_left_click = nil +if exchangeclone.mineclone then + on_left_click = function(itemstack, player, pointed_thing) + if player:get_player_control().sneak then + show_enchanting(player) + else + mcl_crafting_table.show_crafting_form(player) end - local range = itemstack:get_meta():get_int("exchangeclone_item_range") - if range == 4 then range = -1 end - range = range + 1 - itemstack:get_meta():set_int("exchangeclone_item_range", range or 0) - minetest.chat_send_player(player:get_player_name(), "Current Range: "..range) - return itemstack - elseif exchangeclone.mineclone then - show_enchanting(player) end end local function on_right_click(itemstack, player, pointed_thing) + local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) + if click_test ~= false then + return click_test + end + if player:get_player_control().aux1 then + return exchangeclone.range_update(itemstack, player) + end + local center = player:get_pos() + if pointed_thing and pointed_thing.type == "node" then + center = pointed_thing.under + end if player:get_player_control().sneak then local range = tonumber(itemstack:get_meta():get_int("exchangeclone_item_range")) - exchangeclone.transmute_nodes(player, range, 2) - elseif not player:get_player_control().aux1 then + transmute_nodes(player, center, range, 2) + else local range = itemstack:get_meta():get_int("exchangeclone_item_range") - exchangeclone.transmute_nodes(player, range, 1) - elseif exchangeclone.mineclone then - mcl_crafting_table.show_crafting_form(player) + transmute_nodes(player, center, range, 1) end end @@ -286,24 +260,24 @@ if exchangeclone.mineclone then end local longdesc = "A mysterious device discovered by alchemists millenia ago. The crafting recipe was recently rediscovered by ThePython.\n\n".. - "It has the ability to transmute nearby blocks into other blocks. The range can be increased or decreased from 0 to 4 by (shift-)clicking.\n".. + "It has the ability to transmute nearby blocks into other blocks. The range can be increased or decreased from 0 to 4 by (shift-)aux1-right-clicking.\n".. "Transmute blocks by (shift-)right-clicking (holding shift causes a few differences in transmutation). They are changed in a cube centered on ".. "the block directly below you, with a radius equal to the range.\n".. "The ancient tome (entitled the \"Tekkit Wiki\") vaguely mentioned a \"cooldown\" when used to transmute large areas, ".. - "but ThePython was far to lazy to implement such a thing.\n\n".. + "but ThePython was far to lazy to implement such a thing (maybe just have the charge level/radius reset every time?).\n\n".. "The Philosopher's Stone is also useful in converting various resources, such as turning coal into iron, or gold into "..item1..".\n".. "See the crafting guide for recipes. The Philosopher's Stone is NEVER used up in crafting recipes (if it is, it's a bug). The transmutation ".. "range is reset when used in a crafting recipe." -local usagehelp = "The range can be increased or decreased from 0 to 4 by (shift-)clicking. Transmute blocks by (shift-)right-clicking (holding shift causes a few differences in transmutation). They are changed in a cube centered on ".. +local usagehelp = "The range can be increased or decreased from 0 to 4 by (shift-)aux1-right-clicking. Transmute blocks by (shift-)right-clicking (holding shift causes a few differences in transmutation). They are changed in a cube centered on ".. "the block directly below you, with a radius equal to the range.\n\n".. "The Philosopher's Stone is also useful in converting various resources, such as turning coal into iron, or gold into "..item1..".\n".. "See the crafting guide for recipes. The Philosopher's Stone is NEVER used up in crafting recipes (if it is, it's a bug). The transmutation ".. "range is reset when used in a crafting recipe." if exchangeclone.mineclone then - tt_help = tt_help.."\nAux1+click: enchanting table. Aux1+right-click: crafting table." - local extra_stuff = "\n\nIn MineClone, Aux1+right-click opens a 3x3 crafting table and Aux1+left-click opens an enchanting table (the equivalent of a real ".. + tt_help = tt_help.."\nClick: crafting table. Shift-click: enchanting table." + local extra_stuff = "\n\nIn MineClone, clicking opens a 3x3 crafting table and shift+clicking opens an enchanting table (the equivalent of a real ".. "enchanting table with eight bookshelves around it)." longdesc = longdesc..extra_stuff usagehelp = usagehelp..extra_stuff @@ -320,6 +294,7 @@ minetest.register_tool("exchangeclone:philosophers_stone", { on_use = on_left_click, on_place = on_right_click, on_secondary_use = on_right_click, + groups = {philosophers_stone = 1, disable_repair = 1} }) local diamond = "default:diamond" @@ -702,31 +677,33 @@ minetest.register_craft({ replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}} }) -minetest.register_craft({ - output = "exchangeclone:alchemical_coal", - type = "shapeless", - recipe = { - "exchangeclone:philosophers_stone", - "mcl_core:coal_lump", - "mcl_core:coal_lump", - "mcl_core:coal_lump", - "mcl_core:coal_lump", - }, - replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}} -}) - -minetest.register_craft({ - output = "exchangeclone:alchemical_coal", - type = "shapeless", - recipe = { - "exchangeclone:philosophers_stone", - "default:coal_lump", - "default:coal_lump", - "default:coal_lump", - "default:coal_lump", - }, - replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}} -}) +if exchangeclone.mineclone then -- no idea why both recipes show up in the craft guide, so added if/else + minetest.register_craft({ + output = "exchangeclone:alchemical_coal", + type = "shapeless", + recipe = { + "exchangeclone:philosophers_stone", + "mcl_core:coal_lump", + "mcl_core:coal_lump", + "mcl_core:coal_lump", + "mcl_core:coal_lump", + }, + replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}} + }) +else + minetest.register_craft({ + output = "exchangeclone:alchemical_coal", + type = "shapeless", + recipe = { + "exchangeclone:philosophers_stone", + "default:coal_lump", + "default:coal_lump", + "default:coal_lump", + "default:coal_lump", + }, + replacements = {{"exchangeclone:philosophers_stone", "exchangeclone:philosophers_stone"}} + }) +end minetest.register_craft({ output = "default:coal_lump 4", diff --git a/pickaxes.lua b/pickaxes.lua new file mode 100644 index 0000000..85ef6b9 --- /dev/null +++ b/pickaxes.lua @@ -0,0 +1,287 @@ +local players_digging = {} + +local function mine_vein(player, start_pos, node_name, pos) + -- Not very efficient, but it SHOULD work. + if not player then return 0 end + if not start_pos then return 0 end + if not pos then pos = start_pos end + local node = minetest.get_node(pos) + if not node_name then node_name = node.name end + local distance = vector.distance(pos, start_pos) + if distance > 10 then return 0 end + if node_name == node.name then + local energy_cost = 0 + exchangeclone.drop_items_on_player(pos, minetest.get_node_drops(node.name, "exchangeclone:red_matter_pickaxe"), player) + 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 + local cost = mine_vein(player, start_pos, node_name, {x=x,y=y,z=z}) + if cost and cost > 0 then + energy_cost = energy_cost + cost + end + end end end + return energy_cost + end + return 0 +end + +local function pickaxe_on_use(itemstack, player, pointed_thing) + local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) + if click_test ~= false then + return click_test + end + + if player:get_player_control().sneak then + local current_name = itemstack:get_name() + local meta = itemstack:get_meta() + local current_mode = itemstack:get_meta():get_string("exchangeclone_pick_mode") + if current_mode == "" or not current_mode then current_mode = "1x1" end + if current_mode == "1x1" then + itemstack:set_name(current_name.."_3x1") -- set to 3x1 pick + meta:set_string("exchangeclone_pick_mode", "tall") + minetest.chat_send_player(player:get_player_name(), "3x1 tall mode") + elseif current_mode == "tall" then + meta:set_string("exchangeclone_pick_mode", "wide") + minetest.chat_send_player(player:get_player_name(), "3x1 wide mode") + elseif current_mode == "wide" then + meta:set_string("exchangeclone_pick_mode", "long") + minetest.chat_send_player(player:get_player_name(), "3x1 long mode") + elseif current_mode == "long" then + itemstack:set_name(string.sub(current_name, 1, -5)) -- set to 1x1 pick + meta:set_string("exchangeclone_pick_mode", "1x1") + minetest.chat_send_player(player:get_player_name(), "Single block mode") + end + return itemstack + end + + if pointed_thing.type == "node" + and (minetest.get_item_group(minetest.get_node(pointed_thing.under).name, "exchangeclone_ore") > 0) then + local player_energy = exchangeclone.get_player_energy(player) + players_digging[player:get_player_name()] = true + local energy_cost = mine_vein(player, pointed_thing.under) + players_digging[player:get_player_name()] = nil + if energy_cost then + exchangeclone.set_player_energy(player, player_energy - energy_cost) + 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") then + local groups = table.copy(def.groups) + groups.exchangeclone_ore = 1 + minetest.override_item(name, {groups = groups}) + end +end + +minetest.register_tool("exchangeclone:dark_matter_pickaxe", { + description = "Dark Matter Pickaxe", + wield_image = "exchangeclone_dark_matter_pickaxe.png", + inventory_image = "exchangeclone_dark_matter_pickaxe.png", + exchangeclone_pick_mode = "1x1", + groups = { tool=1, pickaxe=1, dig_speed_class=7, enchantability=0, dark_matter_pickaxe=1 }, + wield_scale = exchangeclone.wield_scale, + tool_capabilities = { + -- 1/1.2 + full_punch_interval = 0.5, + max_drop_level=5, + damage_groups = {fleshy=7}, + punch_attack_uses = 0, + groupcaps={ + cracky = {times={[1]=1.5, [2]=0.75, [3]=0.325}, uses=0, maxlevel=4}, + }, + }, + sound = { breaks = "default_tool_breaks" }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 16, level = 7, uses = 0 } + }, + on_secondary_use = pickaxe_on_use, + on_place = pickaxe_on_use, +}) + +minetest.register_tool("exchangeclone:dark_matter_pickaxe_3x1", { + description = "Dark Matter Pickaxe", + wield_image = "exchangeclone_dark_matter_pickaxe.png", + inventory_image = "exchangeclone_dark_matter_pickaxe.png", + exchangeclone_pick_mode = "tall", + groups = { tool=1, pickaxe=1, dig_speed_class=7, enchantability=0, dark_matter_pickaxe=1, not_in_creative_inventory=1 }, + wield_scale = exchangeclone.wield_scale, + tool_capabilities = { + -- 1/1.2 + full_punch_interval = 0.5, + max_drop_level=5, + damage_groups = {fleshy=7}, + punch_attack_uses = 0, + groupcaps={ + cracky = {times={[1]=1.8, [2]=0.9, [3]=0.5}, uses=0, maxlevel=4}, + }, + }, + sound = { breaks = "default_tool_breaks" }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 12, level = 7, uses = 0 } + }, + on_secondary_use = pickaxe_on_use, + on_place = pickaxe_on_use, +}) + +minetest.register_tool("exchangeclone:red_matter_pickaxe", { + description = "Red Matter Pickaxe", + wield_image = "exchangeclone_red_matter_pickaxe.png", + inventory_image = "exchangeclone_red_matter_pickaxe.png", + exchangeclone_pick_mode = "1x1", + groups = { tool=1, pickaxe=1, dig_speed_class=7, red_matter_pickaxe=1, enchantability=0 }, + wield_scale = exchangeclone.wield_scale, + tool_capabilities = { + -- 1/1.2 + full_punch_interval = 0.5, + max_drop_level=5, + damage_groups = {fleshy=9}, + punch_attack_uses = 0, + groupcaps={ + cracky = {times={[1]=1, [2]=0.5, [3]=0.25}, uses=0, maxlevel=5}, + }, + }, + sound = { breaks = "default_tool_breaks" }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 20, level = 8, uses = 0 } + }, + on_secondary_use = pickaxe_on_use, + on_place = pickaxe_on_use, +}) + +minetest.register_tool("exchangeclone:red_matter_pickaxe_3x1", { + description = "Red Matter Pickaxe", + wield_image = "exchangeclone_red_matter_pickaxe.png", + inventory_image = "exchangeclone_red_matter_pickaxe.png", + exchangeclone_pick_mode = "tall", + groups = { tool=1, pickaxe=1, dig_speed_class=7, enchantability=0, red_matter_pickaxe=1, not_in_creative_inventory=1 }, + wield_scale = exchangeclone.wield_scale, + tool_capabilities = { + -- 1/1.2 + full_punch_interval = 0.5, + max_drop_level=5, + damage_groups = {fleshy=9}, + punch_attack_uses = 0, + groupcaps={ + cracky = {times={[1]=1.2, [2]=0.7, [3]=0.4}, uses=0, maxlevel=5}, + }, + }, + sound = { breaks = "default_tool_breaks" }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 20, level = 8, uses = 0 } + }, + on_secondary_use = pickaxe_on_use, + on_place = pickaxe_on_use, +}) + +-- adapted from https://github.com/cultom/hammermod/blob/master/init.lua + +local stone_group = "cracky" +if exchangeclone.mineclone then + stone_group = "pickaxey" +end + +local function dig_if_stone(pos, player) + local node = minetest.get_node(pos) + if minetest.get_item_group(node.name, stone_group) ~= 0 then + minetest.node_dig(pos, minetest.get_node(pos), player) + end +end + +minetest.register_on_dignode( + function(pos, oldnode, player) + if player == nil or (player:get_wielded_item():get_name() ~= "exchangeclone:dark_matter_pickaxe_3x1" + and player:get_wielded_item():get_name() ~= "exchangeclone:red_matter_pickaxe_3x1") then + return + end + local playerName = player:get_player_name() + if (playerName == "" or players_digging[playerName]) then + return + end + players_digging[playerName] = true + + local current_mode = player:get_wielded_item():get_meta():get_string("exchangeclone_pick_mode") + if current_mode == "" or not current_mode then current_mode = "tall" end + + local player_rotation = exchangeclone.get_face_direction(player) + + local new_pos = table.copy(pos) + + if current_mode == "long" then + if player_rotation.y ~= 0 then + new_pos.y = new_pos.y + player_rotation.y + dig_if_stone(new_pos, player) + new_pos.y = new_pos.y + player_rotation.y + dig_if_stone(new_pos, player) + elseif player_rotation.z ~= 0 then + new_pos.z = new_pos.z + player_rotation.z + dig_if_stone(new_pos, player) + new_pos.z = new_pos.z + player_rotation.z + dig_if_stone(new_pos, player) + else + new_pos.x = new_pos.x + player_rotation.x + dig_if_stone(new_pos, player) + new_pos.x = new_pos.x + player_rotation.x + dig_if_stone(new_pos, player) + end + elseif current_mode == "tall" then + if player_rotation.y ~= 0 then + if player_rotation.x ~= 0 then + new_pos.x = pos.x - 1 + dig_if_stone(new_pos, player) + new_pos.x = pos.x + 1 + dig_if_stone(new_pos, player) + else + new_pos.z = pos.z - 1 + dig_if_stone(new_pos, player) + new_pos.z = pos.z + 1 + dig_if_stone(new_pos, player) + end + else + new_pos.y = pos.y - 1 + dig_if_stone(new_pos, player) + new_pos.y = pos.y + 1 + dig_if_stone(new_pos, player) + end + elseif current_mode == "wide" then + if player_rotation.x ~= 0 then + new_pos.z = pos.z - 1 + dig_if_stone(new_pos, player) + new_pos.z = pos.z + 1 + dig_if_stone(new_pos, player) + else + new_pos.x = pos.x - 1 + dig_if_stone(new_pos, player) + new_pos.x = pos.x + 1 + dig_if_stone(new_pos, player) + end + end + + players_digging[playerName] = nil + end +) + +-- end copied code + +minetest.register_craft({ + output = "exchangeclone:dark_matter_pickaxe", + recipe = { + {"exchangeclone:dark_matter", "exchangeclone:dark_matter", "exchangeclone:dark_matter"}, + {"", exchangeclone.diamond_itemstring, ""}, + {"", exchangeclone.diamond_itemstring, ""} + } +}) + +minetest.register_craft({ + output = "exchangeclone:red_matter_pickaxe", + recipe = { + {"exchangeclone:red_matter", "exchangeclone:red_matter", "exchangeclone:red_matter"}, + {"", "group:dark_matter_pickaxe", ""}, + {"", "exchangeclone:dark_matter", ""} + } +}) \ No newline at end of file diff --git a/shears.lua b/shears.lua index 974f794..098ecb6 100644 --- a/shears.lua +++ b/shears.lua @@ -1,114 +1,85 @@ ---[[ - Yes, shears need an entire file... it's a huge amount of code. - They were originally with the other tools, but the code just - got too long. -]] - -local function round(num) - if num % 1 < 0.5 then - return math.floor(num) - else - return math.ceil(num) - end -end - -local shear_cube = function(player, distance) +local shear_cube = function(player, center, distance) + exchangeclone.play_ability_sound(player) local player_pos = player:get_pos() - local pos = {} + local pos = center local node_positions = {} - pos.x = round(player_pos.x) - pos.y = math.floor(player_pos.y) --make sure y is node BELOW player's feet - pos.z = round(player_pos.z) + local player_energy = exchangeclone.get_player_energy(player) + local energy_cost = 0 + pos.x = exchangeclone.round(pos.x) + pos.y = math.floor(pos.y) --make sure y is node BELOW player's feet + pos.z = exchangeclone.round(pos.z) for x = pos.x-distance, pos.x+distance do + if energy_cost + 8 > player_energy then + break + end for y = pos.y-distance, pos.y+distance do + if energy_cost + 8 > player_energy then + break + end for z = pos.z-distance, pos.z+distance do + if energy_cost + 8 > player_energy then + break + end local new_pos = {x=x,y=y,z=z} local node = minetest.get_node(new_pos) or "air" local node_def = minetest.registered_items[node.name] - if node_def.groups.shearsy or node_def.groups.shearsy_cobweb then + if (node_def.groups.shearsy or node_def.groups.shearsy_cobweb) and node.name ~= "mcl_flowers:double_grass_top" then if minetest.is_protected(new_pos, player:get_player_name()) then minetest.record_protection_violation(new_pos, player:get_player_name()) else - local drop_name = node.name - if node_def._mcl_shears_drop and not node_def._mcl_shears_drop == true then - drop_name = node_def._mcl_shears_drop - end - node_positions[#node_positions + 1] = {pos = new_pos, name = drop_name} + energy_cost = energy_cost + 8 + local drops = minetest.get_node_drops(node.name, "exchangeclone:red_matter_shears") + exchangeclone.drop_items_on_player(new_pos, drops, player) + minetest.set_node(new_pos, {name = "air"}) end end end end end - minetest.log(dump(node_positions)) - local player_energy = exchangeclone.get_player_energy(player) - local energy_cost = 0 - for _, data in ipairs(node_positions) do - if energy_cost + 16 > player_energy then - break - end - energy_cost = energy_cost + 16 - minetest.set_node(data.pos, {name = "air"}) - minetest.add_item(player_pos, data.name) - end exchangeclone.set_player_energy(player, player_energy - energy_cost) end local shears_rightclick = function(itemstack, player, pointed_thing) -- Use pointed node's on_rightclick function first, if present - local node - if pointed_thing and pointed_thing.under then - node = minetest.get_node(pointed_thing.under) - if player and not player:get_player_control().sneak then - if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then - return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, player, itemstack) or itemstack - end - end + local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) + if click_test ~= false then + return click_test end if player:get_player_control().aux1 then - local range = tonumber(itemstack:get_meta():get_int("exchangeclone_item_range")) - if player:get_player_control().sneak then - if range == 0 then - range = 4 - else - range = range - 1 - end - end - if range == 4 then - range = 0 + if itemstack:get_name():find("dark") then + return exchangeclone.range_update(itemstack, player, 3) else - range = range + 1 + return exchangeclone.range_update(itemstack, player, 4) end - minetest.chat_send_player(player:get_player_name(), "Current Range: "..range) - itemstack:get_meta():set_int("exchangeclone_item_range", range) - return itemstack end - if player:get_player_control().sneak or not (pointed_thing and pointed_thing.above) then - local range = tonumber(itemstack:get_meta():get_int("exchangeclone_item_range")) - shear_cube(player, range) - return itemstack + if (pointed_thing.type == "node") and pointed_thing.above and not player:get_player_control().sneak then + local node = minetest.get_node(pointed_thing.under) + if node.name == "mcl_farming:pumpkin" and (pointed_thing.above.y ~= pointed_thing.under.y) then + minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true) + local dir = vector.subtract(pointed_thing.under, pointed_thing.above) + local param2 = minetest.dir_to_facedir(dir) + minetest.set_node(pointed_thing.under, {name="mcl_farming:pumpkin_face", param2 = param2}) + minetest.add_item(pointed_thing.above, "mcl_farming:pumpkin_seeds 4") + end end - if not (pointed_thing and pointed_thing.above) then return itemstack end + local center = player:get_pos() - -- Only carve pumpkin if used on side - if pointed_thing.above.y ~= pointed_thing.under.y then - return - end - if node.name == "mcl_farming:pumpkin" then - minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true) - local dir = vector.subtract(pointed_thing.under, pointed_thing.above) - local param2 = minetest.dir_to_facedir(dir) - minetest.set_node(pointed_thing.under, {name="mcl_farming:pumpkin_face", param2 = param2}) - minetest.add_item(pointed_thing.above, "mcl_farming:pumpkin_seeds 4") + if (pointed_thing.type == "node") and pointed_thing.under then + center = pointed_thing.under end + local range = tonumber(itemstack:get_meta():get_int("exchangeclone_item_range")) + shear_cube(player, center, range) return itemstack end minetest.register_tool("exchangeclone:dark_matter_shears", { - description = "Dark Matter Shears\nImage coming soon.", + description = "Dark Matter Shears", + wield_image = "exchangeclone_dark_matter_shears.png", + inventory_image = "exchangeclone_dark_matter_shears.png", stack_max = 1, groups = { tool=1, shears=1, dig_speed_class=7, }, tool_capabilities = { @@ -128,7 +99,9 @@ minetest.register_tool("exchangeclone:dark_matter_shears", { }) minetest.register_tool("exchangeclone:red_matter_shears", { - description = "Red Matter Shears\nImage coming soon.", + description = "Red Matter Shears", + wield_image = "exchangeclone_red_matter_shears.png", + inventory_image = "exchangeclone_red_matter_shears.png", stack_max = 1, groups = { tool=1, shears=1, dig_speed_class=8, }, tool_capabilities = { @@ -450,16 +423,18 @@ minetest.registered_entities["mobs_mc:snowman"].on_rightclick = function(self, c end end - -local diamond_itemstring = "default:diamond" -if exchangeclone.mineclone then - diamond_itemstring = "mcl_core:diamond" -end - minetest.register_craft({ output = "exchangeclone:dark_matter_shears", recipe = { {"", "exchangeclone:dark_matter"}, - {diamond_itemstring, ""}, + {exchangeclone.diamond_itemstring, ""}, + } +}) + +minetest.register_craft({ + output = "exchangeclone:red_matter_shears", + recipe = { + {"", "exchangeclone:red_matter"}, + {"exchangeclone:dark_matter_shears", ""}, } }) \ No newline at end of file diff --git a/sounds/exchangeclone_ability.ogg b/sounds/exchangeclone_ability.ogg new file mode 100644 index 0000000..3730f8b Binary files /dev/null and b/sounds/exchangeclone_ability.ogg differ diff --git a/swords.lua b/swords.lua index 4b4af5f..c3c0e89 100644 --- a/swords.lua +++ b/swords.lua @@ -1,11 +1,4 @@ -local wield_scale -if exchangeclone.mineclone then - local wield_scale = mcl_vars.tool_wield_scale -else - local wield_scale = {x=1,y=1,z=1} -end - -local aoe_exclude = { --any entity not beginning with "mobs_mc:" is automatically added to this list. +local aoe_exclude = { --any entity not including "mobs" is automatically added to this list. ["mobs_mc:spider_eyes"] = true, ["mobs_mc:wither_skull"] = true, ["mobs_mc:fireball"] = true, @@ -56,7 +49,7 @@ local hostile_mobs = { --for Red Matter Sword minetest.register_on_mods_loaded(function() for name, def in pairs(minetest.registered_entities) do - if not name:find("mobs_mc:") then + if not name:find("mobs") then aoe_exclude[name] = true end end @@ -73,14 +66,10 @@ local sword_aoe = function(info) return function(itemstack, player, pointed_thing) --copied from MineClone's TNT; I would simply use the explosion function but it would hurt the player. -- Use pointed node's on_rightclick function first, if present - if pointed_thing and pointed_thing.under then - local node = minetest.get_node(pointed_thing.under) - if player and not player:get_player_control().sneak then - if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then - return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, player, itemstack) or itemstack - end - end - end + local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing) + if click_test ~= false then + return click_test + end local player_energy = exchangeclone.get_player_energy(player) if player_energy >= 384 then @@ -89,6 +78,8 @@ local sword_aoe = function(info) return end + exchangeclone.play_ability_sound(player) + local pos = player:get_pos() -- Entities in radius of explosion @@ -172,14 +163,16 @@ local red_matter_sword_action = function(itemstack, player, pointed_thing) return itemstack end - local aoe_function = sword_aoe({max_damage = 15, knockback = 20, radius = 7, damage_all = damage_all}) + local aoe_function = sword_aoe({max_damage = 12, knockback = 20, radius = 7, damage_all = damage_all}) aoe_function(itemstack, player, pointed_thing) end -minetest.register_tool("exchangeclone:sword_dark_matter", { - description = "Dark Matter Sword\nImage coming soon.", +minetest.register_tool("exchangeclone:dark_matter_sword", { + description = "Dark Matter Sword", + wield_image = "exchangeclone_dark_matter_sword.png", + inventory_image = "exchangeclone_dark_matter_sword.png", groups = { tool=1, sword=1, dig_speed_class=7, enchantability=0 }, - wield_scale = wield_scale, + wield_scale = exchangeclone.wield_scale, tool_capabilities = { -- 1/1.2 full_punch_interval = 0.25, @@ -190,8 +183,8 @@ minetest.register_tool("exchangeclone:sword_dark_matter", { snappy = {times={[1]=0.95, [2]=0.45, [3]=0.15}, uses=0, maxlevel=4}, }, }, - on_secondary_use = sword_aoe({max_damage = 11, knockback = 12, radius = 5}), - on_place = sword_aoe({max_damage = 11, knockback = 12, radius = 5}), + on_secondary_use = sword_aoe({max_damage = 10, knockback = 12, radius = 5}), + on_place = sword_aoe({max_damage = 10, knockback = 12, radius = 5}), sound = { breaks = "default_tool_breaks" }, _mcl_toollike_wield = true, _mcl_diggroups = { @@ -199,15 +192,17 @@ minetest.register_tool("exchangeclone:sword_dark_matter", { }, }) -minetest.register_tool("exchangeclone:sword_red_matter", { - description = "Red Matter Sword\nImage coming soon.", +minetest.register_tool("exchangeclone:red_matter_sword", { + description = "Red Matter Sword", + wield_image = "exchangeclone_red_matter_sword.png", + inventory_image = "exchangeclone_red_matter_sword.png", groups = { tool=1, sword=1, dig_speed_class=8, enchantability=0 }, - wield_scale = wield_scale, + wield_scale = exchangeclone.wield_scale, tool_capabilities = { -- 1/1.2 full_punch_interval = 0.17, max_drop_level=6, - damage_groups = {fleshy=16}, + damage_groups = {fleshy=14}, punch_attack_uses = 0, groupcaps={ snappy = {times={[1]=0.6, [2]=0.25, [3]=0.1}, uses=0, maxlevel=5}, @@ -222,16 +217,20 @@ minetest.register_tool("exchangeclone:sword_red_matter", { }, }) -local diamond_itemstring = "default:diamond" -if exchangeclone.mineclone then - diamond_itemstring = "mcl_core:diamond" -end - minetest.register_craft({ - output = "exchangeclone:sword_dark_matter", + output = "exchangeclone:dark_matter_sword", recipe = { {"", "exchangeclone:dark_matter", ""}, {"", "exchangeclone:dark_matter", ""}, - {"", diamond_itemstring, ""} + {"", exchangeclone.diamond_itemstring, ""} } +}) + +minetest.register_craft({ + output = "exchangeclone:red_matter_sword", + recipe = { + {"", "exchangeclone:red_matter", ""}, + {"", "exchangeclone:red_matter", ""}, + {"", "exchangeclone:dark_matter_sword", ""}, + } }) \ No newline at end of file diff --git a/textures/exchangeclone_dark_matter_axe.png b/textures/exchangeclone_dark_matter_axe.png new file mode 100644 index 0000000..af948bb Binary files /dev/null and b/textures/exchangeclone_dark_matter_axe.png differ diff --git a/textures/exchangeclone_dark_matter_hammer.png b/textures/exchangeclone_dark_matter_hammer.png new file mode 100644 index 0000000..c130f61 Binary files /dev/null and b/textures/exchangeclone_dark_matter_hammer.png differ diff --git a/textures/exchangeclone_dark_matter_hoe.png b/textures/exchangeclone_dark_matter_hoe.png new file mode 100644 index 0000000..43291cc Binary files /dev/null and b/textures/exchangeclone_dark_matter_hoe.png differ diff --git a/textures/exchangeclone_dark_matter_pickaxe.png b/textures/exchangeclone_dark_matter_pickaxe.png new file mode 100644 index 0000000..2dc6761 Binary files /dev/null and b/textures/exchangeclone_dark_matter_pickaxe.png differ diff --git a/textures/exchangeclone_dark_matter_shears.png b/textures/exchangeclone_dark_matter_shears.png new file mode 100644 index 0000000..a421075 Binary files /dev/null and b/textures/exchangeclone_dark_matter_shears.png differ diff --git a/textures/exchangeclone_dark_matter_shovel.png b/textures/exchangeclone_dark_matter_shovel.png new file mode 100644 index 0000000..6d57974 Binary files /dev/null and b/textures/exchangeclone_dark_matter_shovel.png differ diff --git a/textures/exchangeclone_dark_matter_sword.png b/textures/exchangeclone_dark_matter_sword.png new file mode 100644 index 0000000..64fc102 Binary files /dev/null and b/textures/exchangeclone_dark_matter_sword.png differ diff --git a/textures/exchangeclone_pesa.png b/textures/exchangeclone_pesa.png new file mode 100644 index 0000000..71e94a3 Binary files /dev/null and b/textures/exchangeclone_pesa.png differ diff --git a/textures/exchangeclone_red_matter_axe.png b/textures/exchangeclone_red_matter_axe.png new file mode 100644 index 0000000..1abae9b Binary files /dev/null and b/textures/exchangeclone_red_matter_axe.png differ diff --git a/textures/exchangeclone_red_matter_hammer.png b/textures/exchangeclone_red_matter_hammer.png new file mode 100644 index 0000000..d0f3af3 Binary files /dev/null and b/textures/exchangeclone_red_matter_hammer.png differ diff --git a/textures/exchangeclone_red_matter_hoe.png b/textures/exchangeclone_red_matter_hoe.png new file mode 100644 index 0000000..82775d6 Binary files /dev/null and b/textures/exchangeclone_red_matter_hoe.png differ diff --git a/textures/exchangeclone_red_matter_pickaxe.png b/textures/exchangeclone_red_matter_pickaxe.png new file mode 100644 index 0000000..ff1a34c Binary files /dev/null and b/textures/exchangeclone_red_matter_pickaxe.png differ diff --git a/textures/exchangeclone_red_matter_shears.png b/textures/exchangeclone_red_matter_shears.png new file mode 100644 index 0000000..8a9dc97 Binary files /dev/null and b/textures/exchangeclone_red_matter_shears.png differ diff --git a/textures/exchangeclone_red_matter_shovel.png b/textures/exchangeclone_red_matter_shovel.png new file mode 100644 index 0000000..99ca873 Binary files /dev/null and b/textures/exchangeclone_red_matter_shovel.png differ diff --git a/textures/exchangeclone_red_matter_sword.png b/textures/exchangeclone_red_matter_sword.png new file mode 100644 index 0000000..e74f5b6 Binary files /dev/null and b/textures/exchangeclone_red_matter_sword.png differ diff --git a/tools.lua b/tools.lua index fc0826c..6dded35 100644 --- a/tools.lua +++ b/tools.lua @@ -1,19 +1,11 @@ -local wield_scale -if exchangeclone.mineclone then - local wield_scale = mcl_vars.tool_wield_scale -else - local wield_scale = {x=1,y=1,z=1} -end - local shovel_on_place -local axe_on_place if exchangeclone.mineclone then - shovel_on_place = function(itemstack, placer, pointed_thing) + shovel_on_place = function(itemstack, player, pointed_thing) -- Use pointed node's on_rightclick function first, if present local node = minetest.get_node(pointed_thing.under) - if placer and not placer:get_player_control().sneak then + if player and not player:get_player_control().sneak then if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then - return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack + return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, player, itemstack) or itemstack end end @@ -26,8 +18,8 @@ if exchangeclone.mineclone then local above = table.copy(pointed_thing.under) above.y = above.y + 1 if minetest.get_node(above).name == "air" then - if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) + if minetest.is_protected(pointed_thing.under, player:get_player_name()) then + minetest.record_protection_violation(pointed_thing.under, player:get_player_name()) return itemstack end minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true) @@ -36,111 +28,14 @@ if exchangeclone.mineclone then end return itemstack end - - axe_on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.type ~= "node" then return end - - local node = minetest.get_node(pointed_thing.under) - local node_name = minetest.get_node(pointed_thing.under).name - - local noddef = minetest.registered_nodes[node_name] - - if not noddef then - minetest.log("warning", "Trying to right click with an axe the unregistered node: " .. tostring(node_name)) - return - end - - if not placer:get_player_control().sneak and noddef.on_rightclick then - return minetest.item_place(itemstack, placer, pointed_thing) - end - if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) - return itemstack - end - - if noddef._mcl_stripped_variant == nil then - return itemstack - else - minetest.swap_node(pointed_thing.under, {name=noddef._mcl_stripped_variant, param2=node.param2}) - end - return itemstack - end end -local function create_soil(pos, inv) - if pos == nil then - return false - end - local node = minetest.get_node(pos) - local name = node.name - local above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}) - if minetest.get_item_group(name, "cultivatable") == 2 then - if above.name == "air" then - node.name = "mcl_farming:soil" - minetest.set_node(pos, node) - minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.5 }, true) - return true - end - elseif minetest.get_item_group(name, "cultivatable") == 1 then - if above.name == "air" then - node.name = "mcl_core:dirt" - minetest.set_node(pos, node) - minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.6 }, true) - return true - end - end - return false -end - -local hoe_on_place = function(itemstack, user, pointed_thing) - if minetest.get_modpath("farming") and farming then - return farming.hoe_on_use(itemstack, user, pointed_thing) - elseif not mineclone then - return - end - -- Call on_rightclick if the pointed node defines it - local node = minetest.get_node(pointed_thing.under) - if user and not user:get_player_control().sneak then - if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then - return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack - end - end - - if minetest.is_protected(pointed_thing.under, user:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, user:get_player_name()) - return itemstack - end - - if create_soil(pointed_thing.under, user:get_inventory()) then - return itemstack - end -end - -minetest.register_tool("exchangeclone:pick_dark_matter", { - description = "Dark Matter Pickaxe\nImage coming soon.", - groups = { tool=1, pickaxe=1, dig_speed_class=7, enchantability=0 }, - wield_scale = wield_scale, - tool_capabilities = { - -- 1/1.2 - full_punch_interval = 0.5, - max_drop_level=5, - damage_groups = {fleshy=7}, - punch_attack_uses = 0, - groupcaps={ - cracky = {times={[1]=1.5, [2]=0.75, [3]=0.325}, uses=0, maxlevel=4}, - }, - }, - sound = { breaks = "default_tool_breaks" }, - _mcl_toollike_wield = true, - _mcl_diggroups = { - pickaxey = { speed = 16, level = 7, uses = 0 } - }, -}) - -minetest.register_tool("exchangeclone:shovel_dark_matter", { - description = "Dark Matter Shovel\nImage coming soon.", +minetest.register_tool("exchangeclone:dark_matter_shovel", { + description = "Dark Matter Shovel", + wield_image = "exchangeclone_dark_matter_shovel.png", + inventory_image = "exchangeclone_dark_matter_shovel.png", groups = { tool=1, shovel=1, dig_speed_class=7, enchantability=0 }, - wield_scale = wield_scale, + wield_scale = exchangeclone.wield_scale, tool_capabilities = { -- 1/1.2 full_punch_interval = 0.5, @@ -159,82 +54,13 @@ minetest.register_tool("exchangeclone:shovel_dark_matter", { }, }) -minetest.register_tool("exchangeclone:axe_dark_matter", { - description = "Dark Matter Axe\nImage coming soon.", - groups = { tool=1, axe=1, dig_speed_class=7, enchantability=0 }, - wield_scale = wield_scale, - tool_capabilities = { - -- 1/1.2 - full_punch_interval = 0.5, - max_drop_level=5, - damage_groups = {fleshy=16}, - punch_attack_uses = 0, - groupcaps={ - choppy = {times={[1]=1.5, [2]=0.75, [3]=0.38}, uses=0, maxlevel=4}, - }, - }, - sound = { breaks = "default_tool_breaks" }, - on_place = axe_on_place, - _mcl_toollike_wield = true, - _mcl_diggroups = { - axey = { speed = 16, level = 7, uses = 0 } - }, -}) - -minetest.register_tool("exchangeclone:dark_matter_hoe", { - description = "Dark Matter Hoe", - wield_scale = wield_scale, - on_place = hoe_on_place, - groups = { tool=1, hoe=1, enchantability=0 }, - tool_capabilities = { - full_punch_interval = 0.25, - damage_groups = { fleshy = 7, }, - }, - _mcl_toollike_wield = true, - _mcl_diggroups = { - hoey = { speed = 12, level = 7, uses = 0 } - }, -}) - --Crafting recipes -local diamond_itemstring = "default:diamond" -if exchangeclone.mineclone then - diamond_itemstring = "mcl_core:diamond" -end - minetest.register_craft({ - output = "exchangeclone:shovel_dark_matter", + output = "exchangeclone:dark_matter_shovel", recipe = { {"", "exchangeclone:dark_matter", ""}, - {"", diamond_itemstring, ""}, - {"", diamond_itemstring, ""} - } -}) - -minetest.register_craft({ - output = "exchangeclone:pick_dark_matter", - recipe = { - {"exchangeclone:dark_matter", "exchangeclone:dark_matter", "exchangeclone:dark_matter"}, - {"", diamond_itemstring, ""}, - {"", diamond_itemstring, ""} - } -}) - -minetest.register_craft({ - output = "exchangeclone:axe_dark_matter", - recipe = { - {"exchangeclone:dark_matter", "exchangeclone:dark_matter", ""}, - {"exchangeclone:dark_matter", diamond_itemstring, ""}, - {"", diamond_itemstring, ""} - } -}) - -minetest.register_craft({ - output = "exchangeclone:dark_matter_hoe", - recipe = { - {"exchangeclone:dark_matter", "exchangeclone:dark_matter", ""}, - {"", diamond_itemstring, ""}, - {"", diamond_itemstring, ""} + {"", exchangeclone.diamond_itemstring, ""}, + {"", exchangeclone.diamond_itemstring, ""} } }) \ No newline at end of file