Code cleaning

This commit is contained in:
JoseDouglas26 2024-06-13 20:25:02 -03:00
parent 4612667465
commit fd1c2b2cc5
12 changed files with 0 additions and 1904 deletions

View File

@ -1,227 +0,0 @@
local S = minetest.get_translator("mcl_barrels")
local F = minetest.formspec_escape
local C = minetest.colorize
--TODO: fix barrel rotation placement
local open_barrels = {}
local drop_content = mcl_util.drop_items_from_meta_container("main")
---@param pos Vector
local function on_blast(pos)
local node = minetest.get_node(pos)
drop_content(pos, node)
minetest.remove_node(pos)
end
-- Simple protection checking functions
local function protection_check_move(pos, from_list, from_index, to_list, to_index, count, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return count
end
end
local function protection_check_put_take(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
else
return stack:get_count()
end
end
local function barrel_open(pos, node, clicker)
local name = minetest.get_meta(pos):get_string("name")
if name == "" then
name = S("Barrel")
end
local playername = clicker:get_player_name()
minetest.show_formspec(playername,
"mcl_barrels:barrel_" .. pos.x .. "_" .. pos.y .. "_" .. pos.z,
table.concat({
"formspec_version[4]",
"size[11.75,10.425]",
"label[0.375,0.375;" .. F(C(mcl_formspec.label_color, name)) .. "]",
mcl_formspec.get_itemslot_bg_v4(0.375, 0.75, 9, 3),
"list[nodemeta:" .. pos.x .. "," .. pos.y .. "," .. pos.z .. ";main;0.375,0.75;9,3;]",
"label[0.375,4.7;" .. F(C(mcl_formspec.label_color, S("Inventory"))) .. "]",
mcl_formspec.get_itemslot_bg_v4(0.375, 5.1, 9, 3),
"list[current_player;main;0.375,5.1;9,3;9]",
mcl_formspec.get_itemslot_bg_v4(0.375, 9.05, 9, 1),
"list[current_player;main;0.375,9.05;9,1;]",
"listring[nodemeta:" .. pos.x .. "," .. pos.y .. "," .. pos.z .. ";main]",
"listring[current_player;main]",
})
)
minetest.swap_node(pos, { name = "mcl_barrels:barrel_open", param2 = node.param2 })
open_barrels[playername] = pos
minetest.sound_play({name="mcl_barrels_default_barrel_open", gain=0.5}, {
pos = pos,
max_hear_distance = 16,
}, true)
end
---@param pos Vector
local function close_forms(pos)
local players = minetest.get_connected_players()
local formname = "mcl_barrels:barrel_" .. pos.x .. "_" .. pos.y .. "_" .. pos.z
for p = 1, #players do
if vector.distance(players[p]:get_pos(), pos) <= 30 then
minetest.close_formspec(players[p]:get_player_name(), formname)
end
end
end
---@param pos Vector
local function update_after_close(pos)
local node = minetest.get_node_or_nil(pos)
if not node then return end
if node.name == "mcl_barrels:barrel_open" then
minetest.swap_node(pos, { name = "mcl_barrels:barrel_closed", param2 = node.param2 })
minetest.sound_play({name="mcl_barrels_default_barrel_close", gain=0.5}, {
pos = pos,
max_hear_distance = 16,
}, true)
end
end
---@param player ObjectRef
local function close_barrel(player)
local name = player:get_player_name()
local open = open_barrels[name]
if open == nil then
return
end
update_after_close(open)
open_barrels[name] = nil
end
minetest.register_node("mcl_barrels:barrel_closed", {
description = S("Barrel"),
tiles = { "mcl_barrels_barrel_top.png^[transformR270", "mcl_barrels_barrel_bottom.png", "mcl_barrels_barrel_side.png" },
paramtype = "light",
paramtype2 = "facedir",
on_place = function(itemstack, placer, pointed_thing)
minetest.rotate_and_place(itemstack, placer, pointed_thing,
minetest.is_creative_enabled(placer:get_player_name()), {}
, false)
return itemstack
end,
stack_max = 64,
sounds = mcl_sounds.node_sound_wood_defaults(),
groups = { handy = 1, axey = 1, container = 2, material_wood = 1, flammable = -1, deco_block = 1 },
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("main", 9 * 3)
end,
after_place_node = function(pos, placer, itemstack, pointed_thing)
minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name"))
end,
allow_metadata_inventory_move = protection_check_move,
allow_metadata_inventory_take = protection_check_put_take,
allow_metadata_inventory_put = protection_check_put_take,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name() ..
" moves stuff in barrel at " .. minetest.pos_to_string(pos))
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" moves stuff to barrel at " .. minetest.pos_to_string(pos))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" takes stuff from barrel at " .. minetest.pos_to_string(pos))
end,
after_dig_node = drop_content,
on_blast = on_blast,
on_rightclick = barrel_open,
on_destruct = close_forms,
_mcl_blast_resistance = 2.5,
_mcl_hardness = 2.5,
})
minetest.register_node("mcl_barrels:barrel_open", {
description = S("Barrel Open"),
_tt_help = S("27 inventory slots"),
_doc_items_longdesc = S("Barrels are containers which provide 27 inventory slots."),
_doc_items_usagehelp = S("To access its inventory, rightclick it. When broken, the items will drop out."),
_doc_items_create_entry = false,
tiles = { "mcl_barrels_barrel_top_open.png", "mcl_barrels_barrel_bottom.png", "mcl_barrels_barrel_side.png" },
paramtype = "light",
paramtype2 = "facedir",
drop = "mcl_barrels:barrel_closed",
stack_max = 64,
sounds = mcl_sounds.node_sound_wood_defaults(),
groups = {
handy = 1,
axey = 1,
container = 2,
material_wood = 1,
flammable = -1,
deco_block = 1,
not_in_creative_inventory = 1
},
allow_metadata_inventory_move = protection_check_move,
allow_metadata_inventory_take = protection_check_put_take,
allow_metadata_inventory_put = protection_check_put_take,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name() ..
" moves stuff in barrel at " .. minetest.pos_to_string(pos))
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" moves stuff to barrel at " .. minetest.pos_to_string(pos))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" takes stuff from barrel at " .. minetest.pos_to_string(pos))
end,
after_dig_node = drop_content,
on_blast = on_blast,
on_rightclick = barrel_open,
on_destruct = close_forms,
_mcl_blast_resistance = 2.5,
_mcl_hardness = 2.5,
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname:find("mcl_barrels:") == 1 and fields.quit then
close_barrel(player)
end
end)
minetest.register_on_leaveplayer(function(player)
close_barrel(player)
end)
--Minecraft Java Edition craft
minetest.register_craft({
output = "mcl_barrels:barrel_closed",
recipe = {
{ "group:wood", "group:wood_slab", "group:wood" },
{ "group:wood", "", "group:wood" },
{ "group:wood", "group:wood_slab", "group:wood" },
},
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_barrels:barrel_closed",
burntime = 15,
})

View File

