diff --git a/mods/mp_minetest/beds/functions.lua b/mods/mp_minetest/beds/functions.lua index 98483306..896844e5 100644 --- a/mods/mp_minetest/beds/functions.lua +++ b/mods/mp_minetest/beds/functions.lua @@ -29,7 +29,6 @@ local function is_night_skip_enabled() return enable_night_skip end ---[[ local function check_in_beds(players) local in_bed = beds.player if not players then @@ -45,12 +44,6 @@ local function check_in_beds(players) return #players > 0 end -]]-- - --- Allow night skip if any player is in bed -local function check_in_beds(players) - return true -end local function lay_down(player, pos, bed_pos, state, skip) local name = player:get_player_name() diff --git a/mods/mp_minetest/bucket/depends.txt b/mods/mp_minetest/bucket/depends.txt index b57e07ed..3a7daa1d 100644 --- a/mods/mp_minetest/bucket/depends.txt +++ b/mods/mp_minetest/bucket/depends.txt @@ -1,2 +1,2 @@ default -craft_guide? + diff --git a/mods/mp_minetest/creative/init.lua b/mods/mp_minetest/creative/init.lua index f9047189..bba9b34e 100644 --- a/mods/mp_minetest/creative/init.lua +++ b/mods/mp_minetest/creative/init.lua @@ -55,8 +55,7 @@ function minetest.handle_node_drops(pos, drops, digger) local inv = digger:get_inventory() if inv then for _, item in ipairs(drops) do - item = ItemStack(item):get_name() - if not inv:contains_item("main", item) then + if not inv:contains_item("main", item, true) then inv:add_item("main", item) end end diff --git a/mods/mp_minetest/default/README.txt b/mods/mp_minetest/default/README.txt index fc6def98..8e8541c9 100644 --- a/mods/mp_minetest/default/README.txt +++ b/mods/mp_minetest/default/README.txt @@ -78,10 +78,6 @@ Splizard (CC BY-SA 3.0): Zeg9 (CC BY-SA 3.0): default_coal_block.png - default_steel_block.png - default_copper_block.png - default_bronze_block.png - default_gold_block.png paramat (CC BY-SA 3.0): wieldhand.png -- Copied from character.png by Jordach (CC BY-SA 3.0) @@ -158,6 +154,9 @@ sofar (CC BY-SA 3.0): default_aspen_tree default_aspen_tree_top, derived from default_pine_tree_top (by paramat) default_aspen_wood, derived from default_pine_wood (by paramat) + default_chest_wood, default_chest_wood_locked derived from default_chest_* textures by BlockMen + +sofar (WTFPL): default_gravel.png -- Derived from Gambit's PixelBOX texture pack light gravel Neuromancer (CC BY-SA 2.0): @@ -212,6 +211,16 @@ kaeza (CC-BY-SA 3.0): default_desert_sandstone_brick.png default_desert_sandstone_block.png +kilbith (CC BY-SA 3.0): + default_steel_block.png + default_copper_block.png + default_bronze_block.png + default_gold_block.png + default_tin_block.png + default_mineral_tin.png + default_tin_ingot.png + default_tin_lump.png + Glass breaking sounds (CC BY 3.0): 1: http://www.freesound.org/people/cmusounddesign/sounds/71947/ 2: http://www.freesound.org/people/Tomlija/sounds/97669/ @@ -279,3 +288,13 @@ https://www.freesound.org/people/AGFX/packs/1253/ blukotek (CC0 1.0) https://www.freesound.org/people/blukotek/sounds/251660/ default_dig_snappy.ogg + +Chests sounds added by sofar, derived of several files mixed together: + default_chest_open.ogg + default_chest_close.ogg + - http://www.freesound.org/people/Sevin7/sounds/269722/ CC0 + - http://www.freesound.org/people/Percy%20Duke/sounds/23448/ CC-BY-3.0 + - http://www.freesound.org/people/kingsamas/sounds/135576/ CC-BY-3.0 + - http://www.freesound.org/people/bulbastre/sounds/126887/ CC-BY-3.0 + - http://www.freesound.org/people/Yoyodaman234/sounds/183541/ CC0 + diff --git a/mods/mp_minetest/default/crafting.lua b/mods/mp_minetest/default/crafting.lua index 721f4132..50ffb1ae 100644 --- a/mods/mp_minetest/default/crafting.lua +++ b/mods/mp_minetest/default/crafting.lua @@ -392,12 +392,6 @@ minetest.register_craft({ } }) -minetest.register_craft({ - type = "shapeless", - output = "default:bronze_ingot", - recipe = {"default:steel_ingot", "default:copper_ingot"}, -}) - minetest.register_craft({ output = 'default:coalblock', recipe = { @@ -446,6 +440,31 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = "default:tinblock", + recipe = { + {"default:tin_ingot", "default:tin_ingot", "default:tin_ingot"}, + {"default:tin_ingot", "default:tin_ingot", "default:tin_ingot"}, + {"default:tin_ingot", "default:tin_ingot", "default:tin_ingot"}, + } +}) + +minetest.register_craft({ + output = "default:tin_ingot 9", + recipe = { + {"default:tinblock"}, + } +}) + +minetest.register_craft({ + output = "default:bronze_ingot 9", + recipe = { + {"default:copper_ingot", "default:copper_ingot", "default:copper_ingot"}, + {"default:copper_ingot", "default:tin_ingot", "default:copper_ingot"}, + {"default:copper_ingot", "default:copper_ingot", "default:copper_ingot"}, + } +}) + minetest.register_craft({ output = 'default:bronzeblock', recipe = { @@ -849,6 +868,12 @@ minetest.register_craft({ recipe = "default:copper_lump", }) +minetest.register_craft({ + type = "cooking", + output = "default:tin_ingot", + recipe = "default:tin_lump", +}) + minetest.register_craft({ type = "cooking", output = "default:gold_ingot", diff --git a/mods/mp_minetest/default/craftitems.lua b/mods/mp_minetest/default/craftitems.lua index aa8f56bd..33cdd5f6 100644 --- a/mods/mp_minetest/default/craftitems.lua +++ b/mods/mp_minetest/default/craftitems.lua @@ -12,6 +12,7 @@ minetest.register_craftitem("default:paper", { groups = {flammable = 3}, }) + local lpp = 14 -- Lines per book's page local function book_on_use(itemstack, user) local player_name = user:get_player_name() @@ -93,6 +94,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) data = stack:get_meta():to_table().fields end + if data and data.owner and data.owner ~= player:get_player_name() then + return + end + if not data then data = {} end data.title = fields.title data.owner = player:get_player_name() @@ -134,7 +139,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end - stack:get_meta():from_table(data) + stack:get_meta():from_table({fields = data}) stack = book_on_use(stack, player) end @@ -186,6 +191,62 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv craft_inv:set_stack("craft", index, original) end) +minetest.register_craftitem("default:skeleton_key", { + description = "Skeleton Key", + inventory_image = "default_key_skeleton.png", + groups = {key = 1}, + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type ~= "node" then + return itemstack + end + + local pos = pointed_thing.under + local node = minetest.get_node(pos) + + if not node then + return itemstack + end + + local on_skeleton_key_use = minetest.registered_nodes[node.name].on_skeleton_key_use + if not on_skeleton_key_use then + return itemstack + end + + -- make a new key secret in case the node callback needs it + local random = math.random + local newsecret = string.format( + "%04x%04x%04x%04x", + random(2^16) - 1, random(2^16) - 1, + random(2^16) - 1, random(2^16) - 1) + + local secret, _, _ = on_skeleton_key_use(pos, user, newsecret) + + if secret then + local inv = minetest.get_inventory({type="player", name=user:get_player_name()}) + + -- update original itemstack + itemstack:take_item() + + -- finish and return the new key + local new_stack = ItemStack("default:key") + local meta = new_stack:get_meta() + meta:set_string("secret", secret) + meta:set_string("description", "Key to "..user:get_player_name().."'s " + ..minetest.registered_nodes[node.name].description) + + if itemstack:get_count() == 0 then + itemstack = new_stack + else + if inv:add_item("main", new_stack):get_count() > 0 then + minetest.add_item(user:getpos(), new_stack) + end -- else: added to inventory successfully + end + + return itemstack + end + end +}) + minetest.register_craftitem("default:coal_lump", { description = "Coal Lump", inventory_image = "default_coal_lump.png", @@ -202,6 +263,11 @@ minetest.register_craftitem("default:copper_lump", { inventory_image = "default_copper_lump.png", }) +minetest.register_craftitem("default:tin_lump", { + description = "Tin Lump", + inventory_image = "default_tin_lump.png", +}) + minetest.register_craftitem("default:mese_crystal", { description = "Mese Crystal", inventory_image = "default_mese_crystal.png", @@ -232,6 +298,11 @@ minetest.register_craftitem("default:copper_ingot", { inventory_image = "default_copper_ingot.png", }) +minetest.register_craftitem("default:tin_ingot", { + description = "Tin Ingot", + inventory_image = "default_tin_ingot.png", +}) + minetest.register_craftitem("default:bronze_ingot", { description = "Bronze Ingot", inventory_image = "default_bronze_ingot.png", diff --git a/mods/mp_minetest/default/depends.txt b/mods/mp_minetest/default/depends.txt deleted file mode 100644 index ac03cfdc..00000000 --- a/mods/mp_minetest/default/depends.txt +++ /dev/null @@ -1 +0,0 @@ -craft_guide? \ No newline at end of file diff --git a/mods/mp_minetest/default/license.txt b/mods/mp_minetest/default/license.txt index 09e4225f..72af7284 100644 --- a/mods/mp_minetest/default/license.txt +++ b/mods/mp_minetest/default/license.txt @@ -43,6 +43,7 @@ Copyright (C) 2010-2016: Mito551 GreenXenith kaeza + kilbith You are free to: Share — copy and redistribute the material in any medium or format. diff --git a/mods/mp_minetest/default/mapgen.lua b/mods/mp_minetest/default/mapgen.lua index 9e359a33..1305226a 100644 --- a/mods/mp_minetest/default/mapgen.lua +++ b/mods/mp_minetest/default/mapgen.lua @@ -357,6 +357,41 @@ function default.register_ores() y_max = -64, }) + -- Tin + + minetest.register_ore({ + ore_type = "scatter", + ore = "default:stone_with_tin", + wherein = "default:stone", + clust_scarcity = 10 * 10 * 10, + clust_num_ores = 5, + clust_size = 3, + y_min = 1025, + y_max = 31000, + }) + + minetest.register_ore({ + ore_type = "scatter", + ore = "default:stone_with_tin", + wherein = "default:stone", + clust_scarcity = 13 * 13 * 13, + clust_num_ores = 4, + clust_size = 3, + y_min = -127, + y_max = -32, + }) + + minetest.register_ore({ + ore_type = "scatter", + ore = "default:stone_with_tin", + wherein = "default:stone", + clust_scarcity = 10 * 10 * 10, + clust_num_ores = 5, + clust_size = 3, + y_min = -31000, + y_max = -128, + }) + -- Gold minetest.register_ore({ diff --git a/mods/mp_minetest/default/models/chest_open.obj b/mods/mp_minetest/default/models/chest_open.obj new file mode 100644 index 00000000..a1dcce8d --- /dev/null +++ b/mods/mp_minetest/default/models/chest_open.obj @@ -0,0 +1,82 @@ +# Blender v2.76 (sub 0) OBJ File: 'chest_open.blend' +# www.blender.org +mtllib chest_open.mtl +o Bottom_Cube.001 +v -0.500000 -0.500000 0.500000 +v -0.500000 0.187500 0.500000 +v -0.500000 -0.500000 -0.500000 +v -0.500000 0.187500 -0.500000 +v 0.500000 -0.500000 0.500000 +v 0.500000 0.187500 0.500000 +v 0.500000 -0.500000 -0.500000 +v 0.500000 0.187500 -0.500000 +vt 0.750000 0.343750 +vt 0.500000 0.343750 +vt 0.500000 0.000000 +vt 0.750000 0.000000 +vt 0.250000 0.343750 +vt 0.250000 0.000000 +vt 0.000000 0.343750 +vt 0.000000 0.000000 +vt 0.750000 0.875000 +vt 0.500000 0.875000 +vt 0.500000 0.500000 +vt 0.750000 0.500000 +vt 0.250000 0.500000 +vt 0.250000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.500000 +vt 1.000000 0.500000 +vt 1.000000 0.000000 +vn -1.000000 0.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 1.000000 0.000000 0.000000 +vn 0.000000 0.000000 1.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +usemtl None +s off +f 2/1/1 4/2/1 3/3/1 1/4/1 +f 4/2/2 8/5/2 7/6/2 3/3/2 +f 8/5/3 6/7/3 5/8/3 7/6/3 +f 6/9/4 2/10/4 1/11/4 5/12/4 +f 1/13/5 3/14/5 7/15/5 5/16/5 +f 6/4/6 8/12/6 4/17/6 2/18/6 +o Top_Cube.002 +v -0.499900 0.187501 0.499900 +v -0.499900 0.408471 0.720970 +v -0.499900 0.894607 -0.207108 +v -0.499900 1.115578 0.013863 +v 0.499900 0.187501 0.499900 +v 0.499900 0.408471 0.720970 +v 0.499900 0.894607 -0.207108 +v 0.499900 1.115578 0.013863 +vt 0.750000 0.500000 +vt 0.500000 0.500000 +vt 0.500000 0.343750 +vt 0.750000 0.343750 +vt 0.250000 0.500000 +vt 0.250000 0.343750 +vt 0.000000 0.500000 +vt 0.000000 0.343750 +vt 0.750000 1.000000 +vt 0.500000 1.000000 +vt 0.500000 0.843750 +vt 0.750000 0.843750 +vt 1.000000 0.500000 +vt 1.000000 1.000000 +vt 0.250000 1.000000 +vn -1.000000 0.000000 0.000000 +vn 0.000000 0.707100 -0.707100 +vn 1.000000 0.000000 0.000000 +vn 0.000000 -0.707100 0.707100 +vn 0.000000 -0.707100 -0.707100 +vn 0.000000 0.707100 0.707100 +usemtl None +s off +f 10/19/7 12/20/7 11/21/7 9/22/7 +f 12/20/8 16/23/8 15/24/8 11/21/8 +f 16/23/9 14/25/9 13/26/9 15/24/9 +f 14/27/10 10/28/10 9/29/10 13/30/10 +f 9/31/11 11/32/11 15/27/11 13/19/11 +f 14/33/12 16/23/12 12/20/12 10/28/12 diff --git a/mods/mp_minetest/default/models/cube.obj b/mods/mp_minetest/default/models/cube.obj new file mode 100644 index 00000000..7bbec5de --- /dev/null +++ b/mods/mp_minetest/default/models/cube.obj @@ -0,0 +1,38 @@ +# Blender v2.76 (sub 0) OBJ File: 'chest_close.blend' +# www.blender.org +mtllib chest_close.mtl +o Cube_Cube.001 +v -0.500000 -0.500000 0.500000 +v -0.500000 0.500000 0.500000 +v -0.500000 -0.500000 -0.500000 +v -0.500000 0.500000 -0.500000 +v 0.500000 -0.500000 0.500000 +v 0.500000 0.500000 0.500000 +v 0.500000 -0.500000 -0.500000 +v 0.500000 0.500000 -0.500000 +vt 0.750000 0.500000 +vt 0.500000 0.500000 +vt 0.500000 -0.000000 +vt 0.750000 0.000000 +vt 0.250000 0.500000 +vt 0.250000 0.000000 +vt 0.000000 0.500000 +vt -0.000000 0.000000 +vt 0.750000 1.000000 +vt 0.500000 1.000000 +vt 0.250000 1.000000 +vt -0.000000 1.000000 +vn -1.000000 0.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 1.000000 0.000000 0.000000 +vn 0.000000 0.000000 1.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +usemtl None +s off +f 2/1/1 4/2/1 3/3/1 1/4/1 +f 4/2/2 8/5/2 7/6/2 3/3/2 +f 8/5/3 6/7/3 5/8/3 7/6/3 +f 6/9/4 2/10/4 1/2/4 5/1/4 +f 1/5/5 3/11/5 7/12/5 5/7/5 +f 6/11/6 8/5/6 4/2/6 2/10/6 diff --git a/mods/mp_minetest/default/nodes.lua b/mods/mp_minetest/default/nodes.lua index b7309e12..c410b213 100644 --- a/mods/mp_minetest/default/nodes.lua +++ b/mods/mp_minetest/default/nodes.lua @@ -107,6 +107,10 @@ default:steelblock default:stone_with_copper default:copperblock + +default:stone_with_tin +default:tinblock + default:bronzeblock default:stone_with_gold @@ -1046,6 +1050,24 @@ minetest.register_node("default:copperblock", { sounds = default.node_sound_metal_defaults(), }) + +minetest.register_node("default:stone_with_tin", { + description = "Tin Ore", + tiles = {"default_stone.png^default_mineral_tin.png"}, + groups = {cracky = 2}, + drop = "default:tin_lump", + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("default:tinblock", { + description = "Tin Block", + tiles = {"default_tin_block.png"}, + is_ground_content = false, + groups = {cracky = 1, level = 2}, + sounds = default.node_sound_metal_defaults(), +}) + + minetest.register_node("default:bronzeblock", { description = "Bronze Block", tiles = {"default_bronze_block.png"}, @@ -1744,188 +1766,276 @@ minetest.register_node("default:lava_flowing", { -- Tools / "Advanced" crafting / Non-"natural" -- -local chest_formspec = - "size[8,9]" .. - default.gui_bg .. - default.gui_bg_img .. - default.gui_slots .. - "list[current_name;main;0,0.3;8,4;]" .. - "list[current_player;main;0,4.85;8,1;]" .. - "list[current_player;main;0,6.08;8,3;8]" .. - "listring[current_name;main]" .. - "listring[current_player;main]" .. - default.get_hotbar_bg(0,4.85) - -local function get_locked_chest_formspec(pos) +local function get_chest_formspec(pos) local spos = pos.x .. "," .. pos.y .. "," .. pos.z local formspec = "size[8,9]" .. default.gui_bg .. default.gui_bg_img .. default.gui_slots .. - "list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" .. + "list[nodemeta:" .. spos .. ";default:chest;0,0.3;8,4;]" .. "list[current_player;main;0,4.85;8,1;]" .. "list[current_player;main;0,6.08;8,3;8]" .. - "listring[nodemeta:" .. spos .. ";main]" .. + "listring[nodemeta:" .. spos .. ";default:chest]" .. "listring[current_player;main]" .. default.get_hotbar_bg(0,4.85) - return formspec + return formspec end -minetest.register_node("default:chest", { - description = "Chest", - tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", - "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"}, - paramtype2 = "facedir", - groups = {choppy = 2, oddly_breakable_by_hand = 2}, - legacy_facedir_simple = true, - is_ground_content = false, - sounds = default.node_sound_wood_defaults(), +local function chest_lid_obstructed(pos) + local above = { x = pos.x, y = pos.y + 1, z = pos.z } + local def = minetest.registered_nodes[minetest.get_node(above).name] + -- allow ladders, signs, wallmounted things and torches to not obstruct + if def.drawtype == "airlike" or + def.drawtype == "signlike" or + def.drawtype == "torchlike" or + (def.drawtype == "nodebox" and def.paramtype2 == "wallmounted") then + return false + end + return true +end - on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", chest_formspec) - local inv = meta:get_inventory() - inv:set_size("main", 8*4) - end, - can_dig = function(pos,player) - local meta = minetest.get_meta(pos); - local inv = meta:get_inventory() - return inv:is_empty("main") - end, - on_metadata_inventory_move = function(pos, from_list, from_index, +local open_chests = {} + +minetest.register_on_player_receive_fields(function(player, formname, fields) + if formname ~= "default:chest" then + return + end + if not fields.quit then + return + end + local pn = player:get_player_name() + + local pos = open_chests[pn].pos + local sound = open_chests[pn].sound + local swap = open_chests[pn].swap + local node = minetest.get_node(pos) + + open_chests[pn] = nil + for k, v in pairs(open_chests) do + if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then + return true + end + end + minetest.after(0.2, minetest.swap_node, pos, { name = "default:" .. swap, + param2 = node.param2 }) + minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10}) + return true +end) + +function default.register_chest(name, d) + local def = table.copy(d) + def.drawtype = "mesh" + def.visual = "mesh" + def.paramtype = "light" + def.paramtype2 = "facedir" + def.legacy_facedir_simple = true + def.is_ground_content = false + + if def.protected then + def.on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", "Locked Chest") + meta:set_string("owner", "") + local inv = meta:get_inventory() + inv:set_size("default:chest", 8*4) + end + def.after_place_node = function(pos, placer) + local meta = minetest.get_meta(pos) + meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext", "Locked Chest (owned by " .. + meta:get_string("owner") .. ")") + end + def.can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("default:chest") and + default.can_interact_with_node(player, pos) + end + def.allow_metadata_inventory_move = function(pos, from_list, from_index, + to_list, to_index, count, player) + if not default.can_interact_with_node(player, pos) then + return 0 + end + return count + end + def.allow_metadata_inventory_put = function(pos, listname, index, stack, player) + if not default.can_interact_with_node(player, pos) then + return 0 + end + return stack:get_count() + end + def.allow_metadata_inventory_take = function(pos, listname, index, stack, player) + if not default.can_interact_with_node(player, pos) then + return 0 + end + return stack:get_count() + end + def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + if not default.can_interact_with_node(clicker, pos) then + return itemstack + end + + minetest.sound_play(def.sound_open, {gain = 0.3, + pos = pos, max_hear_distance = 10}) + if not chest_lid_obstructed(pos) then + minetest.swap_node(pos, + { name = "default:" .. name .. "_open", + param2 = node.param2 }) + end + minetest.after(0.2, minetest.show_formspec, + clicker:get_player_name(), + "default:chest", get_chest_formspec(pos)) + open_chests[clicker:get_player_name()] = { pos = pos, + sound = def.sound_close, swap = name } + end + def.on_blast = function() end + def.on_key_use = function(pos, player) + local secret = minetest.get_meta(pos):get_string("key_lock_secret") + local itemstack = player:get_wielded_item() + local key_meta = itemstack:get_meta() + + if key_meta:get_string("secret") == "" then + key_meta:set_string("secret", minetest.parse_json(itemstack:get_metadata()).secret) + itemstack:set_metadata("") + end + + if secret ~= key_meta:get_string("secret") then + return + end + + minetest.show_formspec( + player:get_player_name(), + "default:chest_locked", + get_chest_formspec(pos) + ) + end + def.on_skeleton_key_use = function(pos, player, newsecret) + local meta = minetest.get_meta(pos) + local owner = meta:get_string("owner") + local pn = player:get_player_name() + + -- verify placer is owner of lockable chest + if owner ~= pn then + minetest.record_protection_violation(pos, pn) + minetest.chat_send_player(pn, "You do not own this chest.") + return nil + end + + local secret = meta:get_string("key_lock_secret") + if secret == "" then + secret = newsecret + meta:set_string("key_lock_secret", secret) + end + + return secret, "a locked chest", owner + end + else + def.on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", "Chest") + local inv = meta:get_inventory() + inv:set_size("default:chest", 8*4) + end + def.can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("default:chest") + end + def.on_rightclick = function(pos, node, clicker) + minetest.sound_play(def.sound_open, {gain = 0.3, pos = pos, + max_hear_distance = 10}) + if not chest_lid_obstructed(pos) then + minetest.swap_node(pos, { + name = "default:" .. name .. "_open", + param2 = node.param2 }) + end + minetest.after(0.2, minetest.show_formspec, + clicker:get_player_name(), + "default:chest", get_chest_formspec(pos)) + open_chests[clicker:get_player_name()] = { pos = pos, + sound = def.sound_close, swap = name } + end + end + + def.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 chest at " .. minetest.pos_to_string(pos)) - end, - on_metadata_inventory_put = function(pos, listname, index, stack, player) + end + def.on_metadata_inventory_put = function(pos, listname, index, stack, player) minetest.log("action", player:get_player_name() .. " moves " .. stack:get_name() .. " to chest at " .. minetest.pos_to_string(pos)) - end, - on_metadata_inventory_take = function(pos, listname, index, stack, player) + end + def.on_metadata_inventory_take = function(pos, listname, index, stack, player) minetest.log("action", player:get_player_name() .. " takes " .. stack:get_name() .. " from chest at " .. minetest.pos_to_string(pos)) - end, - on_blast = function(pos) + end + def.on_blast = function(pos) local drops = {} default.get_inventory_drops(pos, "main", drops) drops[#drops+1] = "default:chest" minetest.remove_node(pos) return drops - end, -}) + end -minetest.register_node("default:chest_locked", { - description = "Locked Chest", - tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", - "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"}, - paramtype2 = "facedir", - groups = {choppy = 2, oddly_breakable_by_hand = 2}, - legacy_facedir_simple = true, - is_ground_content = false, + local def_opened = table.copy(def) + local def_closed = table.copy(def) + + def_opened.mesh = "chest_open.obj" + def_opened.drop = "default:" .. name + def_opened.groups.not_in_creative_inventory = 1 + def_opened.selection_box = { + type = "fixed", + fixed = { -1/2, -1/2, -1/2, 1/2, 3/16, 1/2 }, + } + def_opened.can_dig = function() + return false + end + + def_closed.mesh = "cube.obj" + + minetest.register_node("default:" .. name, def_closed) + minetest.register_node("default:" .. name .. "_open", def_opened) + + -- convert old chests to this new variant + minetest.register_lbm({ + label = "update chests to opening chests", + name = "default:upgrade_" .. name, + nodenames = {"default:" .. name}, + action = function(pos, node) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", nil) + local inv = meta:get_inventory() + local list = inv:get_list("main") + inv:set_list("main", nil) + inv:set_size("default:chest", 8*4) + inv:set_list("default:chest", list) + end + }) +end + + +default.register_chest("chest", { + description = "Chest", + tiles = { "default_chest_wood.png" }, sounds = default.node_sound_wood_defaults(), - - after_place_node = function(pos, placer) - local meta = minetest.get_meta(pos) - meta:set_string("owner", placer:get_player_name() or "") - meta:set_string("infotext", "Locked Chest (owned by " .. - meta:get_string("owner") .. ")") - end, - on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("owner", "") - local inv = meta:get_inventory() - inv:set_size("main", 8 * 4) - end, - can_dig = function(pos,player) - local meta = minetest.get_meta(pos); - local inv = meta:get_inventory() - return inv:is_empty("main") and default.can_interact_with_node(player, pos) - end, - allow_metadata_inventory_move = function(pos, from_list, from_index, - to_list, to_index, count, player) - if not default.can_interact_with_node(player, pos) then - return 0 - end - return count - end, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) - if not default.can_interact_with_node(player, pos) then - return 0 - end - return stack:get_count() - end, - allow_metadata_inventory_take = function(pos, listname, index, stack, player) - if not default.can_interact_with_node(player, pos) then - return 0 - end - return stack:get_count() - end, - on_metadata_inventory_put = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name() .. - " moves " .. stack:get_name() .. - " to locked chest 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 " .. stack:get_name() .. - " from locked chest at " .. minetest.pos_to_string(pos)) - end, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) - if default.can_interact_with_node(clicker, pos) then - minetest.show_formspec( - clicker:get_player_name(), - "default:chest_locked", - get_locked_chest_formspec(pos) - ) - end - return itemstack - end, - on_blast = function() end, - on_key_use = function(pos, player) - local secret = minetest.get_meta(pos):get_string("key_lock_secret") - local itemstack = player:get_wielded_item() - local key_meta = itemstack:get_meta() - - if key_meta:get_string("secret") == "" then - key_meta:set_string("secret", minetest.parse_json(itemstack:get_metadata()).secret) - itemstack:set_metadata("") - end - - if secret ~= key_meta:get_string("secret") then - return - end - - minetest.show_formspec( - player:get_player_name(), - "default:chest_locked", - get_locked_chest_formspec(pos) - ) - end, - on_skeleton_key_use = function(pos, player, newsecret) - local meta = minetest.get_meta(pos) - local owner = meta:get_string("owner") - local name = player:get_player_name() - - -- verify placer is owner of lockable chest - if owner ~= name then - minetest.record_protection_violation(pos, name) - minetest.chat_send_player(name, "You do not own this chest.") - return nil - end - - local secret = meta:get_string("key_lock_secret") - if secret == "" then - secret = newsecret - meta:set_string("key_lock_secret", secret) - end - - return secret, "a locked chest", owner - end, + sound_open = "default_chest_open", + sound_close = "default_chest_close", + groups = {choppy = 2, oddly_breakable_by_hand = 2}, }) +default.register_chest("chest_locked", { + description = "Locked Chest", + tiles = { "default_chest_wood_locked.png" }, + sounds = default.node_sound_wood_defaults(), + sound_open = "default_chest_open", + sound_close = "default_chest_close", + groups = {choppy = 2, oddly_breakable_by_hand = 2}, + protected = true, +}) local bookshelf_formspec = "size[8,7;]" .. diff --git a/mods/mp_minetest/default/sounds/default_chest_close.ogg b/mods/mp_minetest/default/sounds/default_chest_close.ogg new file mode 100644 index 00000000..53ff23d2 Binary files /dev/null and b/mods/mp_minetest/default/sounds/default_chest_close.ogg differ diff --git a/mods/mp_minetest/default/sounds/default_chest_open.ogg b/mods/mp_minetest/default/sounds/default_chest_open.ogg new file mode 100644 index 00000000..c73c072c Binary files /dev/null and b/mods/mp_minetest/default/sounds/default_chest_open.ogg differ diff --git a/mods/mp_minetest/default/textures/default_chest_front.png b/mods/mp_minetest/default/textures/default_chest_front.png deleted file mode 100644 index 85227d8f..00000000 Binary files a/mods/mp_minetest/default/textures/default_chest_front.png and /dev/null differ diff --git a/mods/mp_minetest/default/textures/default_chest_lock.png b/mods/mp_minetest/default/textures/default_chest_lock.png deleted file mode 100644 index 73f46c78..00000000 Binary files a/mods/mp_minetest/default/textures/default_chest_lock.png and /dev/null differ diff --git a/mods/mp_minetest/default/textures/default_chest_side.png b/mods/mp_minetest/default/textures/default_chest_side.png deleted file mode 100644 index 44a65a43..00000000 Binary files a/mods/mp_minetest/default/textures/default_chest_side.png and /dev/null differ diff --git a/mods/mp_minetest/default/textures/default_chest_top.png b/mods/mp_minetest/default/textures/default_chest_top.png deleted file mode 100644 index f1a5cb59..00000000 Binary files a/mods/mp_minetest/default/textures/default_chest_top.png and /dev/null differ diff --git a/mods/mp_minetest/default/textures/default_chest_wood.png b/mods/mp_minetest/default/textures/default_chest_wood.png new file mode 100644 index 00000000..408fddb2 Binary files /dev/null and b/mods/mp_minetest/default/textures/default_chest_wood.png differ diff --git a/mods/mp_minetest/default/textures/default_chest_wood_locked.png b/mods/mp_minetest/default/textures/default_chest_wood_locked.png new file mode 100644 index 00000000..f08a7ff8 Binary files /dev/null and b/mods/mp_minetest/default/textures/default_chest_wood_locked.png differ diff --git a/mods/mp_minetest/default/textures/default_mineral_tin.png b/mods/mp_minetest/default/textures/default_mineral_tin.png new file mode 100644 index 00000000..232d4b53 Binary files /dev/null and b/mods/mp_minetest/default/textures/default_mineral_tin.png differ diff --git a/mods/mp_minetest/default/textures/default_snow.png b/mods/mp_minetest/default/textures/default_snow.png index 4ac35938..fcbef0e5 100644 Binary files a/mods/mp_minetest/default/textures/default_snow.png and b/mods/mp_minetest/default/textures/default_snow.png differ diff --git a/mods/mp_minetest/default/textures/default_tin_block.png b/mods/mp_minetest/default/textures/default_tin_block.png new file mode 100644 index 00000000..72759b04 Binary files /dev/null and b/mods/mp_minetest/default/textures/default_tin_block.png differ diff --git a/mods/mp_minetest/default/textures/default_tin_ingot.png b/mods/mp_minetest/default/textures/default_tin_ingot.png new file mode 100644 index 00000000..eed53610 Binary files /dev/null and b/mods/mp_minetest/default/textures/default_tin_ingot.png differ diff --git a/mods/mp_minetest/default/textures/default_tin_lump.png b/mods/mp_minetest/default/textures/default_tin_lump.png new file mode 100644 index 00000000..72bd339b Binary files /dev/null and b/mods/mp_minetest/default/textures/default_tin_lump.png differ diff --git a/mods/mp_minetest/default/tools.lua b/mods/mp_minetest/default/tools.lua index 1a08b918..45c779f1 100644 --- a/mods/mp_minetest/default/tools.lua +++ b/mods/mp_minetest/default/tools.lua @@ -379,48 +379,6 @@ minetest.register_tool("default:sword_diamond", { sound = {breaks = "default_tool_breaks"}, }) -minetest.register_tool("default:skeleton_key", { - description = "Skeleton Key", - inventory_image = "default_key_skeleton.png", - groups = {key = 1}, - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type ~= "node" then - return itemstack - end - - local pos = pointed_thing.under - local node = minetest.get_node(pos) - - if not node then - return itemstack - end - - local on_skeleton_key_use = minetest.registered_nodes[node.name].on_skeleton_key_use - if on_skeleton_key_use then - -- make a new key secret in case the node callback needs it - local random = math.random - local newsecret = string.format( - "%04x%04x%04x%04x", - random(2^16) - 1, random(2^16) - 1, - random(2^16) - 1, random(2^16) - 1) - - local secret, _, _ = on_skeleton_key_use(pos, user, newsecret) - - if secret then - -- finish and return the new key - itemstack:take_item() - itemstack:add_item("default:key") - local meta = itemstack:get_meta() - meta:set_string("secret", secret) - meta:set_string("description", "Key to "..user:get_player_name().."'s " - ..minetest.registered_nodes[node.name].description) - return itemstack - end - end - return nil - end -}) - minetest.register_tool("default:key", { description = "Key", inventory_image = "default_key.png", diff --git a/mods/mp_minetest/doors/init.lua b/mods/mp_minetest/doors/init.lua index a1bfc092..5189dec7 100644 --- a/mods/mp_minetest/doors/init.lua +++ b/mods/mp_minetest/doors/init.lua @@ -150,7 +150,7 @@ function _doors.door_toggle(pos, node, clicker) replace_old_owner_information(pos) - if not default.can_interact_with_node(clicker, pos) then + if clicker and not default.can_interact_with_node(clicker, pos) then return false end @@ -332,6 +332,8 @@ function doors.register(name, def) itemstack:take_item() end + minetest.sound_play(def.sounds.place, {pos = pos}) + on_place_node(pos, minetest.get_node(pos), placer, node, itemstack, pointed_thing) @@ -530,7 +532,7 @@ function _doors.trapdoor_toggle(pos, node, clicker) replace_old_owner_information(pos) - if not default.can_interact_with_node(clicker, pos) then + if clicker and not default.can_interact_with_node(clicker, pos) then return false end diff --git a/mods/mp_minetest/dye/depends.txt b/mods/mp_minetest/dye/depends.txt index 5c6e13f6..e69de29b 100644 --- a/mods/mp_minetest/dye/depends.txt +++ b/mods/mp_minetest/dye/depends.txt @@ -1,2 +0,0 @@ -flowers? -craft_guide? \ No newline at end of file diff --git a/mods/mp_minetest/dye/init.lua b/mods/mp_minetest/dye/init.lua index 87f31d12..80284576 100644 --- a/mods/mp_minetest/dye/init.lua +++ b/mods/mp_minetest/dye/init.lua @@ -81,7 +81,6 @@ local dye_recipes = { {"yellow", "red", "orange"}, {"yellow", "blue", "green"}, -- RYB complementary mixes - {"red", "green", "dark_grey"}, {"yellow", "violet", "dark_grey"}, {"blue", "orange", "dark_grey"}, -- CMY mixes - approximation diff --git a/mods/mp_minetest/stairs/init.lua b/mods/mp_minetest/stairs/init.lua index 835b2193..0ce35218 100644 --- a/mods/mp_minetest/stairs/init.lua +++ b/mods/mp_minetest/stairs/init.lua @@ -587,3 +587,27 @@ stairs.register_stair_and_slab( "Gold Block Slab", default.node_sound_metal_defaults() ) + +stairs.register_stair_and_slab( + "ice", + "default:ice", + {cracky = 3, puts_out_fire = 1, cools_lava = 1}, + {"default_ice.png"}, + "Ice Stair", + "Ice Slab", + default.node_sound_glass_defaults() +) + +stairs.register_stair_and_slab( + "snowblock", + "default:snowblock", + {crumbly = 3, puts_out_fire = 1, cools_lava = 1, snowy = 1}, + {"default_snow.png"}, + "Snow Block Stair", + "Snow Block Slab", + default.node_sound_dirt_defaults({ + footstep = {name = "default_snow_footstep", gain = 0.15}, + dug = {name = "default_snow_footstep", gain = 0.2}, + dig = {name = "default_snow_footstep", gain = 0.2} + }) +)