Add bronze tools

This commit is contained in:
mrkubax10 2023-02-26 20:21:09 +01:00
parent a9c71f4483
commit 50d1b95f00
2 changed files with 405 additions and 9 deletions

View File

@ -17,7 +17,18 @@
local S=minetest.get_translator("industrialtest") local S=minetest.get_translator("industrialtest")
industrialtest.mtgAvailable=minetest.get_modpath("default") industrialtest.mtgAvailable=minetest.get_modpath("default")
industrialtest.mclAvailable=minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_copper") local requiredMclModules={"mcl_core","mcl_copper","mcl_armor"}
industrialtest.mclAvailable=true
for _,mod in ipairs(requiredMclModules) do
if not minetest.get_modpath(mod) then
industrialtest.mclAvailable=false
break
end
end
if industrialtest.mtgAvailable and not minetest.get_modpath("3d_armor") then
error("IndustrialTest requires 3D Armor when used with Minetest Game")
end
industrialtest.elementKeys={} industrialtest.elementKeys={}
@ -106,6 +117,353 @@ if industrialtest.mclAvailable then
} }
}) })
end end
industrialtest.registerToolset=function(material,materialItem,materialDisplayName,config)
minetest.register_tool("industrialtest:"..material.."_pickaxe",{
description=S(materialDisplayName.." Pickaxe"),
inventory_image="industrialtest_mcl_"..material.."_pickaxe.png",
groups={tool=1,pickaxe=1,dig_speed_class=config.digSpeedClass},
tool_capabilities={
full_punch_interval=1,
max_drop_level=config.dropLevel,
damage_groups={fleshy=config.damage},
},
sound={breaks="default_tool_breaks"},
_repair_material="industrialtest:"..material,
_mcl_toollike_wield=true,
_mcl_diggroups={
pickaxey={speed=config.speed,level=config.level,uses=config.uses}
}
})
minetest.register_tool("industrialtest:"..material.."_shovel",{
description=S(materialDisplayName.." Shovel"),
inventory_image="industrialtest_mcl_"..material.."_shovel.png",
groups={tool=1,shovel=1,dig_speed_class=config.digSpeedClass},
tool_capabilities={
full_punch_interval=1,
max_drop_level=config.dropLevel,
damage_groups={fleshy=config.damage}
},
on_place=function(itemstack,placer,pointedThing)
-- Taken from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_tools/init.lua#L159
-- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node(pointedThing.under)
if placer and not placer: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(pointedThing.under, node, placer, itemstack) or itemstack
end
end
-- Only make grass path if tool used on side or top of target node
if pointedThing.above.y < pointedThing.under.y then
return itemstack
end
if (minetest.get_item_group(node.name, "path_creation_possible") == 1) then
local above = table.copy(pointedThing.under)
above.y = above.y + 1
if minetest.get_node(above).name == "air" then
if minetest.is_protected(pointedThing.under, placer:get_player_name()) then
minetest.record_protection_violation(pointedThing.under, placer:get_player_name())
return itemstack
end
if not minetest.is_creative_enabled(placer:get_player_name()) then
-- Add wear (as if digging a shovely node)
local toolname = itemstack:get_name()
local wear = mcl_autogroup.get_wear(toolname, "shovely")
itemstack:add_wear(wear)
end
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true)
minetest.swap_node(pointedThing.under, {name="mcl_core:grass_path"})
end
end
return itemstack
end,
sound={breaks="default_tool_breaks"},
_repair_material="industrialtest:"..material,
_mcl_toollike_wield=true,
_mcl_diggroups={
shovely={speed=config.speed,level=config.level,uses=config.uses}
}
})
minetest.register_tool("industrialtest:"..material.."_axe",{
description=S(materialDisplayName.." Axe"),
inventory_image="industrialtest_mcl_"..material.."_axe.png",
groups={tool=1,axe=1,dig_speed_class=config.digSpeedClass},
tool_capabilities={
full_punch_interval=1,
max_level_drop=config.levelDrop,
damage_groups={fleshy=config.damage+3},
},
on_place=function(itemstack,placer,pointedThing)
-- Taken from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_tools/init.lua#L360
if pointedThing.type ~= "node" then return end
local node = minetest.get_node(pointedThing.under)
local noddef = minetest.registered_nodes[minetest.get_node(pointedThing.under).name]
if not placer:get_player_control().sneak and noddef.on_rightclick then
return minetest.item_place(itemstack, placer, pointedThing)
end
if minetest.is_protected(pointedThing.under, placer:get_player_name()) then
minetest.record_protection_violation(pointedThing.under, placer:get_player_name())
return itemstack
end
if noddef._mcl_stripped_variant == nil then
return itemstack
else
minetest.swap_node(pointedThing.under, {name=noddef._mcl_stripped_variant, param2=node.param2})
if not minetest.is_creative_enabled(placer:get_player_name()) then
-- Add wear (as if digging a axey node)
local toolname = itemstack:get_name()
local wear = mcl_autogroup.get_wear(toolname, "axey")
itemstack:add_wear(wear)
end
end
return itemstack
end,
sound={breaks="default_tool_breaks"},
_repair_material="industrialtest:"..material,
_mcl_toollike_wield=true,
_mcl_diggroups={
axey={speed=config.speed,level=config.level,uses=config.uses}
}
})
minetest.register_tool("industrialtest:"..material.."_sword",{
description=S(materialDisplayName.." Sword"),
inventory_image="industrialtest_mcl_"..material.."_sword.png",
groups={weapon=1,sword=1,dig_speed_class=config.digSpeedClass},
tool_capabilities={
full_punch_interval=0.625,
max_drop_level=config.maxDropLevel,
damage_groups={fleshy=config.damage+2},
},
sound={breaks="default_tool_breaks"},
_repair_material="industrialtest:"..material,
_mcl_toollike_wield=true,
_mcl_diggroups={
swordy={speed=config.speed,level=config.level,uses=config.uses},
swordy_cobweb={speed=config.speed,level=config.level,uses=config.uses}
}
})
minetest.register_tool("industrialtest:"..material.."_hoe",{
description=S(materialDisplayName.." Hoe"),
inventory_image="industrialtest_mcl_"..material.."_hoe.png",
groups={tool=1,hoe=1},
tool_capabilities={
full_punch_interval=1,
damage_groups={fleshy=1}
},
on_place=function(itemstack,user,pointedThing)
-- Taken from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_farming/hoes.lua#L3
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
-- Taken from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_farming/hoes.lua#L29
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node(pointedThing.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(pointedThing.under, node, user, itemstack) or itemstack
end
end
if minetest.is_protected(pointedThing.under, user:get_player_name()) then
minetest.record_protection_violation(pointedThing.under, user:get_player_name())
return itemstack
end
if create_soil(pointedThing.under, user:get_inventory()) then
if not minetest.is_creative_enabled(user:get_player_name()) then
itemstack:add_wear(65535/config.uses)
end
return itemstack
end
end,
_repair_material="industrialtest:"..material,
_mcl_toollike_wield=true,
_mcl_diggroups={
hoey={speed=config.speed,level=config.level,uses=config.uses}
}
})
mcl_armor.register_set({
name=material,
description=materialDisplayName,
durability=config.uses,
points=config.armorPoints,
craft_material="industrialtest:"..material,
cook_material=config.armorCookMaterial,
sound_equip=config.armorEquipSound,
sound_unequip=config.armorUnequipSound,
textures={
head="industrialtest_mcl_"..material.."_helmet.png",
torso="industrialtest_mcl_"..material.."_chestplate.png",
legs="industrialtest_mcl_"..material.."_leggings.png",
feet="industrialtest_mcl_"..material.."_boots.png"
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_pickaxe",
recipe={
{"industrialtest:"..material,"industrialtest:"..material,"industrialtest:"..material},
{"","mcl_core:stick",""},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_shovel",
recipe={
{"","industrialtest:"..material,""},
{"","mcl_core:stick",""},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_shovel",
recipe={
{"industrialtest:"..material,"",""},
{"mcl_core:stick","",""},
{"mcl_core:stick","",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_shovel",
recipe={
{"","","industrialtest:"..material},
{"","","mcl_core:stick"},
{"","","mcl_core:stick"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_axe",
recipe={
{"industrialtest:"..material,"industrialtest:"..material,""},
{"industrialtest:"..material,"mcl_core:stick",""},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_axe",
recipe={
{"","industrialtest:"..material,"industrialtest:"..material},
{"","mcl_core:stick","industrialtest:"..material},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_axe",
recipe={
{"industrialtest:"..material,"industrialtest:"..material,""},
{"mcl_core:stick","industrialtest:"..material,""},
{"mcl_core:stick","",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_axe",
recipe={
{"","industrialtest:"..material,"industrialtest:"..material},
{"","mcl_core:stick","industrialtest:"..material},
{"","","mcl_core:stick"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_sword",
recipe={
{"industrialtest:"..material,"",""},
{"industrialtest:"..material,"",""},
{"mcl_core:stick","",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_sword",
recipe={
{"","industrialtest:"..material,""},
{"","industrialtest:"..material,""},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_sword",
recipe={
{"","","industrialtest:"..material},
{"","","industrialtest:"..material},
{"","","mcl_core:stick"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_hoe",
recipe={
{"industrialtest:"..material,"industrialtest:"..material,""},
{"","mcl_core:stick",""},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_hoe",
recipe={
{"","industrialtest:"..material,"industrialtest:"..material},
{"","","mcl_core:stick"},
{"","","mcl_core:stick"}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_hoe",
recipe={
{"","industrialtest:"..material,"industrialtest:"..material},
{"","mcl_core:stick",""},
{"","mcl_core:stick",""}
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:"..material.."_hoe",
recipe={
{"industrialtest:"..material,"industrialtest:"..material,""},
{"mcl_core:stick","",""},
{"mcl_core:stick","",""}
}
})
end
-- assign element keys for elements that are required later
industrialtest.elementKeys.stick="mcl_core:stick"
-- register required minerals that are not available in MCL -- register required minerals that are not available in MCL
industrialtest.registerMetal("tin","Tin",3,3) industrialtest.registerMetal("tin","Tin",3,3)
industrialtest.elementKeys.tinIngot="industrialtest:tin_ingot" industrialtest.elementKeys.tinIngot="industrialtest:tin_ingot"
@ -115,6 +473,10 @@ if industrialtest.mclAvailable then
description=S("Bronze Ingot"), description=S("Bronze Ingot"),
inventory_image="industrialtest_mcl_bronze_ingot.png" inventory_image="industrialtest_mcl_bronze_ingot.png"
}) })
minetest.register_craftitem("industrialtest:bronze_nugget",{
description=S("Bronze Nugget"),
inventory_image="industrialtest_mcl_bronze_nugget.pngn"
})
minetest.register_craft({ minetest.register_craft({
type="shaped", type="shaped",
output="industrialcraft:bronze_ingot 9", output="industrialcraft:bronze_ingot 9",
@ -124,7 +486,47 @@ if industrialtest.mclAvailable then
{"mcl_copper:copper_ingot","mcl_copper:copper_ingot","mcl_copper:copper_ingot"} {"mcl_copper:copper_ingot","mcl_copper:copper_ingot","mcl_copper:copper_ingot"}
} }
}) })
minetest.register_craft({
type="shapeless",
output="industrialtest:bronze_ingot 9",
recipe={
"industrialtest:bronze_block"
}
})
minetest.register_craft({
type="shaped",
output="industrialtest:bronze_ingot",
recipe={
{"industrialtest:bronze_nugget","industrialtest:bronze_nugget","industrialtest:bronze_nugget"},
{"industrialtest:bronze_nugget","industrialtest:bronze_nugget","industrialtest:bronze_nugget"},
{"industrialtest:bronze_nugget","industrialtest:bronze_nugget","industrialtest:bronze_nugget"},
}
})
minetest.register_craft({
type="shapeless",
output="industrialtest:bronze_nugget 9",
recipe={
"industrialtest:bronze_ingot"
}
})
industrialtest.elementKeys.bronzeIngot="industrialtest:bronze_ingot" industrialtest.elementKeys.bronzeIngot="industrialtest:bronze_ingot"
industrialtest.registerToolset("bronze","bronze_ingot","Bronze",{
digSpeedClass=4,
dropLevel=4,
speed=6,
level=4,
uses=200,
damage=4,
armorPoints={
head=2,
torso=6,
legs=5,
feet=2
},
armorCookMaterial="industrialtest:bronze_nugget",
armorEquipSound="mcl_armor_equip_iron",
armorUnequipSound="mcl_armor_unequip_iron"
})
--register other blocks that are not availabe in MCL --register other blocks that are not availabe in MCL
minetest.register_node("industrialtest:bronze_block",{ minetest.register_node("industrialtest:bronze_block",{
@ -144,13 +546,6 @@ if industrialtest.mclAvailable then
{"industrialtest:bronze_ingot","industrialtest:bronze_ingot","industrialtest:bronze_ingot"} {"industrialtest:bronze_ingot","industrialtest:bronze_ingot","industrialtest:bronze_ingot"}
} }
}) })
minetest.register_craft({
type="shapeless",
output="industrialtest:bronze_ingot 9",
recipe={
"industrialtest:bronze_block"
}
})
-- ore generation is game-dependent so register it there -- ore generation is game-dependent so register it there
local stonelike={"mcl_core:stone","mcl_core:diorite","mcl_core:andesite","mcl_core:granite"} local stonelike={"mcl_core:stone","mcl_core:diorite","mcl_core:andesite","mcl_core:granite"}
@ -228,6 +623,7 @@ elseif industrialtest.mtgAvailable then
end end
industrialtest.elementKeys.tinIngot="default:tin_ingot" industrialtest.elementKeys.tinIngot="default:tin_ingot"
industrialtest.elementKeys.bronzeIngot="default:bronze_ingot" industrialtest.elementKeys.bronzeIngot="default:bronze_ingot"
industrialtest.elementKeys.stick="default:stick"
-- ore generation is game-dependent so register it there -- ore generation is game-dependent so register it there
minetest.register_ore({ minetest.register_ore({

View File

@ -1,5 +1,5 @@
name=industrialtest name=industrialtest
description=Adds various machinery description=Adds various machinery
optional_depends=default,mcl_core,mcl_copper optional_depends=default,3d_armor,mcl_core,mcl_copper,mcl_armor
author=IndustrialTest Team author=IndustrialTest Team
title=IndustrialTest title=IndustrialTest