@ -1,148 +0,0 @@
--[[
#!#!#!#Cake mod created by Jordan4ibanez#!#!#
#!#!#!#Released under CC Attribution-ShareAlike 3.0 Unported #!#!#
]]--
local CAKE_HUNGER_POINTS = 2
local S = minetest.get_translator(minetest.get_current_modname())
local cake_texture = {"cake_top.png","cake_bottom.png","cake_inner.png","cake_side.png","cake_side.png","cake_side.png"}
local slice_1 = { -7/16, -8/16, -7/16, -5/16, 0/16, 7/16}
local slice_2 = { -7/16, -8/16, -7/16, -3/16, 0/16, 7/16}
local slice_3 = { -7/16, -8/16, -7/16, -1/16, 0/16, 7/16}
local slice_4 = { -7/16, -8/16, -7/16, 1/16, 0/16, 7/16}
local slice_5 = { -7/16, -8/16, -7/16, 3/16, 0/16, 7/16}
local slice_6 = { -7/16, -8/16, -7/16, 5/16, 0/16, 7/16}
local full_cake = { -7/16, -8/16, -7/16, 7/16, 0/16, 7/16}
minetest.register_craft({
output = "mcl_cake:cake",
recipe = {
{"mcl_mobitems:milk_bucket", "mcl_mobitems:milk_bucket", "mcl_mobitems:milk_bucket"},
{"mcl_core:sugar", "mcl_throwing:egg", "mcl_core:sugar"},
{"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"},
},
replacements = {
{"mcl_mobitems:milk_bucket", "mcl_buckets:bucket_empty"},
{"mcl_mobitems:milk_bucket", "mcl_buckets:bucket_empty"},
{"mcl_mobitems:milk_bucket", "mcl_buckets:bucket_empty"},
},
})
minetest.register_node("mcl_cake:cake", {
description = S("Cake"),
tiles = {"cake_top.png","cake_bottom.png","cake_side.png","cake_side.png","cake_side.png","cake_side.png"},
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false,
inventory_image = "cake.png",
wield_image = "cake.png",
paramtype = "light",
is_ground_content = false,
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = full_cake
},
node_box = {
type = "fixed",
fixed = full_cake
},
stack_max = 1,
groups = {
handy = 1, attached_node = 1, dig_by_piston = 1, comparator_signal = 14,
cake = 7, food = 2, no_eat_delay = 1, compostability = 100
},
drop = "",
on_rightclick = function(pos, node, clicker, itemstack)
-- Cake is subject to protection
local name = clicker:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
local newcake = minetest.do_item_eat(2, ItemStack("mcl_cake:cake_6"), ItemStack("mcl_cake:cake"), clicker, {type="nothing"})
-- Check if we were allowed to eat
if newcake:get_name() ~= "mcl_cake:cake" or minetest.is_creative_enabled(clicker:get_player_name()) then
minetest.add_node(pos,{type="node",name="mcl_cake:cake_6",param2=0})
end
end,
sounds = mcl_sounds.node_sound_leaves_defaults(),
_food_particles = false,
_mcl_saturation = 0.4,
_mcl_blast_resistance = 0.5,
_mcl_hardness = 0.5,
})
local register_slice = function(level, nodebox, desc)
local this = "mcl_cake:cake_"..level
local after_eat = "mcl_cake:cake_"..(level-1)
local on_rightclick
if level > 1 then
on_rightclick = function(pos, node, clicker, itemstack)
local name = clicker:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
local newcake = minetest.do_item_eat(CAKE_HUNGER_POINTS, ItemStack(after_eat), ItemStack(this), clicker, {type="nothing"})
-- Check if we were allowed to eat
if newcake:get_name() ~= this or minetest.is_creative_enabled(clicker:get_player_name()) then
minetest.add_node(pos,{type="node",name=after_eat,param2=0})
end
end
else
-- Last slice
on_rightclick = function(pos, node, clicker, itemstack)
local name = clicker:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
local newcake = minetest.do_item_eat(CAKE_HUNGER_POINTS, ItemStack("mcl:cake:cake 0"), ItemStack("mcl_cake:cake_1"), clicker, {type="nothing"})
-- Check if we were allowed to eat
if newcake:get_name() ~= this or minetest.is_creative_enabled(clicker:get_player_name()) then
minetest.remove_node(pos)
minetest.check_for_falling(pos)
end
end
end
minetest.register_node(this, {
description = desc,
tiles = cake_texture,
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false,
paramtype = "light",
is_ground_content = false,
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = nodebox,
},
node_box = {
type = "fixed",
fixed = nodebox,
},
groups = {
handy = 1, attached_node = 1, not_in_creative_inventory = 1,
dig_by_piston = 1, cake = level, comparator_signal = level * 2,
food = 2, no_eat_delay = 1
},
drop = "",
on_rightclick = on_rightclick,
sounds = mcl_sounds.node_sound_leaves_defaults(),
_food_particles = false,
_mcl_saturation = 0.4,
_mcl_blast_resistance = 0.5,
_mcl_hardness = 0.5,
})
end
register_slice(6, slice_6, S("Cake (6 Slices Left)"))
register_slice(5, slice_5, S("Cake (5 Slices Left)"))
register_slice(4, slice_4, S("Cake (4 Slices Left)"))
register_slice(3, slice_3, S("Cake (3 Slices Left)"))
register_slice(2, slice_2, S("Cake (2 Slices Left)"))
register_slice(1, slice_1, S("Cake (1 Slice Left)"))

View File

@ -2,14 +2,4 @@ local path = minetest.get_modpath("mcl_copper") -- Getting mcl_copper mod path
mcl_copper = {} -- Initializing global variable mcl_copper.
-- Loading the file containing the descriptions and longdescs of each block
dofile(path .. "/descriptions.lua")
-- Loading the file that registers all blocks provided by this mod
dofile(path .. "/nodes.lua")
-- Loading the file that registers craftitems
dofile(path .. "/items.lua")
-- Loading the file that registers the blocks crafting recipes
dofile(path .. "/crafting.lua")
-- Loading the file that handles oxidized, waxed and stripped variants for blocks that are registered
-- in other mods and normally do not have these variants.
--dofile(path .. "/functions.lua")

View File

