mirror of
https://github.com/minetest-mods/nether.git
synced 2024-09-07 21:00:33 +02:00
Technic and Toolranks support (#73)
Co-authored-by: Treer <treer.git@gmail.com>
This commit is contained in:
parent
d16b530685
commit
a6d1f55f0a
|
@ -27,9 +27,12 @@ read_globals = {
|
|||
"stairsplus",
|
||||
"string.split",
|
||||
table = { fields = { "copy", "getn" } },
|
||||
"technic",
|
||||
"toolranks",
|
||||
"vector",
|
||||
"VoxelArea",
|
||||
"VoxelManip",
|
||||
"walls",
|
||||
xpanes = { fields = { "register_pane" } },
|
||||
}
|
||||
|
||||
|
|
6
init.lua
6
init.lua
|
@ -144,7 +144,9 @@ if nether.NETHER_REALM_ENABLED then
|
|||
end
|
||||
end
|
||||
dofile(nether.path .. "/portal_examples.lua")
|
||||
|
||||
if minetest.get_modpath("technic") then
|
||||
dofile(nether.path .. "/nether-compressor-recipe.lua")
|
||||
end
|
||||
|
||||
-- Portals are ignited by right-clicking with a mese crystal fragment
|
||||
nether.register_portal_ignition_item(
|
||||
|
@ -345,4 +347,4 @@ minetest.register_on_dieplayer(
|
|||
)
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
|
2
mod.conf
2
mod.conf
|
@ -1,4 +1,4 @@
|
|||
name = nether
|
||||
description = Adds a deep underground realm with different mapgen that you can reach with obsidian portals.
|
||||
depends = stairs, default
|
||||
optional_depends = moreblocks, mesecons, loot, dungeon_loot, doc_basics, fire, climate_api, ethereal, xpanes, walls
|
||||
optional_depends = toolranks, technic, moreblocks, mesecons, loot, dungeon_loot, doc_basics, fire, climate_api, ethereal, xpanes, walls
|
||||
|
|
40
nether-compressor-recipe.lua
Normal file
40
nether-compressor-recipe.lua
Normal file
|
@ -0,0 +1,40 @@
|
|||
local S = minetest.get_translator("nether")
|
||||
|
||||
technic.register_recipe_type("compressing", { description = S("Compressing") })
|
||||
|
||||
function register_compressor_recipe(data)
|
||||
data.time = data.time or 4
|
||||
technic.register_recipe("compressing", data)
|
||||
end
|
||||
|
||||
local recipes = {
|
||||
{"nether:rack", "nether:brick",},
|
||||
{"nether:rack_deep", "nether:brick_deep"},
|
||||
{"nether:brick 9", "nether:brick_compressed", 12},
|
||||
{"nether:brick_compressed 9", "nether:nether_lump", 12}
|
||||
|
||||
}
|
||||
-- clear craft recipe
|
||||
-- But allow brick blocks to be crafted like the other bricks from Minetest Game
|
||||
|
||||
minetest.clear_craft({
|
||||
recipe = {
|
||||
{"nether:brick","nether:brick","nether:brick"},
|
||||
{"nether:brick","nether:brick","nether:brick"},
|
||||
{"nether:brick","nether:brick","nether:brick"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.clear_craft({
|
||||
recipe = {
|
||||
{"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"},
|
||||
{"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"},
|
||||
{"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"},
|
||||
}
|
||||
})
|
||||
|
||||
for _, data in pairs(recipes) do
|
||||
register_compressor_recipe({input = {data[1]}, output = data[2], time = data[3]})
|
||||
end
|
||||
|
||||
|
32
tools.lua
32
tools.lua
|
@ -153,6 +153,38 @@ minetest.register_craft({
|
|||
})
|
||||
|
||||
|
||||
if minetest.get_modpath("toolranks") then
|
||||
|
||||
local function add_toolranks(name)
|
||||
local nethertool_after_use = ItemStack(name):get_definition().after_use
|
||||
toolranks.add_tool(name)
|
||||
local toolranks_after_use = ItemStack(name):get_definition().after_use
|
||||
|
||||
if nethertool_after_use == nil or nethertool_after_use == toolranks_after_use then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.override_item(name, {
|
||||
after_use = function(itemstack, user, node, digparams)
|
||||
-- combine nethertool_after_use and toolranks_after_use by allowing
|
||||
-- nethertool_after_use() to calculate the wear...
|
||||
local initial_wear = itemstack:get_wear()
|
||||
itemstack = nethertool_after_use(itemstack, user, node, digparams)
|
||||
local wear = itemstack:get_wear() - initial_wear
|
||||
itemstack:set_wear(initial_wear) -- restore/undo the wear
|
||||
|
||||
-- ...and have toolranks_after_use() apply the wear.
|
||||
digparams.wear = wear
|
||||
return toolranks_after_use(itemstack, user, node, digparams)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
add_toolranks("nether:pick_nether")
|
||||
add_toolranks("nether:shovel_nether")
|
||||
add_toolranks("nether:axe_nether")
|
||||
add_toolranks("nether:sword_nether")
|
||||
end
|
||||
|
||||
|
||||
--===========================--
|
||||
|
|
Loading…
Reference in New Issue
Block a user