From f9d25562041dc5f55546acefec23eed620cee7cd Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 20 May 2020 20:05:13 -0700 Subject: [PATCH] Add support for MineClone2 --- .luacheckrc | 27 ++-- compat/mcl2.lua | 184 +++++++++++++++++++++++++++ compat/mtg.lua | 59 ++++++++- depends.txt | 9 +- init.lua | 329 +++++++++++++++++++++--------------------------- mod.conf | 2 +- 6 files changed, 410 insertions(+), 200 deletions(-) create mode 100644 compat/mcl2.lua diff --git a/.luacheckrc b/.luacheckrc index 678e25f..2200dd4 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -2,20 +2,27 @@ unused_args = false max_line_length = 999 globals = { - "minetest", "lavastuff", + "minetest", "lavastuff", } read_globals = { - string = {fields = {"split"}}, - table = {fields = {"copy", "getn"}}, + string = {fields = {"split"}}, + table = {fields = {"copy", "getn"}}, - -- Builtin - "vector", "ItemStack", - "dump", "DIR_DELIM", "VoxelArea", "Settings", + -- Builtin + "vector", "ItemStack", + "dump", "DIR_DELIM", "VoxelArea", "Settings", - -- MTG - "default", "sfinv", "creative", "stairs", + -- MTG + "default", "sfinv", "creative", "stairs", - -- Other mods - "armor", "stairsplus", "toolranks", + -- MC2 + "mcl_sounds", + + -- Other mods + "armor", "stairsplus", "toolranks", +} + +exclude_files = { + ".luacheckrc", } diff --git a/compat/mcl2.lua b/compat/mcl2.lua new file mode 100644 index 0000000..8062927 --- /dev/null +++ b/compat/mcl2.lua @@ -0,0 +1,184 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +for _, item in pairs({"lavastuff:sword", "lavastuff:pick", "lavastuff:axe", "lavastuff:shovel"}) do + local itype = item:sub(item:find(":")+1) + local mcldef = table.copy(minetest.registered_items[("mcl_tools:%s_diamond"):format(itype)]) + local groups = table.copy(minetest.registered_items[item].groups) + + mcldef.tool_capabilities.damage_groups.fleshy = mcldef.tool_capabilities.damage_groups.fleshy + 1 + mcldef.tool_capabilities.full_punch_interval = mcldef.tool_capabilities.full_punch_interval - 0.1 + groups.dig_speed_class = mcldef.groups.dig_speed_class + + minetest.override_item(item, { + tool_capabilities = mcldef.tool_capabilities, + groups = groups, + wield_scale = vector.new(1.8, 1.8, 1), + _repair_material = "lavastuff:ingot", + }) +end + +minetest.override_item("lavastuff:block", { + stack_max = 64, + groups = {pickaxey=3, building_block=1}, + sounds = mcl_sounds.node_sound_stone_defaults(), + _mcl_blast_resistance = 6, + _mcl_hardness = 4, +}) + +for _, item in pairs({"lavastuff:ingot", "lavastuff:orb"}) do + minetest.override_item(item, { + stack_max = 64, + }) +end + +minetest.register_tool("lavastuff:helmet",{ + description = S("Lava Helmet"), + inventory_image = "lavastuff_inv_helmet.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_head=1, mcl_armor_points=3, mcl_armor_uses=600, mcl_armor_toughness=3}, + _repair_material = "lavastuff:ingot", + sounds = { + _mcl_armor_equip = "mcl_armor_equip_diamond", + _mcl_armor_unequip = "mcl_armor_unequip_diamond", + }, + on_place = armor.on_armor_use, + on_secondary_use = armor.on_armor_use, +}) + +minetest.register_tool("lavastuff:chestplate", { + description = S("Lava Chestplate"), + inventory_image = "lavastuff_inv_chestplate.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_torso=1, mcl_armor_points=8, mcl_armor_uses=600, mcl_armor_toughness=3}, + _repair_material = "lavastuff:ingot", + sounds = { + _mcl_armor_equip = "mcl_armor_equip_diamond", + _mcl_armor_unequip = "mcl_armor_unequip_diamond", + }, + on_place = armor.on_armor_use, + on_secondary_use = armor.on_armor_use, +}) + +minetest.register_tool("lavastuff:leggings", { + description = S("Lava Leggings"), + inventory_image = "lavastuff_inv_leggings.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_legs=1, mcl_armor_points=6, mcl_armor_uses=600, mcl_armor_toughness=3}, + _repair_material = "lavastuff:ingot", + sounds = { + _mcl_armor_equip = "mcl_armor_equip_diamond", + _mcl_armor_unequip = "mcl_armor_unequip_diamond", + }, + on_place = armor.on_armor_use, + on_secondary_use = armor.on_armor_use, +}) + +minetest.register_tool("lavastuff:boots", { + description = S("Lava Boots"), + inventory_image = "lavastuff_inv_boots.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_feet=1, mcl_armor_points=3, mcl_armor_uses=600, mcl_armor_toughness=3}, + _repair_material = "lavastuff:ingot", + sounds = { + _mcl_armor_equip = "mcl_armor_equip_diamond", + _mcl_armor_unequip = "mcl_armor_unequip_diamond", + }, + on_place = armor.on_armor_use, + on_secondary_use = armor.on_armor_use, +}) + +-- +-- Ingot craft +-- + +minetest.register_craft({ + type = "shapeless", + output = "lavastuff:ingot 2", + recipe = {"mcl_mobitems:blaze_rod", "lavastuff:orb"} +}) + +-- +-- Orb craft +-- + +minetest.register_craft({ + output = "lavastuff:orb", + recipe = { + {"mcl_mobitems:blaze_powder", "mcl_mobitems:magma_cream", "mcl_mobitems:blaze_powder"}, + {"mcl_mobitems:magma_cream", "mcl_buckets:bucket_lava", "mcl_mobitems:magma_cream"}, + {"", "mcl_mobitems:magma_cream", ""} + }, + replacements = {{"mcl_buckets:bucket_lava", "mcl_buckets:bucket_empty"}} +}) + +-- +-- Tool crafts +-- + +minetest.register_craft({ + output = "lavastuff:sword", + recipe = { + {"lavastuff:ingot"}, + {"lavastuff:ingot"}, + {"mcl_core:iron_ingot"}, + } +}) + +minetest.register_craft({ + output = "lavastuff:pick", + recipe = { + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"", "mcl_core:iron_ingot", ""}, + {"", "mcl_core:iron_ingot", ""}, + } +}) + +minetest.register_craft({ + output = "lavastuff:shovel", + recipe = { + {"lavastuff:ingot"}, + {"mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot"}, + } +}) + +minetest.register_craft({ + output = "lavastuff:axe", + recipe = { + {"lavastuff:ingot", "lavastuff:ingot", ""}, + {"lavastuff:ingot", "mcl_core:iron_ingot", ""}, + {"", "mcl_core:iron_ingot", ""}, + } +}) + +-- +-- Block crafts +-- + +minetest.register_craft({ + type = "shapeless", + output = "lavastuff:ingot 9", + recipe = {"lavastuff:block"} +}) + +minetest.register_craft({ + output = "lavastuff:block", + recipe = { + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + } +}) + +-- +-- Lava in a Bottle craft +-- + +minetest.register_craft({ + output = "lavastuff:lava_in_a_bottle", + recipe = { + {"", "mcl_buckets:bucket_lava"}, + {"", "mcl_potions:glass_bottle"}, + }, + replacements = {{"mcl_buckets:bucket_lava", "mcl_buckets:bucket_empty"}} +}) diff --git a/compat/mtg.lua b/compat/mtg.lua index 6541876..b0766ee 100644 --- a/compat/mtg.lua +++ b/compat/mtg.lua @@ -1,3 +1,60 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +-- Armor +-- + +if minetest.get_modpath("3d_armor") then + armor:register_armor("lavastuff:helmet", { + description = S("Lava Helmet"), + inventory_image = "lavastuff_inv_helmet.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_head=1, armor_heal=12, armor_use=100, armor_fire=10}, + armor_groups = {fleshy=15}, + damage_groups = {cracky=2, snappy=1, level=3}, + wear = 0, + }) + + armor:register_armor("lavastuff:chestplate", { + description = S("Lava Chestplate"), + inventory_image = "lavastuff_inv_chestplate.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_torso=1, armor_heal=12, armor_use=100, armor_fire=10}, + armor_groups = {fleshy=20}, + damage_groups = {cracky=2, snappy=1, level=3}, + wear = 0, + }) + + armor:register_armor("lavastuff:leggings", { + description = S("Lava Leggings"), + inventory_image = "lavastuff_inv_leggings.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_legs=1, armor_heal=12, armor_use=100, armor_fire=10}, + armor_groups = {fleshy=20}, + damage_groups = {cracky=2, snappy=1, level=3}, + wear = 0, + }) + + armor:register_armor("lavastuff:boots", { + description = S("Lava Boots"), + inventory_image = "lavastuff_inv_boots.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_feet=1, armor_heal=12, armor_use=100, armor_fire=10, physics_jump=0.5, physics_speed = 1}, + armor_groups = {fleshy=15}, + damage_groups = {cracky=2, snappy=1, level=3}, + wear = 0, + }) + + armor:register_armor("lavastuff:shield", { + description = S("Lava Shield"), + inventory_image = "lavastuff_inven_shield.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_shield=1, armor_heal=12, armor_use=100, armor_fire=10}, + armor_groups = {fleshy=20}, + damage_groups = {cracky=2, snappy=1, level=3}, + wear = 0, + }) +end + -- -- Ingot craft -- @@ -20,7 +77,7 @@ if not minetest.get_modpath("mobs_monster") then {"default:mese_crystal", "bucket:bucket_lava", "default:mese_crystal"}, {"default:mese_crystal", "default:mese_crystal", "default:mese_crystal"} }, - replacements = {{"bucket:bucket_lava", "bucket:bucket_empty 1"}} + replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}} }) end diff --git a/depends.txt b/depends.txt index cbde671..e422c15 100644 --- a/depends.txt +++ b/depends.txt @@ -7,5 +7,12 @@ mobs_monster? toolranks? moreblocks? vessels? -mc_fire? nc_fire? +mcl_armor? +mcl_fire? +mcl_buckets? +mcl_nether? +mcl_potions? +mcl_core? +mcl_mobitems? +mcl_tools? diff --git a/init.lua b/init.lua index 4ee8bb5..244d72c 100644 --- a/init.lua +++ b/init.lua @@ -119,6 +119,7 @@ minetest.register_craftitem("lavastuff:ingot", { description = S("Lava Ingot"), inventory_image = "lavastuff_ingot.png", light_source = 7, -- Texture will have a glow when dropped + groups = {craftitem = 1}, }) -- @@ -130,6 +131,7 @@ if not minetest.get_modpath("mobs_monster") then description = S("Lava Orb"), inventory_image = "zmobs_lava_orb.png", light_source = 7, -- Texture will have a glow when dropped + groups = {craftitem = 1}, }) minetest.register_alias("mobs:lava_orb", "lavastuff:orb") @@ -137,192 +139,11 @@ else minetest.register_alias("lavastuff:orb", "mobs:lava_orb") end --- --- Tools --- - -minetest.register_tool("lavastuff:sword", { - description = S("Lava Sword"), - inventory_image = "lavastuff_sword.png", - light_source = 7, -- Texture will have a glow when dropped - tool_capabilities = { - full_punch_interval = 0.6, - max_drop_level = 1, - groupcaps = { - snappy = { - times = {1.7, 0.7, 0.25}, - uses = 50, - maxlevel = 3 - }, - }, - damage_groups = {fleshy = 10, burns = 1}, - }, - on_place = lavastuff.tool_fire_func, - sound = {breaks = "default_tool_breaks"}, -}) - -if not minetest.get_modpath("mobs_monster") then - minetest.register_alias("mobs:pick_lava", "lavastuff:pick") - - minetest.register_tool("lavastuff:pick", { - description = S("Lava Pickaxe"), - inventory_image = "lavastuff_pick.png", - light_source = 7, -- Texture will have a glow when dropped - tool_capabilities = { - burns = true, -- fire_plus support - full_punch_interval = 0.7, - max_drop_level = 3, - groupcaps={ - cracky = { - times = {[1] = 1.8, [2] = 0.8, [3] = 0.40}, - uses = 40, - maxlevel = 3 - }, - }, - damage_groups = {fleshy = 6, burns = 1}, - }, - on_place = lavastuff.tool_fire_func, - }) - --- Lava Pick (restores autosmelt functionality) - - lavastuff.burn_drops("lavastuff:pick") -else - minetest.register_alias("lavastuff:pick", "mobs:pick_lava") - - minetest.register_tool(":mobs:pick_lava", { - description = S("Lava Pickaxe"), - inventory_image = "lavastuff_pick.png", - light_source = 7, -- Texture will have a glow when dropped - tool_capabilities = { - burns = true, -- fire_plus support - full_punch_interval = 0.7, - max_drop_level = 3, - groupcaps={ - cracky = { - times = {[1] = 1.8, [2] = 0.8, [3] = 0.40}, - uses = 40, - maxlevel = 3 - }, - }, - damage_groups = {fleshy = 6, burns = 1}, - }, - on_place = lavastuff.tool_fire_func, - }) -end - -minetest.register_tool("lavastuff:shovel", { - description = S("Lava Shovel"), - inventory_image = "lavastuff_shovel.png", - wield_image = "lavastuff_shovel.png^[transformR90", - light_source = 7, -- Texture will have a glow when dropped - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=1, - groupcaps={ - crumbly = {times={[1]=1.10, [2]=0.50, [3]=0.30}, uses=30, maxlevel=3}, - }, - damage_groups = {fleshy=4}, - }, - on_place = lavastuff.tool_fire_func, - sound = {breaks = "default_tool_breaks"}, -}) - -minetest.register_tool("lavastuff:axe", { - description = S("Lava Axe"), - inventory_image = "lavastuff_axe.png", - light_source = 7, -- Texture will have a glow when dropped - tool_capabilities = { - full_punch_interval = 0.8, - max_drop_level = 1, - groupcaps = { - choppy = { - times = {[1] = 2.00, [2] = 0.80, [3] = 0.40}, - uses = 40, - maxlevel = 3 - }, - }, - damage_groups = {fleshy = 7, burns = 1}, - }, - on_place = lavastuff.tool_fire_func, - sound = {breaks = "default_tool_breaks"}, -}) - --- --- Tool Crafts --- - -if minetest.get_modpath("mobs_monster") then - minetest.clear_craft({ - recipe = { - {"mobs:lava_orb", "mobs:lava_orb", "mobs:lava_orb"}, - {"", "default:obsidian_shard", ""}, - {"", "default:obsidian_shard", ""}, - } - }) -end - --- --- Armor --- - -if minetest.get_modpath("3d_armor") then - armor:register_armor("lavastuff:helmet", { - description = S("Lava Helmet"), - inventory_image = "lavastuff_inv_helmet.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_head=1, armor_heal=12, armor_use=100, armor_fire=10}, - armor_groups = {fleshy=15}, - damage_groups = {cracky=2, snappy=1, level=3}, - wear = 0, - }) - - armor:register_armor("lavastuff:chestplate", { - description = S("Lava Chestplate"), - inventory_image = "lavastuff_inv_chestplate.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_torso=1, armor_heal=12, armor_use=100, armor_fire=10}, - armor_groups = {fleshy=20}, - damage_groups = {cracky=2, snappy=1, level=3}, - wear = 0, - }) - - armor:register_armor("lavastuff:leggings", { - description = S("Lava Leggings"), - inventory_image = "lavastuff_inv_leggings.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_legs=1, armor_heal=12, armor_use=100, armor_fire=10}, - armor_groups = {fleshy=20}, - damage_groups = {cracky=2, snappy=1, level=3}, - wear = 0, - }) - - armor:register_armor("lavastuff:boots", { - description = S("Lava Boots"), - inventory_image = "lavastuff_inv_boots.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_feet=1, armor_heal=12, armor_use=100, armor_fire=10, physics_jump=0.5, physics_speed = 1}, - armor_groups = {fleshy=15}, - damage_groups = {cracky=2, snappy=1, level=3}, - wear = 0, - }) - - armor:register_armor("lavastuff:shield", { - description = S("Lava Shield"), - inventory_image = "lavastuff_inven_shield.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_shield=1, armor_heal=12, armor_use=100, armor_fire=10}, - armor_groups = {fleshy=20}, - damage_groups = {cracky=2, snappy=1, level=3}, - wear = 0, - }) -end - -- -- Armor Crafts -- -if minetest.get_modpath("3d_armor") then +if minetest.get_modpath("3d_armor") or minetest.get_modpath("mcl_armor") then minetest.register_craft({ output = "lavastuff:helmet", recipe = { @@ -358,12 +179,144 @@ if minetest.get_modpath("3d_armor") then } }) - minetest.register_craft({ - output = "lavastuff:shield", + if not minetest.get_modpath("mcl_armor") then + minetest.register_craft({ + output = "lavastuff:shield", + recipe = { + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"", "lavastuff:ingot", ""}, + } + }) + end +end + +-- +-- Tools +-- + +minetest.register_tool("lavastuff:sword", { + description = S("Lava Sword"), + inventory_image = "lavastuff_sword.png", + groups = {weapon = 1, sword = 1}, + light_source = 7, -- Texture will have a glow when dropped + tool_capabilities = { + full_punch_interval = 0.6, + max_drop_level = 1, + groupcaps = { + snappy = { + times = {1.7, 0.7, 0.25}, + uses = 50, + maxlevel = 3 + }, + }, + damage_groups = {fleshy = 10, burns = 1}, + }, + on_place = lavastuff.tool_fire_func, + sound = {breaks = "default_tool_breaks"}, +}) + +if not minetest.get_modpath("mobs_monster") then + minetest.register_alias("mobs:pick_lava", "lavastuff:pick") + + minetest.register_tool("lavastuff:pick", { + description = S("Lava Pickaxe"), + inventory_image = "lavastuff_pick.png", + groups = {tool = 1, pickaxe = 1}, + light_source = 7, -- Texture will have a glow when dropped + tool_capabilities = { + burns = true, -- fire_plus support + full_punch_interval = 0.7, + max_drop_level = 3, + groupcaps={ + cracky = { + times = {[1] = 1.8, [2] = 0.8, [3] = 0.40}, + uses = 40, + maxlevel = 3 + }, + }, + damage_groups = {fleshy = 6, burns = 1}, + }, + on_place = lavastuff.tool_fire_func, + }) + +-- Lava Pick (restores autosmelt functionality) + + lavastuff.burn_drops("lavastuff:pick") +else + minetest.register_alias("lavastuff:pick", "mobs:pick_lava") + + minetest.register_tool(":mobs:pick_lava", { + description = S("Lava Pickaxe"), + inventory_image = "lavastuff_pick.png", + groups = {tool = 1, pickaxe = 1}, + light_source = 7, -- Texture will have a glow when dropped + tool_capabilities = { + burns = true, -- fire_plus support + full_punch_interval = 0.7, + max_drop_level = 3, + groupcaps={ + cracky = { + times = {[1] = 1.8, [2] = 0.8, [3] = 0.40}, + uses = 40, + maxlevel = 3 + }, + }, + damage_groups = {fleshy = 6, burns = 1}, + }, + on_place = lavastuff.tool_fire_func, + }) +end + +minetest.register_tool("lavastuff:shovel", { + description = S("Lava Shovel"), + inventory_image = "lavastuff_shovel.png", + wield_image = "lavastuff_shovel.png^[transformR90", + groups = {tool = 1, shovel = 1}, + light_source = 7, -- Texture will have a glow when dropped + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + crumbly = {times={[1]=1.10, [2]=0.50, [3]=0.30}, uses=30, maxlevel=3}, + }, + damage_groups = {fleshy=4}, + }, + on_place = lavastuff.tool_fire_func, + sound = {breaks = "default_tool_breaks"}, +}) + +minetest.register_tool("lavastuff:axe", { + description = S("Lava Axe"), + inventory_image = "lavastuff_axe.png", + groups = {tool = 1, axe = 1}, + light_source = 7, -- Texture will have a glow when dropped + tool_capabilities = { + full_punch_interval = 0.8, + max_drop_level = 1, + groupcaps = { + choppy = { + times = {[1] = 2.00, [2] = 0.80, [3] = 0.40}, + uses = 40, + maxlevel = 3 + }, + }, + damage_groups = {fleshy = 7, burns = 1}, + }, + on_place = lavastuff.tool_fire_func, + sound = {breaks = "default_tool_breaks"}, +}) + +-- +-- Tool Craft +-- + +if minetest.get_modpath("mobs_monster") then + minetest.clear_craft({ recipe = { - {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, - {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, - {"", "lavastuff:ingot", ""}, + {"mobs:lava_orb", "mobs:lava_orb", "mobs:lava_orb"}, + {"", "default:obsidian_shard", ""}, + {"", "default:obsidian_shard", ""}, } }) end @@ -470,4 +423,6 @@ minetest.register_node("lavastuff:lava_in_a_bottle", { if minetest.get_modpath("default") and minetest.get_modpath("bucket") and minetest.get_modpath("vessels") then dofile(minetest.get_modpath("lavastuff") .. "/compat/mtg.lua") +elseif minetest.get_modpath("mcl_core") then + dofile(minetest.get_modpath("lavastuff") .. "/compat/mcl2.lua") end diff --git a/mod.conf b/mod.conf index 2f0612e..fd1d92e 100644 --- a/mod.conf +++ b/mod.conf @@ -3,4 +3,4 @@ author = Lone_Wolf description = Adds lava tools, armor, and blocks release = 0 title = Lava Stuff -optional_depends = fire, stairs, mobs_monster, 3d_armor, toolranks, moreblocks, vessels, default, bucket, mcl_fire, nc_fire +optional_depends = fire, stairs, mobs_monster, 3d_armor, toolranks, moreblocks, vessels, default, bucket, mcl_armor, mcl_fire, mcl_buckets, mcl_nether, mcl_potions, mcl_core, mcl_mobitems, mcl_tools, nc_fire,