@ -1,560 +0,0 @@
-- mods/default/crafting.lua
--
-- Crafting definition
--
local function craft_planks(output, input)
minetest.register_craft({
output = "mcl_core:"..output.."wood 4",
recipe = {
{"mcl_core:"..input},
}
})
end
local planks = {
{"", "oak"},
{"dark", "dark_oak"},
{"jungle", "jungle"},
{"acacia", "acacia"},
{"spruce", "spruce"},
{"birch", "birch"}
}
for _, p in pairs(planks) do
craft_planks(p[1], p[1].."tree")
craft_planks(p[1], p[1].."tree_bark")
craft_planks(p[1], "stripped_"..p[2])
craft_planks(p[1], "stripped_"..p[2].."_bark")
end
minetest.register_craft({
type = "shapeless",
output = "mcl_core:mossycobble",
recipe = { "mcl_core:cobble", "mcl_core:vine" },
})
minetest.register_craft({
type = "shapeless",
output = "mcl_core:stonebrickmossy",
recipe = { "mcl_core:stonebrick", "mcl_core:vine" },
})
minetest.register_craft({
output = "mcl_core:coarse_dirt 4",
recipe = {
{"mcl_core:dirt", "mcl_core:gravel"},
{"mcl_core:gravel", "mcl_core:dirt"},
}
})
minetest.register_craft({
output = "mcl_core:coarse_dirt 4",
recipe = {
{"mcl_core:gravel", "mcl_core:dirt"},
{"mcl_core:dirt", "mcl_core:gravel"},
}
})
minetest.register_craft({
output = "mcl_core:sandstonesmooth 4",
recipe = {
{"mcl_core:sandstone","mcl_core:sandstone"},
{"mcl_core:sandstone","mcl_core:sandstone"},
}
})
minetest.register_craft({
output = "mcl_core:redsandstonesmooth 4",
recipe = {
{"mcl_core:redsandstone","mcl_core:redsandstone"},
{"mcl_core:redsandstone","mcl_core:redsandstone"},
}
})
minetest.register_craft({
output = "mcl_core:granite_smooth 4",
recipe = {
{"mcl_core:granite", "mcl_core:granite"},
{"mcl_core:granite", "mcl_core:granite"}
},
})
minetest.register_craft({
output = "mcl_core:andesite_smooth 4",
recipe = {
{"mcl_core:andesite", "mcl_core:andesite"},
{"mcl_core:andesite", "mcl_core:andesite"}
},
})
minetest.register_craft({
output = "mcl_core:diorite_smooth 4",
recipe = {
{"mcl_core:diorite", "mcl_core:diorite"},
{"mcl_core:diorite", "mcl_core:diorite"}
},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_core:granite",
recipe = {"mcl_core:diorite", "mcl_nether:quartz"},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_core:andesite 2",
recipe = {"mcl_core:diorite", "mcl_core:cobble"},
})
minetest.register_craft({
output = "mcl_core:diorite 2",
recipe = {
{"mcl_core:cobble", "mcl_nether:quartz"},
{"mcl_nether:quartz", "mcl_core:cobble"},
}
})
minetest.register_craft({
output = "mcl_core:diorite 2",
recipe = {
{"mcl_nether:quartz", "mcl_core:cobble"},
{"mcl_core:cobble", "mcl_nether:quartz"},
}
})
minetest.register_craft({
output = "mcl_core:bone_block",
recipe = {
{ "mcl_bone_meal:bone_meal", "mcl_bone_meal:bone_meal", "mcl_bone_meal:bone_meal" },
{ "mcl_bone_meal:bone_meal", "mcl_bone_meal:bone_meal", "mcl_bone_meal:bone_meal" },
{ "mcl_bone_meal:bone_meal", "mcl_bone_meal:bone_meal", "mcl_bone_meal:bone_meal" },
},
})
minetest.register_craft({
output = "mcl_bone_meal:bone_meal 9",
recipe = {
{ "mcl_core:bone_block" },
},
})
minetest.register_craft({
output = "mcl_core:stick 4",
recipe = {
{"group:wood"},
{"group:wood"},
}
})
minetest.register_craft({
output = "mcl_core:coalblock",
recipe = {
{"mcl_core:coal_lump", "mcl_core:coal_lump", "mcl_core:coal_lump"},
{"mcl_core:coal_lump", "mcl_core:coal_lump", "mcl_core:coal_lump"},
{"mcl_core:coal_lump", "mcl_core:coal_lump", "mcl_core:coal_lump"},
}
})
minetest.register_craft({
output = "mcl_core:coal_lump 9",
recipe = {
{"mcl_core:coalblock"},
}
})
minetest.register_craft({
output = "mcl_core:ironblock",
recipe = {
{"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
{"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
{"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
}
})
minetest.register_craft({
output = "mcl_core:iron_ingot 9",
recipe = {
{"mcl_core:ironblock"},
}
})
minetest.register_craft({
output = "mcl_core:goldblock",
recipe = {
{"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"},
{"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"},
{"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"},
}
})
minetest.register_craft({
output = "mcl_core:gold_ingot 9",
recipe = {
{"mcl_core:goldblock"},
}
})
minetest.register_craft({
output = "mcl_core:gold_nugget 9",
recipe = {{"mcl_core:gold_ingot"}},
})
minetest.register_craft({
output = "mcl_core:iron_nugget 9",
recipe = {{"mcl_core:iron_ingot"}},
})
minetest.register_craft({
output = "mcl_core:gold_ingot",
recipe = {
{"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"},
{"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"},
{"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"},
}
})
minetest.register_craft({
output = "mcl_core:iron_ingot",
recipe = {
{"mcl_core:iron_nugget", "mcl_core:iron_nugget", "mcl_core:iron_nugget"},
{"mcl_core:iron_nugget", "mcl_core:iron_nugget", "mcl_core:iron_nugget"},
{"mcl_core:iron_nugget", "mcl_core:iron_nugget", "mcl_core:iron_nugget"},
}
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:iron_nugget",
recipe = "mcl_mobitems:iron_horse_armor",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:gold_nugget",
recipe = "mcl_mobitems:gold_horse_armor",
cooktime = 10,
})
minetest.register_craft({
output = "mcl_core:sandstone",
recipe = {
{"mcl_core:sand", "mcl_core:sand"},
{"mcl_core:sand", "mcl_core:sand"},
}
})
minetest.register_craft({
output = "mcl_core:redsandstone",
recipe = {
{"mcl_core:redsand", "mcl_core:redsand"},
{"mcl_core:redsand", "mcl_core:redsand"},
}
})
minetest.register_craft({
output = "mcl_core:clay",
recipe = {
{"mcl_core:clay_lump", "mcl_core:clay_lump"},
{"mcl_core:clay_lump", "mcl_core:clay_lump"},
}
})
minetest.register_craft({
output = "mcl_core:brick_block",
recipe = {
{"mcl_core:brick", "mcl_core:brick"},
{"mcl_core:brick", "mcl_core:brick"},
}
})
minetest.register_craft({
output = "mcl_core:paper 3",
recipe = {
{"mcl_core:reeds", "mcl_core:reeds", "mcl_core:reeds"},
}
})
minetest.register_craft({
output = "mcl_core:ladder 3",
recipe = {
{"mcl_core:stick", "", "mcl_core:stick"},
{"mcl_core:stick", "mcl_core:stick", "mcl_core:stick"},
{"mcl_core:stick", "", "mcl_core:stick"},
}
})
minetest.register_craft({
output = "mcl_core:stonebrick 4",
recipe = {
{"mcl_core:stone", "mcl_core:stone"},
{"mcl_core:stone", "mcl_core:stone"},
}
})
minetest.register_craft({
output = "mcl_core:lapisblock",
recipe = {
{"mcl_core:lapis", "mcl_core:lapis", "mcl_core:lapis"},
{"mcl_core:lapis", "mcl_core:lapis", "mcl_core:lapis"},
{"mcl_core:lapis", "mcl_core:lapis", "mcl_core:lapis"},
}
})
minetest.register_craft({
output = "mcl_core:lapis 9",
recipe = {
{"mcl_core:lapisblock"},
}
})
minetest.register_craft({
output = "mcl_core:emeraldblock",
recipe = {
{"mcl_core:emerald", "mcl_core:emerald", "mcl_core:emerald"},
{"mcl_core:emerald", "mcl_core:emerald", "mcl_core:emerald"},
{"mcl_core:emerald", "mcl_core:emerald", "mcl_core:emerald"},
}
})
minetest.register_craft({
output = "mcl_core:emerald 9",
recipe = {
{"mcl_core:emeraldblock"},
}
})
minetest.register_craft({
output = "mcl_core:diamondblock",
recipe = {
{"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"},
{"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"},
{"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"},
}
})
minetest.register_craft({
output = "mcl_core:diamond 9",
recipe = {
{"mcl_core:diamondblock"},
}
})
minetest.register_craft({
output = "mcl_core:apple_gold",
recipe = {
{"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"},
{"mcl_core:gold_ingot", "mcl_core:apple", "mcl_core:gold_ingot"},
{"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"},
}
})
minetest.register_craft({
output = "mcl_core:sugar",
recipe = {
{"mcl_core:reeds"},
}
})
minetest.register_craft({
output = "mcl_core:bowl 4",
recipe = {
{"group:wood", "", "group:wood"},
{"", "group:wood", ""},
}
})
minetest.register_craft({
output = "mcl_core:snowblock",
recipe = {
{"mcl_throwing:snowball", "mcl_throwing:snowball"},
{"mcl_throwing:snowball", "mcl_throwing:snowball"},
}
})
minetest.register_craft({
output = "mcl_core:snow 6",
recipe = {
{"mcl_core:snowblock", "mcl_core:snowblock", "mcl_core:snowblock"},
}
})
minetest.register_craft({
output = 'mcl_core:packed_ice 1',
recipe = {
{'mcl_core:ice', 'mcl_core:ice', 'mcl_core:ice'},
{'mcl_core:ice', 'mcl_core:ice', 'mcl_core:ice'},
{'mcl_core:ice', 'mcl_core:ice', 'mcl_core:ice'},
}
})
--
-- Crafting (tool repair)
--
minetest.register_craft({
type = "toolrepair",
additional_wear = -mcl_core.repair,
})
--
-- Cooking recipes
--
minetest.register_craft({
type = "cooking",
output = "mcl_core:glass",
recipe = "group:sand",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:stone",
recipe = "mcl_core:cobble",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:stone_smooth",
recipe = "mcl_core:stone",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:stonebrickcracked",
recipe = "mcl_core:stonebrick",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:iron_ingot",
recipe = "mcl_core:stone_with_iron",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:gold_ingot",
recipe = "mcl_core:stone_with_gold",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:brick",
recipe = "mcl_core:clay_lump",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:charcoal_lump",
recipe = "group:tree",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:coal_lump",
recipe = "mcl_core:stone_with_coal",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:diamond",
recipe = "mcl_core:stone_with_diamond",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:emerald",
recipe = "mcl_core:stone_with_emerald",
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:lapis",
recipe = "mcl_core:stone_with_lapis",
cooktime = 10,
})
--
-- Fuels
--
minetest.register_craft({
type = "fuel",
recipe = "mcl_core:coalblock",
burntime = 800,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_core:coal_lump",
burntime = 80,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_core:charcoal_lump",
burntime = 80,
})
minetest.register_craft({
type = "fuel",
recipe = "group:tree",
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "group:bark",
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_core:ladder",
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "group:wood",
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "group:sapling",
burntime = 5,
})
minetest.register_craft({
type = "fuel",
recipe = "group:sapling",
burntime = 5,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_core:bowl",
burntime = 5,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_core:stick",
burntime = 5,
})

View File

@ -1,272 +0,0 @@
-- mods/default/craftitems.lua
local S = minetest.get_translator(minetest.get_current_modname())
local enable_fapples = minetest.settings:get_bool("mcl_enable_fapples",true)
--
-- Crafting items
--
minetest.register_craftitem("mcl_core:stick", {
description = S("Stick"),
_doc_items_longdesc = S("Sticks are a very versatile crafting material; used in countless crafting recipes."),
_doc_items_hidden = false,
inventory_image = "default_stick.png",
stack_max = 64,
groups = { craftitem=1, stick=1 },
_mcl_toollike_wield = true,
})
minetest.register_craftitem("mcl_core:paper", {
description = S("Paper"),
_doc_items_longdesc = S("Paper is used to craft books and maps."),
inventory_image = "default_paper.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:coal_lump", {
description = S("Coal"),
_doc_items_longdesc = S("“Coal” refers to coal lumps obtained by digging coal ore which can be found underground. Coal is your standard furnace fuel, but it can also be used to make torches, coal blocks and a few other things."),
_doc_items_hidden = false,
inventory_image = "default_coal_lump.png",
stack_max = 64,
groups = { craftitem=1, coal=1 },
})
minetest.register_craftitem("mcl_core:charcoal_lump", {
description = S("Charcoal"),
_doc_items_longdesc = S("Charcoal is an alternative furnace fuel created by cooking wood in a furnace. It has the same burning time as coal and also shares many of its crafting recipes, but it can not be used to create coal blocks."),
_doc_items_hidden = false,
inventory_image = "mcl_core_charcoal.png",
stack_max = 64,
groups = { craftitem=1, coal=1 },
})
minetest.register_craftitem("mcl_core:iron_nugget", {
description = S("Iron Nugget"),
_doc_items_longdesc = S("Iron nuggets are very small pieces of molten iron; the main purpose is to create iron ingots."),
inventory_image = "mcl_core_iron_nugget.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:gold_nugget", {
description = S("Gold Nugget"),
_doc_items_longdesc = S("Gold nuggets are very small pieces of molten gold; the main purpose is to create gold ingots."),
inventory_image = "mcl_core_gold_nugget.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:diamond", {
description = S("Diamond"),
_doc_items_longdesc = S("Diamonds are precious minerals and useful to create the highest tier of armor and tools."),
inventory_image = "default_diamond.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:clay_lump", {
description = S("Clay Ball"),
_doc_items_longdesc = S("Clay balls are a raw material, mainly used to create bricks in the furnace."),
_doc_items_hidden = false,
inventory_image = "default_clay_lump.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:iron_ingot", {
description = S("Iron Ingot"),
_doc_items_longdesc = S("Molten iron. It is used to craft armor, tools, and whatnot."),
inventory_image = "default_steel_ingot.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:gold_ingot", {
description = S("Gold Ingot"),
_doc_items_longdesc = S("Molten gold. It is used to craft armor, tools, and whatnot."),
inventory_image = "default_gold_ingot.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:emerald", {
description = S("Emerald"),
_doc_items_longdesc = S("Emeralds are used in villager trades as currency."),
inventory_image = "mcl_core_emerald.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:lapis", {
description = S("Lapis Lazuli"),
_doc_items_longdesc = S("Lapis Lazuli are required for enchanting items on an enchanting table."),
inventory_image = "mcl_core_lapis.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:brick", {
description = S("Brick"),
_doc_items_longdesc = S("Bricks are used to craft brick blocks."),
inventory_image = "default_clay_brick.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:flint", {
description = S("Flint"),
_doc_items_longdesc = S("Flint is a raw material."),
inventory_image = "default_flint.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:sugar", {
description = S("Sugar"),
_doc_items_longdesc = S("Sugar comes from sugar canes and is used to make sweet foods."),
inventory_image = "mcl_core_sugar.png",
stack_max = 64,
groups = { craftitem = 1, brewitem=1 },
})
minetest.register_craftitem("mcl_core:bowl",{
description = S("Bowl"),
_doc_items_longdesc = S("Bowls are mainly used to hold tasty soups."),
inventory_image = "mcl_core_bowl.png",
stack_max = 64,
groups = { craftitem = 1 },
})
minetest.register_craftitem("mcl_core:apple", {
description = S("Apple"),
_doc_items_longdesc = S("Apples are food items which can be eaten."),
wield_image = "default_apple.png",
inventory_image = "default_apple.png",
stack_max = 64,
on_place = minetest.item_eat(4),
on_secondary_use = minetest.item_eat(4),
groups = { food = 2, eatable = 4, compostability = 65 },
_mcl_saturation = 2.4,
})
local gapple_hunger_restore = minetest.item_eat(4)
local function eat_gapple(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.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(pointed_thing.under, node, placer, itemstack) or itemstack
end
end
elseif pointed_thing.type == "object" then
return itemstack
end
local regen_duration, absorption = 5, 1
if itemstack:get_name() == "mcl_core:apple_gold_enchanted" then
regen_duration, absorption = 20, 4
mcl_potions.give_effect("fire_resistance", placer, 1, 300)
mcl_potions.give_effect_by_level("leaping", placer, 1, 300)
if enable_fapples then
mcl_potions.give_effect_by_level("swiftness", placer, absorption, 120)
end
end
mcl_potions.give_effect_by_level("absorption", placer, absorption, 120)
mcl_potions.give_effect_by_level("regeneration", placer, 2, regen_duration)
return gapple_hunger_restore(itemstack, placer, pointed_thing)
end
local function eat_gapple_delayed(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.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(pointed_thing.under, node, placer, itemstack) or itemstack
end
end
elseif pointed_thing.type == "object" then
return itemstack
end
local function eat_gapple(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.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(pointed_thing.under, node, placer, itemstack) or itemstack
end
end
elseif pointed_thing.type == "object" then
return itemstack
end
local regen_duration, absorption = 5, 1
if itemstack:get_name() == "mcl_core:apple_gold_enchanted" then
regen_duration, absorption = 20, 4
mcl_potions.give_effect("fire_resistance", placer, 1, 300)
mcl_potions.give_effect_by_level("leaping", placer, 1, 300)
if enable_fapples then
mcl_potions.give_effect_by_level("swiftness", placer, absorption, 120)
end
end
mcl_potions.give_effect_by_level("absorption", placer, absorption, 120)
mcl_potions.give_effect_by_level("regeneration", placer, 2, regen_duration)
--return gapple_hunger_restore(itemstack, placer, pointed_thing)
end
-- Wrapper for handling mcl_hunger delayed eating
local name = placer:get_player_name()
mcl_hunger.eat_internal[name]._custom_itemstack = itemstack -- Used as comparison to make sure the custom wrapper executes only when the same item is eaten
mcl_hunger.eat_internal[name]._custom_var = {
itemstack = itemstack,
placer = placer,
pointed_thing = pointed_thing,
}
mcl_hunger.eat_internal[name]._custom_func = eat_gapple
mcl_hunger.eat_internal[name]._custom_wrapper = function(name)
mcl_hunger.eat_internal[name]._custom_func(
mcl_hunger.eat_internal[name]._custom_var.itemstack,
mcl_hunger.eat_internal[name]._custom_var.placer,
mcl_hunger.eat_internal[name]._custom_var.pointed_thing
)
end
--mcl_hunger.eat_internal[name]._custom_do_delayed = true -- Only _custom_wrapper will be executed after holding RMB or LMB within a specified delay
minetest.do_item_eat(4, nil, itemstack, placer, pointed_thing)
end
minetest.register_craftitem("mcl_core:apple_gold", {
-- TODO: Add special highlight color
description = S("Golden Apple"),
_doc_items_longdesc = S("Golden apples are precious food items which can be eaten."),
wield_image = "mcl_core_apple_golden.png",
inventory_image = "mcl_core_apple_golden.png",
stack_max = 64,
--on_place = eat_gapple, -- Will do effect immediately but not reduce item count until eating delay ends which makes it exploitable by deliberately not finishing delay
--on_secondary_use = eat_gapple,
on_place = eat_gapple_delayed,
on_secondary_use = eat_gapple_delayed,
groups = { food = 2, eatable = 4, can_eat_when_full = 1 },
_mcl_saturation = 9.6,
})
minetest.register_craftitem("mcl_core:apple_gold_enchanted", {
description = S("Enchanted Golden Apple"),
_doc_items_longdesc = S("Golden apples are precious food items which can be eaten."),
wield_image = "mcl_core_apple_golden.png" .. mcl_enchanting.overlay,
inventory_image = "mcl_core_apple_golden.png" .. mcl_enchanting.overlay,
stack_max = 64,
--on_place = eat_gapple,
--on_secondary_use = eat_gapple,
on_place = eat_gapple_delayed,
on_secondary_use = eat_gapple_delayed,
groups = { food = 2, eatable = 4, can_eat_when_full = 1 },
_mcl_saturation = 9.6,
})

View File

@ -466,116 +466,3 @@ minetest.register_abm({
mcl_end.grow_chorus_plant_step(pos, node, pr)
end,
})
--- Chorus fruit ---
-- Attempt to randomly teleport the player within a 8×8×8 box around. Rules:
-- * Not in solid blocks.
-- * Not in liquids.
-- * Always on top of a solid block
-- * Maximum attempts: 16
--
-- Returns true on success.
local function random_teleport(player)
local pos = player:get_pos()
-- 16 attempts to find a suitable position
for a=1, 16 do
-- Teleportation box
local x,y,z
x = math.random(round(pos.x)-8, round(pos.x)+8)
y = math.random(math.ceil(pos.y)-8, math.ceil(pos.y)+8)
z = math.random(round(pos.z)-8, round(pos.z)+8)
local node_cache = {}
local ground_level = false
-- Scan nodes from selected position until we hit ground
for t=0, 16 do
local tpos = {x=x, y=y-t, z=z}
local tnode = minetest.get_node(tpos)
if tnode.name == "mcl_core:void" or tnode.name == "ignore" then
break
end
local tdef = minetest.registered_nodes[tnode.name]
table.insert(node_cache, {pos=tpos, node=tnode})
if tdef.walkable then
ground_level = true
break
end
end
-- Ground found? Then let's check if the player has enough room
if ground_level and #node_cache >= 1 then
local streak = 0
local last_was_walkable = true
for c=#node_cache, 1, -1 do
local tpos = node_cache[c].pos
local tnode = node_cache[c].node
local tdef = minetest.registered_nodes[tnode.name]
-- Player needs a space of 2 safe non-liquid nodes on top of a walkable node
if not tdef.walkable and tdef.liquidtype == "none" and tdef.damage_per_second <= 0 then
if (streak == 0 and last_was_walkable) or (streak > 0) then
streak = streak + 1
end
else
streak = 0
end
last_was_walkable = tdef.walkable
if streak >= 2 then
-- JACKPOT! Now we can teleport.
local goal = {x=tpos.x, y=tpos.y-1.5, z=tpos.z}
player:set_pos(goal)
minetest.sound_play({name="mcl_end_teleport", gain=0.8}, {pos=goal, max_hear_distance=16}, true)
return true
end
end
end
end
return false
end
-- Randomly teleport player and update hunger
local eat_chorus_fruit = function(itemstack, player, pointed_thing)
if player and pointed_thing and pointed_thing.type == "node" and not player:get_player_control().sneak then
local node_under = minetest.get_node(pointed_thing.under)
-- Use pointed node's on_rightclick function first, if present
if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then
return minetest.registered_nodes[node_under.name].on_rightclick(pointed_thing.under, node_under, player, itemstack) or itemstack
end
end
local count = itemstack:get_count()
local new_itemstack = minetest.do_item_eat(4, nil, itemstack, player, pointed_thing)
local new_count = new_itemstack:get_count()
if count ~= new_count or new_itemstack:get_name() ~= "mcl_end:chorus_fruit" or (minetest.is_creative_enabled(player:get_player_name()) == true) then
random_teleport(player)
end
return new_itemstack
end
minetest.register_craftitem("mcl_end:chorus_fruit", {
description = S("Chorus Fruit"),
_tt_help = S("Randomly teleports you when eaten"),
_doc_items_longdesc = S("A chorus fruit is an edible fruit from the chorus plant which is home to the End. Eating it teleports you to the top of a random solid block nearby, provided you won't end up inside a liquid, solid or harmful blocks. Teleportation might fail if there are very few or no places to teleport to."),
wield_image = "mcl_end_chorus_fruit.png",
inventory_image = "mcl_end_chorus_fruit.png",
on_place = eat_chorus_fruit,
on_secondary_use = eat_chorus_fruit,
groups = { food = 2, transport = 1, eatable = 4, can_eat_when_full = 1 },
_mcl_saturation = 2.4,
stack_max = 64,
})
minetest.register_craftitem("mcl_end:chorus_fruit_popped", {
description = S("Popped Chorus Fruit"),
_doc_items_longdesc = doc.sub.items.temp.craftitem,
wield_image = "mcl_end_chorus_fruit_popped.png",
inventory_image = "mcl_end_chorus_fruit_popped.png",
groups = { craftitem = 1 },
stack_max = 64,
})
--- Crafting ---
minetest.register_craft({
type = "cooking",
output = "mcl_end:chorus_fruit_popped",
recipe = "mcl_end:chorus_fruit",
cooktime = 10,
})

View File

@ -1,32 +0,0 @@
local S = minetest.get_translator(minetest.get_current_modname())
-- Fletching Table Code. No use as of current Minecraft Updates. Basically a decor block. As of now, this is complete.
minetest.register_node("mcl_fletching_table:fletching_table", {
description = S("Fletching Table"),
_tt_help = S("A fletching table"),
_doc_items_longdesc = S("This is the fletcher villager's work station. It currently has no use beyond decoration."),
tiles = {
"fletching_table_top.png", "fletching_table_bottom.png",
"fletching_table_front.png", "fletching_table_front.png",
"fletching_table_side.png", "fletching_table_side.png"
},
paramtype2 = "facedir",
groups = { axey = 2, handy = 1, deco_block = 1, material_wood = 1, flammable = 1 },
sounds = mcl_sounds.node_sound_wood_defaults(),
_mcl_blast_resistance = 2.5,
_mcl_hardness = 2.5
})
minetest.register_craft({
output = "mcl_fletching_table:fletching_table",
recipe = {
{ "mcl_core:flint", "mcl_core:flint", "" },
{ "group:wood", "group:wood", "" },
{ "group:wood", "group:wood", "" },
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_fletching_table:fletching_table",
burntime = 15,
})

View File

@ -1,297 +0,0 @@
local S = minetest.get_translator(minetest.get_current_modname())
local minetest = minetest
local mod_doc = minetest.get_modpath("doc")
local mod_screwdriver = minetest.get_modpath("screwdriver")
local equip_armor
if minetest.get_modpath("mcl_armor") then
equip_armor = mcl_armor.equip_on_use
end
mcl_heads = {}
-- rotations of head nodes within a quadrant (0° ≤ θ ≤ 90°)
mcl_heads.FLOOR_DEGREES = { [0]='', '22_5', '45', '67_5', }
-- box of head nodes
mcl_heads.FLOOR_BOX = { -0.25, -0.5, -0.25, 0.25, 0.0, 0.25, }
-- floor head node nodedef template ------------------------------------------------------------------------------------
--- node definition template for floor mod heads
mcl_heads.deftemplate_floor = {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = mcl_heads.FLOOR_BOX,
},
groups = {
handy = 1,
armor = 1,
armor_head = 1,
non_combat_armor = 1,
non_combat_armor_head = 1,
head = 1,
deco_block = 1,
dig_by_piston = 1,
},
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false,
paramtype = "light",
paramtype2 = "facedir",
stack_max = 64,
sunlight_propagates = true,
sounds = mcl_sounds.node_sound_defaults{
footstep = {name="default_hard_footstep", gain=0.3},
},
is_ground_content = false,
_mcl_armor_element = "head",
_mcl_blast_resistance = 1,
_mcl_hardness = 1,
on_secondary_use = equip_armor,
}
mcl_heads.deftemplate_floor_angled = {
drawtype = "mesh",
selection_box = {
type = "fixed",
fixed = mcl_heads.FLOOR_BOX,
},
collision_box = {
type = "fixed",
fixed = mcl_heads.FLOOR_BOX,
},
groups = {
handy = 1,
head = 1,
deco_block = 1,
dig_by_piston = 1,
not_in_creative_inventory = 1,
},
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false,
paramtype = "light",
paramtype2 = "facedir",
stack_max = 64,
sunlight_propagates = true,
sounds = mcl_sounds.node_sound_defaults{
footstep = {name="default_hard_footstep", gain=0.3},
},
is_ground_content = false,
_doc_items_create_entry = false,
_mcl_blast_resistance = 1,
_mcl_hardness = 1,
}
function mcl_heads.deftemplate_floor.on_rotate(pos, node, user, mode, new_param2)
if mode == screwdriver.ROTATE_AXIS then
node.name = node.name .. "_wall"
node.param2 = minetest.dir_to_wallmounted(minetest.facedir_to_dir(node.param2))
minetest.set_node(pos, node)
return true
end
end
function mcl_heads.deftemplate_floor.on_place(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local under = pointed_thing.under
local node = minetest.get_node(under)
local def = minetest.registered_nodes[node.name]
if not def then return itemstack end
-- Allow pointed node's on_rightclick callback to override place.
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(under, node, placer, itemstack) or itemstack
end
end
local above = pointed_thing.above
local dir = {x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}
local wdir = minetest.dir_to_wallmounted(dir)
local itemstring = itemstack:get_name()
local placestack = ItemStack(itemstack)
-- place wall head node (elsewhere)
if wdir ~= 0 and wdir ~= 1 then
placestack:set_name(itemstring .."_wall")
itemstack = minetest.item_place(placestack, placer, pointed_thing, wdir)
-- place floor head node (floor and ceiling)
else
local fdir = minetest.dir_to_facedir(dir)
-- determine the head node rotation based on player's yaw (in cw direction from North/Z+)
local yaw = placer:get_look_horizontal()
yaw = wdir == 1 and math.pi*2 - yaw or yaw
local rotation_level = math.min(math.max(math.round((yaw / (math.pi*2)) * 16), 0), 15)
placestack:set_name(itemstring ..mcl_heads.FLOOR_DEGREES[rotation_level % 4])
-- determine the head node face direction based on rotation level
fdir = math.floor(rotation_level / 4) + (wdir == 1 and 0 or 20)
itemstack = minetest.item_place(placestack, placer, pointed_thing, fdir)
end
-- restore item from angled and wall head nodes
itemstack:set_name(itemstring)
return itemstack
end
-- wall head node nodedef template -------------------------------------------------------------------------------------
--- node definition template for wall mod heads
mcl_heads.deftemplate_wall = {
drawtype = "nodebox",
node_box = {
type = "wallmounted",
wall_bottom = { -0.25, -0.5, -0.25, 0.25, 0.0, 0.25, },
wall_top = { -0.25, 0.0, -0.25, 0.25, 0.5, 0.25, },
wall_side = { -0.5, -0.25, -0.25, 0.0, 0.25, 0.25, },
},
groups = {
handy = 1,
head = 1,
deco_block = 1,
dig_by_piston = 1,
not_in_creative_inventory = 1,
},
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false,
paramtype = "light",
paramtype2 = "wallmounted",
stack_max = 64,
sunlight_propagates = true,
sounds = mcl_sounds.node_sound_defaults{
footstep = {name="default_hard_footstep", gain=0.3},
},
is_ground_content = false,
_doc_items_create_entry = false,
_mcl_blast_resistance = 1,
_mcl_hardness = 1,
}
function mcl_heads.deftemplate_wall.on_rotate(pos, node, user, mode, new_param2)
if mode == screwdriver.ROTATE_AXIS then
node.name = string.sub(node.name, 1, string.len(node.name)-5)
node.param2 = minetest.dir_to_facedir(minetest.wallmounted_to_dir(node.param2))
minetest.set_node(pos, node)
return true
end
end
-- API functions -------------------------------------------------------------------------------------------------------
--- @class HeadDef
--- @field name string identifier for node
--- @field texture string armor texture for node
--- @field description string translated description
--- @field longdesc string translated doc description
--- @field range_mob string name of mob affected by range reduction
--- @field range_factor number factor of range reduction
--- registers a head
--- @param head_def HeadDef head node definition
function mcl_heads.register_head(head_def)
local name = "mcl_heads:" ..head_def.name
-- register the floor head node
minetest.register_node(name, table.update(table.copy(mcl_heads.deftemplate_floor), {
description = head_def.description,
_doc_items_longdesc = head_def.longdesc,
-- The head textures are based off the textures of an actual mob.
tiles = {
-- Note: bottom texture is overlaid over top texture to get rid of possible transparency.
-- This is required for skeleton skull and wither skeleton skull.
-- Note: -x coords go right per-pixel, -y coords go down per-pixel
"[combine:16x16:-36,4=" ..head_def.texture, -- top
"([combine:16x16:-36,4=" ..head_def.texture..")^([combine:16x16:-44,4="..head_def.texture..")", -- bottom
"[combine:16x16:-28,0=" ..head_def.texture, -- left
"[combine:16x16:-44,0=" ..head_def.texture, -- right
"[combine:16x16:-52,0=" ..head_def.texture, -- back
"[combine:16x16:-36,0=" ..head_def.texture, -- front
},
_mcl_armor_mob_range_mob = head_def.range_mob,
_mcl_armor_mob_range_factor = head_def.range_factor,
_mcl_armor_texture = head_def.texture
}))
-- register the angled floor head nodes
for i, d in ipairs(mcl_heads.FLOOR_DEGREES) do
minetest.register_node(name ..d, table.update(table.copy(mcl_heads.deftemplate_floor_angled), {
mesh = "mcl_heads_floor" ..d ..".obj",
tiles = { head_def.texture },
drop = name,
}))
end
-- register the wall head node
minetest.register_node(name .."_wall", table.update(table.copy(mcl_heads.deftemplate_wall), {
-- The head textures are based off the textures of an actual mob.
-- Note: -x coords go right per-pixel, -y coords go down per-pixel
tiles = {
{ name = "[combine:16x16:-36,-4=" ..head_def.texture, align_style = "world" }, -- front
{ name = "[combine:16x16:-52,-4="..head_def.texture, align_style = "world" }, -- back
{ name = "[combine:16x16:-40,-4=" ..head_def.texture, align_style = "world" }, -- right
{ name = "[combine:16x16:-32,-4=" ..head_def.texture, align_style = "world" }, -- left
{ name = "([combine:16x16:-36,0=" ..head_def.texture ..")^[transformR180", align_style = "node" }, -- top
-- Note: bottom texture is overlaid over top texture to get rid of possible transparency.
-- This is required for skeleton skull and wither skeleton skull.
{ name = "([combine:16x16:-36,0=" ..head_def.texture ..")^([combine:16x16:-44,8=" ..head_def.texture..")", align_style = "node" }, -- bottom
},
drop = name,
}))
end
-- initial heads -------------------------------------------------------------------------------------------------------
mcl_heads.register_head{
name = "zombie",
texture = "mcl_heads_zombie.png",
description = S("Zombie Head"),
longdesc = S("A zombie head is a small decorative block which resembles the head of a zombie. It can also be worn as a helmet, which reduces the detection range of zombies by 50%."),
range_mob = "mobs_mc:zombie",
range_factor = 0.5,
}
mcl_heads.register_head{
name = "stalker",
texture = "mcl_heads_stalker.png",
description = S("Stalker Head"),
longdesc = S("A stalker head is a small decorative block which resembles the head of a stalker. It can also be worn as a helmet, which reduces the detection range of stalkers by 50%."),
range_mob = "mobs_mc:stalker",
range_factor = 0.5,
}
-- Original Minecraft name: “Head”
mcl_heads.register_head{
name = "steve",
texture = "mcl_heads_steve.png",
description = S("Human Head"),
longdesc = S("A human head is a small decorative block which resembles the head of a human (i.e. a player character). It can also be worn as a helmet for fun, but does not offer any protection."),
}
mcl_heads.register_head{
name = "skeleton",
texture = "mcl_heads_skeleton.png",
description = S("Skeleton Skull"),
longdesc = S("A skeleton skull is a small decorative block which resembles the skull of a skeleton. It can also be worn as a helmet, which reduces the detection range of skeletons by 50%."),
range_mob = "mobs_mc:skeleton",
range_factor = 0.5,
}
mcl_heads.register_head{
name = "wither_skeleton",
texture = "mcl_heads_wither_skeleton.png",
description = S("Wither Skeleton Skull"),
longdesc = S("A wither skeleton skull is a small decorative block which resembles the skull of a wither skeleton. It can also be worn as a helmet for fun, but does not offer any protection."),
}

View File

@ -1,109 +0,0 @@
---------------
---- Honey ----
---------------
mcl_honey = {}
-- Variables
local S = minetest.get_translator(minetest.get_current_modname())
local alldirs = { { x = 0, y = 0, z = 1 }, { x = 1, y = 0, z = 0 }, { x = 0, y = 0, z = -1 }, { x = -1, y = 0, z = 0 }, { x = 0, y = -1, z = 0 }, { x = 0, y = 1, z = 0 } }
minetest.register_node("mcl_honey:honey_block", {
description = S("Honey Block"),
_doc_items_longdesc = S("Honey Block. Used as a decoration and in redstone. Is sticky on some sides."),
tiles = { "mcl_honey_block_side.png" },
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "blend" or true,
groups = { handy = 1, deco_block = 1, fall_damage_add_percent = -80 },
sounds = {
dug = { name = "slimenodes_dug", gain = 0.6 },
place = { name = "slimenodes_place", gain = 0.6 },
footstep = { name = "slimenodes_step", gain = 0.3 },
},
paramtype = "light",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{ -0.4, -0.4, -0.4, 0.4, 0.4, 0.4 },
{ -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
}
},
selection_box = {
type = "regular",
},
_mcl_blast_resistance = 0,
_mcl_hardness = 0,
mvps_sticky = function(pos, node, piston_pos)
local connected = {}
for n, v in ipairs(alldirs) do
local neighbor_pos = vector.add(pos, v)
local neighbor_node = minetest.get_node(neighbor_pos)
if neighbor_node then
if neighbor_node.name == "ignore" then
minetest.get_voxel_manip():read_from_map(neighbor_pos, neighbor_pos)
neighbor_node = minetest.get_node(neighbor_pos)
end
local name = neighbor_node.name
if name ~= "air" and name ~= "ignore" and name ~= "mcl_core:slimeblock" and not mesecon.mvps_unsticky[name] then
local piston, piston_side, piston_up, piston_down = false, false, false, false
if name == "mesecons_pistons:piston_sticky_off" or name == "mesecons_pistons:piston_normal_off" then
piston, piston_side = true, true
elseif name == "mesecons_pistons:piston_up_sticky_off" or name == "mesecons_pistons:piston_up_normal_off" then
piston, piston_up = true, true
elseif name == "mesecons_pistons:piston_down_sticky_off" or name == "mesecons_pistons:piston_down_normal_off" then
piston, piston_down = true, true
end
if not ((piston_side and (n - 1 == neighbor_node.param2)) or (piston_up and (n == 5)) or (piston_down and (n == 6))) then
if piston and piston_pos then
if piston_pos.x == neighbor_pos.x and piston_pos.y == neighbor_pos.y and piston_pos.z == neighbor_pos.z then
-- Loopback to the same piston! Preventing unwanted behavior:
return {}, true
end
end
table.insert(connected, neighbor_pos)
end
end
end
end
return connected, false
end,
})
-- Crafting
minetest.register_craft({
output = "mcl_honey:honeycomb_block",
recipe = {
{ "mcl_honey:honeycomb", "mcl_honey:honeycomb" },
{ "mcl_honey:honeycomb", "mcl_honey:honeycomb" },
},
})
minetest.register_craft({
output = "mcl_honey:honey_block",
recipe = {
{ "mcl_honey:honey_bottle", "mcl_honey:honey_bottle" },
{ "mcl_honey:honey_bottle", "mcl_honey:honey_bottle" },
},
replacements = {
{ "mcl_honey:honey_bottle", "mcl_potions:glass_bottle" },
{ "mcl_honey:honey_bottle", "mcl_potions:glass_bottle" },
{ "mcl_honey:honey_bottle", "mcl_potions:glass_bottle" },
{ "mcl_honey:honey_bottle", "mcl_potions:glass_bottle" },
},
})
minetest.register_craft({
output = "mcl_honey:honey_bottle 4",
recipe = {
{ "mcl_potions:glass_bottle", "mcl_potions:glass_bottle", "mcl_honey:honey_block" },
{ "mcl_potions:glass_bottle", "mcl_potions:glass_bottle", "" },
},
})
minetest.register_craft({
type = "shapeless",
output = "mcl_core:sugar 3",
recipe = { "mcl_honey:honey_bottle" },
replacements = {
{ "mcl_honey:honey_bottle", "mcl_potions:glass_bottle" },
},
})

View File

@ -1,34 +0,0 @@
local S = minetest.get_translator(minetest.get_current_modname())
-- Loom Code. Used to craft banner designs easier. Still needs a GUI. https://minecraft.fandom.com/wiki/Loom
minetest.register_node("mcl_loom:loom", {
description = S("Loom"),
_tt_help = S("Used to create banner designs"),
_doc_items_longdesc = S("This is the shepherd villager's work station. It is used to create banner designs."),
tiles = {
"loom_top.png", "loom_bottom.png",
"loom_side.png", "loom_side.png",
"loom_side.png", "loom_front.png"
},
paramtype2 = "facedir",
groups = { axey = 2, handy = 1, deco_block = 1, material_wood = 1, flammable = 1 },
sounds = mcl_sounds.node_sound_wood_defaults(),
_mcl_blast_resistance = 2.5,
_mcl_hardness = 2.5
})
minetest.register_craft({
output = "mcl_loom:loom",
recipe = {
{ "", "", "" },
{ "mcl_mobitems:string", "mcl_mobitems:string", "" },
{ "group:wood", "group:wood", "" },
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_loom:loom",
burntime = 15,
})

View File

@ -103,49 +103,6 @@ minetest.register_node("mcl_nether:nether_wart", {
}
})
minetest.register_craftitem("mcl_nether:nether_wart_item", {
description = S("Nether Wart"),
_tt_help = S("Grows on soul sand"),
_doc_items_longdesc = S("Nether warts are plants home to the Nether. They can be planted on soul sand and grow in 4 stages."),
_doc_items_usagehelp = S("Place this item on soul sand to plant it and watch it grow."),
inventory_image = "mcl_nether_nether_wart.png",
wield_image = "mcl_nether_nether_wart.png",
groups = {craftitem = 1, brewitem = 1, compostability = 30},
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
-- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node(pointed_thing.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(pointed_thing.under, node, placer, itemstack) or itemstack
end
end
local placepos = pointed_thing.above
local soilpos = table.copy(placepos)
soilpos.y = soilpos.y - 1
-- Check for correct soil type
local chk = minetest.get_item_group(minetest.get_node(soilpos).name, "soil_nether_wart")
if chk and chk ~= 0 then
-- Check if node above soil node allows placement
if minetest.registered_items[minetest.get_node(placepos).name].buildable_to then
-- Place nether wart
minetest.sound_play({name="default_place_node", gain=1.0}, {pos=placepos}, true)
minetest.set_node(placepos, {name="mcl_nether:nether_wart_0", param2 = 3})
if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
return itemstack
end
end
end,
})
local names = {"mcl_nether:nether_wart_0", "mcl_nether:nether_wart_1", "mcl_nether:nether_wart_2"}
minetest.register_abm({

View File

@ -1,59 +0,0 @@
local S = minetest.get_translator(minetest.get_current_modname())
local function register_raw_ore(description, n)
local ore = description:lower()
local n = n or ""
local raw_ingot = "mcl_raw_ores:raw_"..ore
local texture = "mcl_raw_ores_raw_"..ore
minetest.register_craftitem(raw_ingot, {
description = S("Raw "..description),
_doc_items_longdesc = S("Raw "..ore..". Mine a"..n.." "..ore.." ore to get it."),
inventory_image = texture..".png",
groups = { craftitem = 1, blast_furnace_smeltable = 1 },
})
minetest.register_node(raw_ingot.."_block", {
description = S("Block of Raw "..description),
_doc_items_longdesc = S("A block of raw "..ore.." is mostly a decorative block but also useful as a compact storage of raw "..ore.."."),
tiles = { texture.."_block.png" },
is_ground_content = false,
groups = { pickaxey = 2, building_block = 1, blast_furnace_smeltable = 1 },
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
})
minetest.register_craft({
output = raw_ingot.."_block",
recipe = {
{ raw_ingot, raw_ingot, raw_ingot },
{ raw_ingot, raw_ingot, raw_ingot },
{ raw_ingot, raw_ingot, raw_ingot },
},
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:"..ore.."_ingot",
recipe = raw_ingot,
cooktime = 10,
})
minetest.register_craft({
type = "cooking",
output = "mcl_core:"..ore.."block",
recipe = raw_ingot.."_block",
cooktime = 90,
})
minetest.register_craft({
output = raw_ingot.." 9",
recipe = {
{ raw_ingot.."_block" },
},
})
end
register_raw_ore("Iron", "n")
register_raw_ore("Gold")