Introduce compatibility with mcl_rubber mod

Closes #1
This commit is contained in:
mrkubax10 2024-02-26 17:06:11 +01:00
parent 7df191097d
commit d2346f65aa
7 changed files with 334 additions and 309 deletions

View File

@ -160,16 +160,16 @@ minetest.register_craft({
output="industrialtest:insulated_tin_cable", output="industrialtest:insulated_tin_cable",
recipe={ recipe={
"industrialtest:tin_cable", "industrialtest:tin_cable",
"industrialtest:rubber" industrialtest.elementKeys.rubber
} }
}) })
minetest.register_craft({ minetest.register_craft({
type="shaped", type="shaped",
output="industrialtest:insulated_tin_cable 6", output="industrialtest:insulated_tin_cable 6",
recipe={ recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}, {industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{industrialtest.elementKeys.tinIngot,industrialtest.elementKeys.tinIngot,industrialtest.elementKeys.tinIngot}, {industrialtest.elementKeys.tinIngot,industrialtest.elementKeys.tinIngot,industrialtest.elementKeys.tinIngot},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"} {industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
} }
}) })
industrialtest.api.registerCableFormerRecipe({ industrialtest.api.registerCableFormerRecipe({
@ -191,16 +191,16 @@ minetest.register_craft({
output="industrialtest:insulated_copper_cable", output="industrialtest:insulated_copper_cable",
recipe={ recipe={
"industrialtest:copper_cable", "industrialtest:copper_cable",
"industrialtest:rubber" industrialtest.elementKeys.rubber
} }
}) })
minetest.register_craft({ minetest.register_craft({
type="shaped", type="shaped",
output="industrialtest:insulated_copper_cable 6", output="industrialtest:insulated_copper_cable 6",
recipe={ recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}, {industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{industrialtest.elementKeys.copperIngot,industrialtest.elementKeys.copperIngot,industrialtest.elementKeys.copperIngot}, {industrialtest.elementKeys.copperIngot,industrialtest.elementKeys.copperIngot,industrialtest.elementKeys.copperIngot},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"} {industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
} }
}) })
industrialtest.api.registerCableFormerRecipe({ industrialtest.api.registerCableFormerRecipe({
@ -221,16 +221,16 @@ minetest.register_craft({
output="industrialtest:insulated_gold_cable", output="industrialtest:insulated_gold_cable",
recipe={ recipe={
"industrialtest:gold_cable", "industrialtest:gold_cable",
"industrialtest:rubber" industrialtest.elementKeys.rubber
} }
}) })
minetest.register_craft({ minetest.register_craft({
type="shaped", type="shaped",
output="industrialtest:insulated_gold_cable 6", output="industrialtest:insulated_gold_cable 6",
recipe={ recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}, {industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{industrialtest.elementKeys.goldIngot,industrialtest.elementKeys.goldIngot,industrialtest.elementKeys.goldIngot}, {industrialtest.elementKeys.goldIngot,industrialtest.elementKeys.goldIngot,industrialtest.elementKeys.goldIngot},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"} {industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
} }
}) })
industrialtest.api.registerCableFormerRecipe({ industrialtest.api.registerCableFormerRecipe({
@ -251,16 +251,16 @@ minetest.register_craft({
output="industrialtest:insulated_iron_cable", output="industrialtest:insulated_iron_cable",
recipe={ recipe={
"industrialtest:iron_cable", "industrialtest:iron_cable",
"industrialtest:rubber" industrialtest.elementKeys.rubber
} }
}) })
minetest.register_craft({ minetest.register_craft({
type="shaped", type="shaped",
output="industrialtest:insulated_iron_cable 6", output="industrialtest:insulated_iron_cable 6",
recipe={ recipe={
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}, {industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber},
{"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"}, {"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"},
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"} {industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber,industrialtest.elementKeys.rubber}
} }
}) })
industrialtest.api.registerCableFormerRecipe({ industrialtest.api.registerCableFormerRecipe({

View File

@ -33,7 +33,14 @@ for _,mod in ipairs(requiredMclModules) do
end end
end end
if industrialtest.mtgAvailable and not minetest.get_modpath("3d_armor") then industrialtest.mods={}
if industrialtest.mtgAvailable then
industrialtest.mods._3dArmor=minetest.get_modpath("3d_armor")
elseif industrialtest.mclAvailable then
industrialtest.mods.mclRubber=minetest.get_modpath("mcl_rubber")
end
if industrialtest.mtgAvailable and not industrialtest then
error("IndustrialTest requires 3D Armor when used with Minetest Game") error("IndustrialTest requires 3D Armor when used with Minetest Game")
end end
@ -552,6 +559,11 @@ if industrialtest.mclAvailable then
industrialtest.elementKeys.cactus="mcl_core:cactus" industrialtest.elementKeys.cactus="mcl_core:cactus"
industrialtest.elementKeys.groupSapling="group:sapling" industrialtest.elementKeys.groupSapling="group:sapling"
industrialtest.elementKeys.groupLeaves="group:leaves" industrialtest.elementKeys.groupLeaves="group:leaves"
industrialtest.elementKeys.stickyResin=(industrialtest.mods.mclRubber and "mcl_rubber:rubber_raw" or "industrialtest:sticky_resin")
industrialtest.elementKeys.rubber=(industrialtest.mods.mclRubber and "mcl_rubber:rubber" or "industrialtest:rubber")
industrialtest.elementKeys.rubberWood=(industrialtest.mods.mclRubber and "mcl_rubber:rubbertree" or "industrialtest:rubber_wood")
industrialtest.elementKeys.rubberSapling=(industrialtest.mods.mclRubber and "mcl_rubber:rubbersapling" or "industrialtest:rubber_sapling")
industrialtest.elementKeys.treetap=(industrialtest.mods.mclRubber and "mcl_rubber:treetap" or "industrialtest:treetap")
-- 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)
@ -781,6 +793,11 @@ elseif industrialtest.mtgAvailable then
industrialtest.elementKeys.cactus="default:cactus" industrialtest.elementKeys.cactus="default:cactus"
industrialtest.elementKeys.groupSapling="group:sapling" industrialtest.elementKeys.groupSapling="group:sapling"
industrialtest.elementKeys.groupLeaves="group:leaves" industrialtest.elementKeys.groupLeaves="group:leaves"
industrialtest.elementKeys.stickyResin="industrialtest:sticky_resin"
industrialtest.elementKeys.rubber="industrialtest:rubber"
industrialtest.elementKeys.rubberWood="industrialtest:rubber_wood"
industrialtest.elementKeys.rubberSapling="industrialtest:rubber_sapling"
industrialtest.elementKeys.treetap="industrialtest:treetap"
else else
error("No compatible games found!") error("No compatible games found!")
end end

View File

@ -117,31 +117,33 @@ minetest.register_craft({
} }
}) })
minetest.register_craftitem("industrialtest:sticky_resin",{ if not industrialtest.mods.mclRubber then
minetest.register_craftitem("industrialtest:sticky_resin",{
description=S("Sticky Resin"), description=S("Sticky Resin"),
inventory_image="industrialtest_sticky_resin.png" inventory_image="industrialtest_sticky_resin.png"
}) })
minetest.register_craftitem("industrialtest:rubber",{ minetest.register_craftitem("industrialtest:rubber",{
description=S("Rubber"), description=S("Rubber"),
inventory_image="industrialtest_rubber.png" inventory_image="industrialtest_rubber.png"
}) })
minetest.register_craft({ minetest.register_craft({
type="cooking", type="cooking",
output="industrialtest:rubber", output="industrialtest:rubber",
recipe="industrialtest:sticky_resin" recipe="industrialtest:sticky_resin"
})
end
industrialtest.api.registerExtractorRecipe({
output=industrialtest.elementKeys.rubber,
recipe=industrialtest.elementKeys.rubberWood
}) })
industrialtest.api.registerExtractorRecipe({ industrialtest.api.registerExtractorRecipe({
output="industrialtest:rubber", output=industrialtest.elementKeys.rubber,
recipe="industrialtest:rubber_wood" recipe=industrialtest.elementKeys.rubberSapling
}) })
industrialtest.api.registerExtractorRecipe({ industrialtest.api.registerExtractorRecipe({
output="industrialtest:rubber", output=industrialtest.elementKeys.rubber.." 3",
recipe="industrialtest:rubber_sapling" recipe=industrialtest.elementKeys.stickyResin
})
industrialtest.api.registerExtractorRecipe({
output="industrialtest:rubber 3",
recipe="industrialtest:sticky_resin"
}) })
minetest.register_craftitem("industrialtest:raw_carbon_fibre",{ minetest.register_craftitem("industrialtest:raw_carbon_fibre",{

View File

@ -31,7 +31,7 @@ minetest.register_craft({
type="shaped", type="shaped",
output="industrialtest:extractor", output="industrialtest:extractor",
recipe={ recipe={
{"industrialtest:treetap","industrialtest:machine_block","industrialtest:treetap"}, {industrialtest.elementKeys.treetap,"industrialtest:machine_block",industrialtest.elementKeys.treetap},
{"industrialtest:treetap","industrialtest:electronic_circuit","industrialtest:treetap"} {industrialtest.elementKeys.treetap,"industrialtest:electronic_circuit",industrialtest.elementKeys.treetap}
} }
}) })

View File

@ -15,7 +15,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
minetest.register_on_generated(function(minp,maxp,seed) minetest.register_on_generated(function(minp,maxp,seed)
if industrialtest.random:next(1,100)>40 then if industrialtest.mods.mclRubber or industrialtest.random:next(1,100)>40 then
return return
end end
local center=vector.new((maxp.x-minp.x)/2+ minp.x,(maxp.y-minp.y)/2+minp.y,(maxp.z-minp.z)/2+minp.z) local center=vector.new((maxp.x-minp.x)/2+ minp.x,(maxp.y-minp.y)/2+minp.y,(maxp.z-minp.z)/2+minp.z)

View File

@ -66,7 +66,8 @@ minetest.register_craft({
} }
}) })
definition={ if not industrialtest.mods.mclRubber then
definition={
description=S("Rubber Wood"), description=S("Rubber Wood"),
tiles={ tiles={
"industrialtest_rubber_wood_top.png", "industrialtest_rubber_wood_top.png",
@ -74,8 +75,8 @@ definition={
"industrialtest_rubber_wood_side.png" "industrialtest_rubber_wood_side.png"
}, },
paramtype2="4dir" paramtype2="4dir"
} }
if industrialtest.mtgAvailable then if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_wood_defaults() definition.sounds=default.node_sound_wood_defaults()
definition.groups={ definition.groups={
tree=1, tree=1,
@ -83,7 +84,7 @@ if industrialtest.mtgAvailable then
oddly_breakable_by_hand=1, oddly_breakable_by_hand=1,
flammable=2 flammable=2
} }
elseif industrialtest.mclAvailable then elseif industrialtest.mclAvailable then
definition.sounds=mcl_sounds.node_sound_wood_defaults() definition.sounds=mcl_sounds.node_sound_wood_defaults()
definition.groups={ definition.groups={
handy=1, handy=1,
@ -98,26 +99,26 @@ elseif industrialtest.mclAvailable then
definition.after_destruct=mcl_core.update_leaves definition.after_destruct=mcl_core.update_leaves
definition._mcl_blast_resistance=1.8 definition._mcl_blast_resistance=1.8
definition._mcl_hardness=1.8 definition._mcl_hardness=1.8
end end
definition.groups._industrialtest_rubberWood=1 definition.groups._industrialtest_rubberWood=1
minetest.register_node("industrialtest:rubber_wood",definition) minetest.register_node("industrialtest:rubber_wood",definition)
definition=table.copy(definition) definition=table.copy(definition)
definition.description=nil definition.description=nil
definition.tiles={ definition.tiles={
"industrialtest_rubber_wood_top.png", "industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_top.png", "industrialtest_rubber_wood_top.png",
"industrialtest_rubber_wood_side.png", "industrialtest_rubber_wood_side.png",
"industrialtest_rubber_wood_side.png", "industrialtest_rubber_wood_side.png",
"industrialtest_rubber_wood_side_with_rubber.png", "industrialtest_rubber_wood_side_with_rubber.png",
"industrialtest_rubber_wood_side.png" "industrialtest_rubber_wood_side.png"
} }
definition.drop="industrialtest:rubber_wood" definition.drop="industrialtest:rubber_wood"
if industrialtest.mclAvailable then if industrialtest.mclAvailable then
definition.groups.not_in_creative_inventory=1 definition.groups.not_in_creative_inventory=1
definition._doc_items_create_entry=false definition._doc_items_create_entry=false
end end
minetest.register_node("industrialtest:rubber_wood_with_rubber",definition) minetest.register_node("industrialtest:rubber_wood_with_rubber",definition)
minetest.register_abm({ minetest.register_abm({
label="Rubber forming", label="Rubber forming",
nodenames={"industrialtest:rubber_wood"}, nodenames={"industrialtest:rubber_wood"},
interval=120, interval=120,
@ -141,13 +142,13 @@ minetest.register_abm({
param2=industrialtest.random:next(0,3) param2=industrialtest.random:next(0,3)
}) })
end end
}) })
minetest.register_craft({ minetest.register_craft({
type="shapeless", type="shapeless",
output=industrialtest.elementKeys.junglePlanks.." 3", output=industrialtest.elementKeys.junglePlanks.." 3",
recipe={"group:_industrialtest_rubberWood"} recipe={"group:_industrialtest_rubberWood"}
}) })
definition={ definition={
description=S("Rubber Leaves"), description=S("Rubber Leaves"),
drawtype="allfaces_optional", drawtype="allfaces_optional",
tiles={"industrialtest_rubber_leaves.png"}, tiles={"industrialtest_rubber_leaves.png"},
@ -155,8 +156,8 @@ definition={
paramtype="light", paramtype="light",
sunlight_propagates=true, sunlight_propagates=true,
waving=1 waving=1
} }
if industrialtest.mtgAvailable then if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_leaves_defaults() definition.sounds=default.node_sound_leaves_defaults()
definition.groups={ definition.groups={
snappy=3, snappy=3,
@ -175,7 +176,7 @@ if industrialtest.mtgAvailable then
} }
} }
definition.after_place_node=default.after_place_leaves definition.after_place_node=default.after_place_leaves
elseif industrialtest.mclAvailable then elseif industrialtest.mclAvailable then
local saplingChances={20,16,12,10} local saplingChances={20,16,12,10}
local stickChances={50,45,30,35,10} local stickChances={50,45,30,35,10}
-- Taken and adapted from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_core/nodes_trees.lua#L157 -- Taken and adapted from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_core/nodes_trees.lua#L157
@ -220,16 +221,16 @@ elseif industrialtest.mclAvailable then
definition._mcl_hardness=0.2 definition._mcl_hardness=0.2
definition._mcl_silk_touch_drop=true definition._mcl_silk_touch_drop=true
definition._mcl_fortune_drop={getDrops(1),getDrops(2),getDrops(3),getDrops(4)} definition._mcl_fortune_drop={getDrops(1),getDrops(2),getDrops(3),getDrops(4)}
end end
minetest.register_node("industrialtest:rubber_leaves",definition) minetest.register_node("industrialtest:rubber_leaves",definition)
if industrialtest.mtgAvailable then if industrialtest.mtgAvailable then
default.register_leafdecay({ default.register_leafdecay({
trunks={"industrialtest:rubber_wood"}, trunks={"industrialtest:rubber_wood"},
leaves={"industrialtest:rubber_leaves"}, leaves={"industrialtest:rubber_leaves"},
radius=2 radius=2
}) })
end end
if industrialtest.mclAvailable then if industrialtest.mclAvailable then
definition=table.copy(definition) definition=table.copy(definition)
definition._doc_items_create_entry=false definition._doc_items_create_entry=false
definition.groups.not_in_creative_inventory=1 definition.groups.not_in_creative_inventory=1
@ -237,8 +238,8 @@ if industrialtest.mclAvailable then
definition._mcl_shears_drop={"industrialtest:rubber_leaves"} definition._mcl_shears_drop={"industrialtest:rubber_leaves"}
definition._mcl_silk_touch_drop={"industrialtest:rubber_leaves"} definition._mcl_silk_touch_drop={"industrialtest:rubber_leaves"}
minetest.register_node("industrialtest:rubber_leaves_orphan",definition) minetest.register_node("industrialtest:rubber_leaves_orphan",definition)
end end
industrialtest.makeRubberTree=function(pos) industrialtest.makeRubberTree=function(pos)
-- FIXME: Replace this with placing schematic -- FIXME: Replace this with placing schematic
-- Taken and adapted from https://github.com/minetest/minetest_game/blob/master/mods/default/trees.lua#L182 -- Taken and adapted from https://github.com/minetest/minetest_game/blob/master/mods/default/trees.lua#L182
local height=industrialtest.random:next(4,5) local height=industrialtest.random:next(4,5)
@ -297,8 +298,8 @@ industrialtest.makeRubberTree=function(pos)
manip:set_data(data) manip:set_data(data)
manip:write_to_map() manip:write_to_map()
manip:update_map() manip:update_map()
end end
definition={ definition={
description=S("Rubber Sapling"), description=S("Rubber Sapling"),
inventory_image="industrialtest_rubber_sapling.png", inventory_image="industrialtest_rubber_sapling.png",
wield_image="industrialtest_rubber_sapling.png", wield_image="industrialtest_rubber_sapling.png",
@ -333,8 +334,8 @@ definition={
return false return false
end end
} }
if industrialtest.mtgAvailable then if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_leaves_defaults() definition.sounds=default.node_sound_leaves_defaults()
definition.groups={ definition.groups={
snappy=2, snappy=2,
@ -343,7 +344,7 @@ if industrialtest.mtgAvailable then
definition.on_construct=function(pos) definition.on_construct=function(pos)
minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500)) minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500))
end end
elseif industrialtest.mclAvailable then elseif industrialtest.mclAvailable then
definition.sounds=mcl_sounds.node_sound_leaves_defaults() definition.sounds=mcl_sounds.node_sound_leaves_defaults()
definition.groups={ definition.groups={
plant=1, plant=1,
@ -358,12 +359,12 @@ elseif industrialtest.mclAvailable then
local meta=minetest.get_meta(pos) local meta=minetest.get_meta(pos)
meta:set_int("stage",0) meta:set_int("stage",0)
end end
end end
definition.groups.attached_node=1 definition.groups.attached_node=1
definition.groups.dig_immediate=3 definition.groups.dig_immediate=3
definition.groups.sapling=1 definition.groups.sapling=1
minetest.register_node("industrialtest:rubber_sapling",definition) minetest.register_node("industrialtest:rubber_sapling",definition)
if industrialtest.mtgAvailable then if industrialtest.mtgAvailable then
minetest.register_lbm({ minetest.register_lbm({
name="industrialtest:rubber_sapling_lbm", name="industrialtest:rubber_sapling_lbm",
nodenames={"industrialtest:rubber_sapling"}, nodenames={"industrialtest:rubber_sapling"},
@ -371,4 +372,5 @@ if industrialtest.mtgAvailable then
minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500)) minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500))
end end
}) })
end
end end

View File

@ -14,6 +14,10 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
if industrialtest.mods.mclRubber then
return
end
local S=minetest.get_translator("industrialtest") local S=minetest.get_translator("industrialtest")
local function onTreetapUse(user,pointed) local function onTreetapUse(user,pointed)