From 5acffc4364800caf735e7c04bdf2cdbbcfc28d95 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Tue, 14 May 2024 01:07:32 +0000 Subject: [PATCH] Initial compressed block API and several compressed block series --- mods/ITEMS/mcl_compressed_blocks/init.lua | 145 ++++++++++++++++++- mods/ITEMS/mcl_compressed_blocks/mod.conf | 3 +- mods/ITEMS/mcl_compressed_blocks/nodes.lua | 121 ---------------- mods/ITEMS/mcl_compressed_blocks/recipes.lua | 127 ---------------- 4 files changed, 145 insertions(+), 251 deletions(-) delete mode 100644 mods/ITEMS/mcl_compressed_blocks/nodes.lua delete mode 100644 mods/ITEMS/mcl_compressed_blocks/recipes.lua diff --git a/mods/ITEMS/mcl_compressed_blocks/init.lua b/mods/ITEMS/mcl_compressed_blocks/init.lua index e81c7f4a0..7c97d0ad1 100644 --- a/mods/ITEMS/mcl_compressed_blocks/init.lua +++ b/mods/ITEMS/mcl_compressed_blocks/init.lua @@ -1,5 +1,146 @@ local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) +local mod = {} +mcl_compressed_block = mod -dofile(modpath.."/nodes.lua") -dofile(modpath.."/recipes.lua") +local LABELS = { + [0] = "@1", + "Compressed @1", + "Double Compressed @1", + "Triple Compressed @1", + "Quadruple Compressed @1", + "Quintuple Compressed @1", + "Sextuple Compressed @1", + "Septuple Compressed @1", + "Octuple Compressed @1", +} +local NODE_NAMES = { + [0] = "", + "compressed_", + "double_compressed_", + "triple_compressed_", + "quadruple_compressed_", + "quintuple_compressed_", + "sextuple_compressed_", + "septuple_compressed_", + "octuple_compressed_", +} +local BLAST_RESISTENCE = { + 11, 19, 33, 58, 102, 179, 313, 548, +} +local HARDNESS = { + 3, 4, 5, 7, 9, 12, 16, 21, +} + +local block_name = "Cobblestone" +function mod.register_block_compression(base_block, block_name, max_levels, final_drops) + local base_nodedef = minetest.registered_nodes[base_block] + assert(base_nodedef) + + local prev_name = base_block + for i = 1,(max_levels-1) do + local overlay_level = math.ceil(i/max_levels * 8) + local name = "mcl_compressed_blocks:"..NODE_NAMES[i]..block_name + + minetest.register_node(name,{ + description = S(LABELS[i], base_nodedef.description), + _doc_items_longdesc = ( + "@1 is a decorative block made from 9 @2. It is useful for saving space in your inventories." + ):gsub("@1",LABELS[i]:gsub("@1",block_name)):gsub("@2",LABELS[i-1]:gsub("@1",block_name)), + _doc_items_hidden = false, + tiles = {base_nodedef.tiles[1].."^mcl_compressed_blocks_"..tostring(overlay_level).."x_overlay.png"}, + is_ground_content = true, + stack_max = 64, + groups = {pickaxey=1, stone=1, building_block=1}, + sounds = base_nodedef.sounds, + _mcl_blast_resistance = BLAST_RESISTENCE[i], + _mcl_hardness = HARDNESS[i], + }) + + minetest.register_craft({ + output = name, + recipe = { + { prev_name, prev_name, prev_name }, + { prev_name, prev_name, prev_name }, + { prev_name, prev_name, prev_name }, + }, + }) + minetest.register_craft({ + output = prev_name .. " 9", + recipe = { + { name }, + }, + }) + prev_name = name + end + + -- Compression Terminal Block + local name = "mcl_compressed_blocks:"..NODE_NAMES[max_levels]..block_name + minetest.register_node(name,{ + description = S(LABELS[max_levels], base_nodedef.description), + _doc_items_longdesc = ( + "@1 is a decorative block made from 9 @2. It is useful for saving space in your inventories." + ):gsub("@1",LABELS[max_levels]:gsub("@1",block_name)):gsub("@2",LABELS[max_levels-1]:gsub("@1",block_name)), + _doc_items_hidden = false, + tiles = {base_nodedef.tiles[1].."^mcl_compressed_blocks_8x_overlay.png"}, + is_ground_content = true, + stack_max = 64, + groups = {pickaxey=1, stone=1, building_block=1}, + drop = final_drops, + sounds = base_nodedef.sounds, + _mcl_blast_resistance = BLAST_RESISTENCE[max_levels], + _mcl_hardness = HARDNESS[max_levels], + _mcl_silk_touch_drop = true, + }) + minetest.register_craft({ + output = name, + recipe = { + { prev_name, prev_name, prev_name }, + { prev_name, prev_name, prev_name }, + { prev_name, prev_name, prev_name }, + }, + }) + minetest.register_craft({ + output = prev_name .. " 9", + recipe = { + { name }, + }, + }) +end + +mod.register_block_compression("mcl_core:cobble", "cobblestone", 8, { + max_items = 2, + items = { + {items = {"mcl_core:diamond 9"}}, + {items = {"mcl_nether:netherite_scrap 18"}}, + }, +}) +mod.register_block_compression("mcl_deepslate:deepslate_cobbled", "deepslate_cobbled", 8, { + max_items = 2, + items = { + {items = {"mcl_core:diamond 9"}}, + {items = {"mcl_nether:netherite_scrap 18"}}, + }, +}) +mod.register_block_compression("mcl_core:granite", "granite", 5, { + max_items = 2, + items = { + {items = {"mcl_core:diamond 9"}}, + {items = {"mcl_nether:netherite_scrap 18"}}, + }, +}) +mod.register_block_compression("mcl_core:diorite", "diorite", 6, { + max_items = 2, + items = { + {items = {"mcl_core:diamond 9"}}, + {items = {"mcl_nether:netherite_scrap 18"}}, + }, +}) +mod.register_block_compression("mcl_core:andesite", "andesite", 6, { + max_items = 2, + items = { + {items = {"mcl_core:diamond 9"}}, + {items = {"mcl_nether:netherite_scrap 18"}}, + }, +}) diff --git a/mods/ITEMS/mcl_compressed_blocks/mod.conf b/mods/ITEMS/mcl_compressed_blocks/mod.conf index d3c5771c9..08a771413 100644 --- a/mods/ITEMS/mcl_compressed_blocks/mod.conf +++ b/mods/ITEMS/mcl_compressed_blocks/mod.conf @@ -1,3 +1,4 @@ name = mcl_compressed_blocks -depends = mcl_core +depends = mcl_core, mcl_deepslate description = adds compressed blocks to voxelibre + diff --git a/mods/ITEMS/mcl_compressed_blocks/nodes.lua b/mods/ITEMS/mcl_compressed_blocks/nodes.lua deleted file mode 100644 index 32c47bfd4..000000000 --- a/mods/ITEMS/mcl_compressed_blocks/nodes.lua +++ /dev/null @@ -1,121 +0,0 @@ ---Compressed Cobblestone -minetest.register_node("mcl_compressed_blocks:compressed_cobblestone", { - description = "Compressed Cobblestone", - _doc_items_longdesc = ("Compressed Cobblestone is a decorative block made from 9 Cobblestone. It is useful for saving space in your inventories."), - _doc_items_hidden = false, - tiles = {"mcl_compressed_blocks_compressed_cobblestone.png"}, - is_ground_content = true, - stack_max = 64, - groups = {pickaxey=1, stone=1, building_block=1}, - sounds = mcl_sounds.node_sound_stone_defaults(), - _mcl_blast_resistance = 11, - _mcl_hardness = 3, -}) - ---Double Compressed Cobble -minetest.register_node("mcl_compressed_blocks:double_compressed_cobblestone", { - description = "Double Compressed Cobblestone", - _doc_items_longdesc = ("Double Compressed Cobblestone is a decorative block made from 9 Compressed Cobblestone. It is useful for saving space in your inventories."), - _doc_items_hidden = false, - tiles = {"mcl_compressed_blocks_double_compressed_cobblestone.png"}, - is_ground_content = true, - stack_max = 64, - groups = {pickaxey=1, stone=1, building_block=1}, - sounds = mcl_sounds.node_sound_stone_defaults(), - _mcl_blast_resistance = 19, - _mcl_hardness = 4, -}) - ---Triple Compressed Cobble -minetest.register_node("mcl_compressed_blocks:triple_compressed_cobblestone", { - description = "Triple Compressed Cobblestone", - _doc_items_longdesc = ("Triple Compressed Cobblestone is a decorative block made from 9 Double Compressed Cobblestone. It is useful for saving space in your inventories."), - _doc_items_hidden = false, - tiles = {"mcl_compressed_blocks_triple_compressed_cobblestone.png"}, - is_ground_content = true, - stack_max = 64, - groups = {pickaxey=1, stone=1, building_block=1}, - sounds = mcl_sounds.node_sound_stone_defaults(), - _mcl_blast_resistance = 33, - _mcl_hardness = 5, -}) - ---Quadruple Compressed Cobble -minetest.register_node("mcl_compressed_blocks:quadruple_compressed_cobblestone", { - description = "Quadruple Compressed Cobblestone", - _doc_items_longdesc = ("Quadruple Compressed Cobblestone is a decorative block made from 9 Triple Compressed Cobblestone. It is useful for saving space in your inventories."), - _doc_items_hidden = false, - tiles = {"mcl_compressed_blocks_quadruple_compressed_cobblestone.png"}, - is_ground_content = true, - stack_max = 64, - groups = {pickaxey=1, stone=1, building_block=1}, - sounds = mcl_sounds.node_sound_stone_defaults(), - _mcl_blast_resistance = 58, - _mcl_hardness = 7, -}) - ---Quintuple Compressed Cobble -minetest.register_node("mcl_compressed_blocks:quintuple_compressed_cobblestone", { - description = "Quintuple Compressed Cobblestone", - _doc_items_longdesc = ("Quintuple Compressed Cobblestone is a decorative block made from 9 Quadruple Compressed Cobblestone. It is useful for saving space in your inventories."), - _doc_items_hidden = false, - tiles = {"mcl_compressed_blocks_quintuple_compressed_cobblestone.png"}, - is_ground_content = true, - stack_max = 64, - groups = {pickaxey=1, stone=1, building_block=1}, - sounds = mcl_sounds.node_sound_stone_defaults(), - _mcl_blast_resistance = 102, - _mcl_hardness = 9, -}) - ---Sextuple Compressed Cobble -minetest.register_node("mcl_compressed_blocks:sextuple_compressed_cobblestone", { - description = "Sextuple Compressed Cobblestone", - _doc_items_longdesc = ("Sextuple Compressed Cobblestone is a decorative block made from 9 Quintuple Compressed Cobblestone. It is useful for saving space in your inventories."), - _doc_items_hidden = false, - tiles = {"mcl_compressed_blocks_sextuple_compressed_cobblestone.png"}, - is_ground_content = true, - stack_max = 64, - groups = {pickaxey=1, stone=1, building_block=1}, - sounds = mcl_sounds.node_sound_stone_defaults(), - _mcl_blast_resistance = 179, - _mcl_hardness = 12, -}) - ---Septuple Compressed Cobble -minetest.register_node("mcl_compressed_blocks:septuple_compressed_cobblestone", { - description = "Septuple Compressed Cobblestone", - _doc_items_longdesc = ("Septuple Compressed Cobblestone is a decorative block made from 9 Sextuple Compressed Cobblestone. It is useful for saving space in your inventories."), - _doc_items_hidden = false, - tiles = {"mcl_compressed_blocks_septuple_compressed_cobblestone.png"}, - is_ground_content = true, - stack_max = 64, - groups = {pickaxey=1, stone=1, building_block=1}, - sounds = mcl_sounds.node_sound_stone_defaults(), - _mcl_blast_resistance = 313, - _mcl_hardness = 16, -}) - ---Ocutple Compressed Cobble -minetest.register_node("mcl_compressed_blocks:octuple_compressed_cobblestone", { - description = "Octuple Compressed Cobblestone", - _doc_items_longdesc = ("Octuple Compressed Cobblestone is a decorative block made from 9 Septuple Compressed Cobblestone. It is useful for saving space in your inventories."), - _doc_items_hidden = false, - tiles = {"mcl_compressed_blocks_octuple_compressed_cobblestone.png"}, - is_ground_content = true, - stack_max = 64, - groups = {pickaxey=1, stone=1, building_block=1}, - drop = { - - max_items = 2, - items = { - {items = {"mcl_core:diamond 9"}}, - {items = {"mcl_nether:netherite_scrap 18"}}, - }, - }, - - sounds = mcl_sounds.node_sound_stone_defaults(), - _mcl_blast_resistance = 548, - _mcl_hardness = 21, - _mcl_silk_touch_drop = true, -}) diff --git a/mods/ITEMS/mcl_compressed_blocks/recipes.lua b/mods/ITEMS/mcl_compressed_blocks/recipes.lua deleted file mode 100644 index a02e8c612..000000000 --- a/mods/ITEMS/mcl_compressed_blocks/recipes.lua +++ /dev/null @@ -1,127 +0,0 @@ -minetest.register_craft({ - output = "mcl_compressed_blocks:compressed_cobblestone", - recipe = { - { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, - { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, - { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, - }, -}) - -minetest.register_craft({ - output = "mcl_core:cobble 9", - recipe = { - { "mcl_compressed_blocks:compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:double_compressed_cobblestone", - recipe = { - { "mcl_compressed_blocks:compressed_cobblestone", "mcl_compressed_blocks:compressed_cobblestone", "mcl_compressed_blocks:compressed_cobblestone" }, - { "mcl_compressed_blocks:compressed_cobblestone", "mcl_compressed_blocks:compressed_cobblestone", "mcl_compressed_blocks:compressed_cobblestone" }, - { "mcl_compressed_blocks:compressed_cobblestone", "mcl_compressed_blocks:compressed_cobblestone", "mcl_compressed_blocks:compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:compressed_cobblestone 9", - recipe = { - { "mcl_compressed_blocks:double_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:triple_compressed_cobblestone", - recipe = { - { "mcl_compressed_blocks:double_compressed_cobblestone", "mcl_compressed_blocks:double_compressed_cobblestone", "mcl_compressed_blocks:double_compressed_cobblestone" }, - { "mcl_compressed_blocks:double_compressed_cobblestone", "mcl_compressed_blocks:double_compressed_cobblestone", "mcl_compressed_blocks:double_compressed_cobblestone" }, - { "mcl_compressed_blocks:double_compressed_cobblestone", "mcl_compressed_blocks:double_compressed_cobblestone", "mcl_compressed_blocks:double_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:double_compressed_cobblestone 9", - recipe = { - { "mcl_compressed_blocks:triple_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:quadruple_compressed_cobblestone", - recipe = { - { "mcl_compressed_blocks:triple_compressed_cobblestone", "mcl_compressed_blocks:triple_compressed_cobblestone", "mcl_compressed_blocks:triple_compressed_cobblestone" }, - { "mcl_compressed_blocks:triple_compressed_cobblestone", "mcl_compressed_blocks:triple_compressed_cobblestone", "mcl_compressed_blocks:triple_compressed_cobblestone" }, - { "mcl_compressed_blocks:triple_compressed_cobblestone", "mcl_compressed_blocks:triple_compressed_cobblestone", "mcl_compressed_blocks:triple_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:triple_compressed_cobblestone 9", - recipe = { - { "mcl_compressed_blocks:quadruple_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:quintuple_compressed_cobblestone", - recipe = { - { "mcl_compressed_blocks:quadruple_compressed_cobblestone", "mcl_compressed_blocks:quadruple_compressed_cobblestone", "mcl_compressed_blocks:quadruple_compressed_cobblestone" }, - { "mcl_compressed_blocks:quadruple_compressed_cobblestone", "mcl_compressed_blocks:quadruple_compressed_cobblestone", "mcl_compressed_blocks:quadruple_compressed_cobblestone" }, - { "mcl_compressed_blocks:quadruple_compressed_cobblestone", "mcl_compressed_blocks:quadruple_compressed_cobblestone", "mcl_compressed_blocks:quadruple_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:quadruple_compressed_cobblestone 9", - recipe = { - { "mcl_compressed_blocks:quintuple_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:sextuple_compressed_cobblestone", - recipe = { - { "mcl_compressed_blocks:quintuple_compressed_cobblestone", "mcl_compressed_blocks:quintuple_compressed_cobblestone", "mcl_compressed_blocks:quintuple_compressed_cobblestone" }, - { "mcl_compressed_blocks:quintuple_compressed_cobblestone", "mcl_compressed_blocks:quintuple_compressed_cobblestone", "mcl_compressed_blocks:quintuple_compressed_cobblestone" }, - { "mcl_compressed_blocks:quintuple_compressed_cobblestone", "mcl_compressed_blocks:quintuple_compressed_cobblestone", "mcl_compressed_blocks:quintuple_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:quintuple_compressed_cobblestone 9", - recipe = { - { "mcl_compressed_blocks:sextuple_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:septuple_compressed_cobblestone", - recipe = { - { "mcl_compressed_blocks:sextuple_compressed_cobblestone", "mcl_compressed_blocks:sextuple_compressed_cobblestone", "mcl_compressed_blocks:sextuple_compressed_cobblestone" }, - { "mcl_compressed_blocks:sextuple_compressed_cobblestone", "mcl_compressed_blocks:sextuple_compressed_cobblestone", "mcl_compressed_blocks:sextuple_compressed_cobblestone" }, - { "mcl_compressed_blocks:sextuple_compressed_cobblestone", "mcl_compressed_blocks:sextuple_compressed_cobblestone", "mcl_compressed_blocks:sextuple_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:sextuple_compressed_cobblestone 9", - recipe = { - { "mcl_compressed_blocks:septuple_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:octuple_compressed_cobblestone", - recipe = { - { "mcl_compressed_blocks:septuple_compressed_cobblestone", "mcl_compressed_blocks:septuple_compressed_cobblestone", "mcl_compressed_blocks:septuple_compressed_cobblestone" }, - { "mcl_compressed_blocks:septuple_compressed_cobblestone", "mcl_compressed_blocks:septuple_compressed_cobblestone", "mcl_compressed_blocks:septuple_compressed_cobblestone" }, - { "mcl_compressed_blocks:septuple_compressed_cobblestone", "mcl_compressed_blocks:septuple_compressed_cobblestone", "mcl_compressed_blocks:septuple_compressed_cobblestone" }, - }, -}) - -minetest.register_craft({ - output = "mcl_compressed_blocks:septuple_compressed_cobblestone 9", - recipe = { - { "mcl_compressed_blocks:octuple_compressed_cobblestone" }, - }, -})