Merge pull request 'mcl_wip (API and refactoring)' (#1265) from AFCMS/MineClone2:mcl-wip-refactoring into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/1265
This commit is contained in:
AFCMS 2021-03-07 19:51:49 +00:00
commit d274f6f444
21 changed files with 78 additions and 70 deletions

@ -654,6 +654,8 @@ register_minecart(
{"mcl_minecarts:minecart", "mcl_chests:chest"}, {"mcl_minecarts:minecart", "mcl_chests:chest"},
nil, nil, false) nil, nil, false)
mcl_wip.register_wip_item("mcl_minecarts:chest_minecart")
-- Minecart with Furnace -- Minecart with Furnace
register_minecart( register_minecart(
"mcl_minecarts:furnace_minecart", "mcl_minecarts:furnace_minecart",
@ -708,6 +710,8 @@ register_minecart(
end, nil, false end, nil, false
) )
mcl_wip.register_wip_item("mcl_minecarts:furnace_minecart")
-- Minecart with Command Block -- Minecart with Command Block
register_minecart( register_minecart(
"mcl_minecarts:command_block_minecart", "mcl_minecarts:command_block_minecart",
@ -729,6 +733,8 @@ register_minecart(
nil, nil, false nil, nil, false
) )
mcl_wip.register_wip_item("mcl_minecarts:command_block_minecart")
-- Minecart with Hopper -- Minecart with Hopper
register_minecart( register_minecart(
"mcl_minecarts:hopper_minecart", "mcl_minecarts:hopper_minecart",
@ -747,6 +753,8 @@ register_minecart(
nil, nil, false nil, nil, false
) )
mcl_wip.register_wip_item("mcl_minecarts:hopper_minecart")
-- Minecart with TNT -- Minecart with TNT
register_minecart( register_minecart(
"mcl_minecarts:tnt_minecart", "mcl_minecarts:tnt_minecart",

@ -1,6 +1,6 @@
name = mcl_minecarts name = mcl_minecarts
author = Krock author = Krock
description = Minecarts are vehicles to move players quickly on rails. description = Minecarts are vehicles to move players quickly on rails.
depends = mcl_explosions, mcl_core, mcl_sounds, mcl_player, mcl_achievements, mcl_chests, mcl_furnaces, mesecons_commandblock, mcl_hoppers, mcl_tnt, mesecons depends = mcl_explosions, mcl_core, mcl_sounds, mcl_player, mcl_achievements, mcl_chests, mcl_furnaces, mesecons_commandblock, mcl_hoppers, mcl_tnt, mesecons, mcl_wip
optional_depends = doc_identifier optional_depends = doc_identifier

@ -293,6 +293,8 @@ minetest.register_craftitem("mcl_paintings:painting", {
end, end,
}) })
mcl_wip.register_wip_item("mcl_paintings:painting")
minetest.register_craft({ minetest.register_craft({
output = "mcl_paintings:painting", output = "mcl_paintings:painting",
recipe = { recipe = {

@ -1,4 +1,5 @@
name = mcl_paintings name = mcl_paintings
author = Wuzzy author = Wuzzy
description = The paintings mod for MCL2 description = The paintings mod for MCL2
depends = mcl_wip

@ -105,3 +105,5 @@ mobs:register_arrow("mobs_mc:dragon_fireball", {
}) })
mobs:register_egg("mobs_mc:enderdragon", S("Ender Dragon"), "mobs_mc_spawn_icon_dragon.png", 0, true) mobs:register_egg("mobs_mc:enderdragon", S("Ender Dragon"), "mobs_mc_spawn_icon_dragon.png", 0, true)
mcl_wip.register_wip_item("mobs_mc:enderdragon")

@ -1,6 +1,6 @@
name = mobs_mc name = mobs_mc
author = maikerumine author = maikerumine
description = Adds Minecraft-like monsters and animals. description = Adds Minecraft-like monsters and animals.
depends = mcl_init, mcl_particles, mcl_mobs depends = mcl_init, mcl_particles, mcl_mobs, mcl_wip
optional_depends = default, mcl_tnt, mcl_bows, mcl_throwing, mcl_fishing, bones, mesecons_materials, mobs_mc_gameconfig, doc_items optional_depends = default, mcl_tnt, mcl_bows, mcl_throwing, mcl_fishing, bones, mesecons_materials, mobs_mc_gameconfig, doc_items

@ -104,3 +104,5 @@ mobs:register_arrow("mobs_mc:potion_arrow", {
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:witch", S("Witch"), "mobs_mc_spawn_icon_witch.png", 0, true) mobs:register_egg("mobs_mc:witch", S("Witch"), "mobs_mc_spawn_icon_witch.png", 0, true)
mcl_wip.register_wip_item("mobs_mc:witch")

@ -106,3 +106,5 @@ mobs:register_arrow("mobs_mc:wither_skull", {
--Spawn egg --Spawn egg
mobs:register_egg("mobs_mc:wither", S("Wither"), "mobs_mc_spawn_icon_wither.png", 0, true) mobs:register_egg("mobs_mc:wither", S("Wither"), "mobs_mc_spawn_icon_wither.png", 0, true)
mcl_wip.register_wip_item("mobs_mc:wither")

@ -303,6 +303,7 @@ for _, state in pairs{mesecon.state.on, mesecon.state.off} do
end end
minetest.register_node(nodename, nodedef) minetest.register_node(nodename, nodedef)
mcl_wip.register_wip_item(nodename)
end end
end end

@ -1 +1,2 @@
name = mcl_comparators name = mcl_comparators
depends = mcl_wip

@ -1,5 +0,0 @@
mcl_sounds
mcl_util
doc_items
mcl_worlds
mcl_structures

@ -0,0 +1,2 @@
name = mcl_end
depends = screwdriver, mcl_sounds, mcl_util, doc_items, mcl_worlds, mcl_structures

@ -28,6 +28,8 @@ minetest.register_craftitem("mcl_maps:empty_map", {
stack_max = 64, stack_max = 64,
}) })
mcl_wip.register_wip_item("mcl_maps:empty_map")
local function has_item_in_hotbar(player, item) local function has_item_in_hotbar(player, item)
-- Requirement: player carries the tool in the hotbar -- Requirement: player carries the tool in the hotbar
local inv = player:get_inventory() local inv = player:get_inventory()

@ -1 +1,2 @@
name = mcl_maps name = mcl_maps
depends = mcl_wip

@ -455,3 +455,12 @@ function mcl_potions.get_alchemy(ingr, pot)
return false return false
end end
mcl_wip.register_wip_item("mcl_potions:night_vision")
mcl_wip.register_wip_item("mcl_potions:night_vision_plus")
mcl_wip.register_wip_item("mcl_potions:night_vision_splash")
mcl_wip.register_wip_item("mcl_potions:night_vision_plus_splash")
mcl_wip.register_wip_item("mcl_potions:night_vision_lingering")
mcl_wip.register_wip_item("mcl_potions:night_vision_plus_lingering")
mcl_wip.register_wip_item("mcl_potions:night_vision_arrow")
mcl_wip.register_wip_item("mcl_potions:night_vision_plus_arrow")

@ -1,2 +1,2 @@
name = mcl_potions name = mcl_potions
depends = mcl_core, mcl_farming, mcl_mobitems, mcl_fishing, mcl_bows, mcl_end, mcl_weather, playerphysics depends = mcl_core, mcl_farming, mcl_mobitems, mcl_fishing, mcl_bows, mcl_end, mcl_weather, playerphysics, mcl_wip

@ -187,6 +187,7 @@ minetest.register_tool("screwdriver:screwdriver", {
end, end,
}) })
mcl_wip.register_wip_item("screwdriver:screwdriver")
minetest.register_craft({ minetest.register_craft({
output = "screwdriver:screwdriver", output = "screwdriver:screwdriver",

@ -0,0 +1,2 @@
name = screwdriver
depends = mcl_wip

@ -106,4 +106,5 @@ if minetest.is_creative_enabled("") then
build_a_settlement(minp, maxp, math.random(0,32767)) build_a_settlement(minp, maxp, math.random(0,32767))
end end
}) })
mcl_wip.register_experimental_item("mcl_villages:tool")
end end

@ -2,68 +2,44 @@
local S = minetest.get_translator("mcl_wip") local S = minetest.get_translator("mcl_wip")
local wip_items = { mcl_wip = {}
"mcl_maps:empty_map", mcl_wip.registered_wip_items = {}
"mcl_comparators:comparator_off_comp", mcl_wip.registered_experimental_items = {}
"mcl_minecarts:hopper_minecart",
"mcl_minecarts:command_block_minecart",
"mcl_minecarts:chest_minecart",
"mcl_minecarts:furnace_minecart",
"mobs_mc:enderdragon",
"mobs_mc:wither",
"mobs_mc:witch",
"screwdriver:screwdriver",
"mcl_paintings:painting",
"mcl_potions:night_vision",
"mcl_potions:night_vision_plus",
-- "mcl_potions:weakness",
-- "mcl_potions:weakness_plus",
-- "mcl_potions:strength",
-- "mcl_potions:strength_plus",
-- "mcl_potions:strength_2",
"mcl_potions:night_vision_splash",
"mcl_potions:night_vision_plus_splash",
-- "mcl_potions:weakness_splash",
-- "mcl_potions:weakness_plus_splash",
-- "mcl_potions:strength_splash",
-- "mcl_potions:strength_plus_splash",
-- "mcl_potions:strength_2_splash",
"mcl_potions:night_vision_lingering",
"mcl_potions:night_vision_plus_lingering",
-- "mcl_potions:weakness_lingering",
-- "mcl_potions:weakness_plus_lingering",
-- "mcl_potions:strength_lingering",
-- "mcl_potions:strength_plus_lingering",
-- "mcl_potions:strength_2_lingering",
"mcl_potions:night_vision_arrow",
"mcl_potions:night_vision_plus_arrow",
}
local experimental_items = {
}
for i=1,#wip_items do function mcl_wip.register_wip_item(itemname)
local def = minetest.registered_items[wip_items[i]] table.insert(mcl_wip.registered_wip_items, itemname) --Only check for valid node name after mods loaded
end
function mcl_wip.register_experimental_item(itemname)
table.insert(mcl_wip.registered_experimental_items, itemname)
end
minetest.register_on_mods_loaded(function()
for _,name in pairs(mcl_wip.registered_wip_items) do
local def = minetest.registered_items[name]
if not def then if not def then
minetest.log("error", "[mcl_wip] Unknown item: "..wip_items[i]) minetest.log("error", "[mcl_wip] Unknown item: "..name)
break break
end end
local new_description = def.description local new_description = def.description
local new_groups = table.copy(def.groups)
if new_description == "" then if new_description == "" then
new_description = wip_items[i] new_description = name
end end
new_description = new_description .. "\n"..core.colorize("#FF0000", S("(WIP)")) new_description = new_description .. "\n"..minetest.colorize(mcl_colors.RED, S("(WIP)"))
--new_groups.not_in_craft_guide = 1 minetest.override_item(name, {description = new_description})
minetest.override_item(wip_items[i], { description = new_description, groups = new_groups })
end end
for i=1,#experimental_items do for _,name in pairs(mcl_wip.registered_experimental_items) do
local def = minetest.registered_items[experimental_items[i]] local def = minetest.registered_items[name]
if not def then if not def then
minetest.log("error", "[mcl_wip] Unknown item: "..experimental_items[i]) minetest.log("error", "[mcl_wip] Unknown item: "..name)
break break
end end
local new_description = def.description local new_description = def.description
new_description = new_description .. "\n"..core.colorize("#FFFF00", S("(Temporary)")) if new_description == "" then
minetest.override_item(experimental_items[i], { description = new_description }) new_description = name
end end
new_description = new_description .. "\n"..minetest.colorize(mcl_colors.YELLOW, S("(Temporary)"))
minetest.override_item(name, {description = new_description})
end
end)

@ -1,4 +1,4 @@
name = mcl_wip name = mcl_wip
author = Wuzzy author = Wuzzy
description = Development mod for MineClone 2 which add a “WIP” (Work In Progress) comment to items which are considered to be very unfinished. description = Development mod for MineClone 2 which add a “WIP” (Work In Progress) comment to items which are considered to be very unfinished.
depends = mcl_core, mcl_fishing, mcl_maps, mcl_minecarts, doc_identifier, mobs_mc, mcl_minecarts, mcl_paintings, mcl_potions depends = mcl_colors