From 3f2e35e8272ebc7a50a9e7af01ffc365558d3408 Mon Sep 17 00:00:00 2001
From: jp <jeanpatrick.guerrero@gmail.com>
Date: Mon, 2 Mar 2015 10:29:02 +0100
Subject: [PATCH] Add vessels shelf

---
 mods/vessels/init.lua                   |  81 ++++++++++++++++++++++++
 mods/vessels/textures/vessels_shelf.png | Bin 0 -> 354 bytes
 2 files changed, 81 insertions(+)
 create mode 100644 mods/vessels/textures/vessels_shelf.png

diff --git a/mods/vessels/init.lua b/mods/vessels/init.lua
index 6ca8771..d5bef81 100644
--- a/mods/vessels/init.lua
+++ b/mods/vessels/init.lua
@@ -1,6 +1,87 @@
 -- Minetest 0.4 mod: vessels
 -- See README.txt for licensing and other information.
 
+local vessels_shelf_formspec =
+	"size[8,7;]"..
+	default.gui_bg..
+	default.gui_bg_img..
+	default.gui_slots..
+	"list[context;vessels;0,0.3;8,2;]"..
+	"list[current_player;main;0,2.85;8,1;]"..
+	"list[current_player;main;0,4.08;8,3;8]"..
+	default.get_hotbar_bg(0,2.85)
+
+minetest.register_node("vessels:shelf", {
+	description = "Vessels shelf",
+	tiles = {"default_wood.png", "default_wood.png", "default_wood.png^vessels_shelf.png"},
+	is_ground_content = false,
+	groups = {choppy=3,oddly_breakable_by_hand=2,flammable=3},
+	sounds = default.node_sound_wood_defaults(),
+
+	on_construct = function(pos)
+		local meta = minetest.get_meta(pos)
+		meta:set_string("formspec", vessels_shelf_formspec)
+		local inv = meta:get_inventory()
+		inv:set_size("vessels", 8*2)
+	end,
+	can_dig = function(pos,player)
+		local meta = minetest.get_meta(pos);
+		local inv = meta:get_inventory()
+		return inv:is_empty("vessels")
+	end,
+
+	allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+		local meta = minetest.get_meta(pos)
+		local inv = meta:get_inventory()
+		local to_stack = inv:get_stack(listname, index)
+		if listname == "vessels" then
+			if minetest.get_item_group(stack:get_name(), "vessel") ~= 0
+					and to_stack:is_empty() then
+				return 1
+			else
+				return 0
+			end
+		end
+	end,
+
+	allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+		local meta = minetest.get_meta(pos)
+		local inv = meta:get_inventory()
+		local stack = inv:get_stack(from_list, from_index)
+		local to_stack = inv:get_stack(to_list, to_index)
+		if to_list == "vessels" then
+			if minetest.get_item_group(stack:get_name(), "vessel") ~= 0 
+					and to_stack:is_empty() then
+				return 1
+			else
+				return 0
+			end
+		end
+	end,
+
+	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 vessels shelf 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 vessels shelf 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 vessels shelf at "..minetest.pos_to_string(pos))
+	end,
+})
+
+minetest.register_craft({
+	output = 'vessels:shelf',
+	recipe = {
+		{'group:wood', 'group:wood', 'group:wood'},
+		{'group:vessel', 'group:vessel', 'group:vessel'},
+		{'group:wood', 'group:wood', 'group:wood'},
+	}
+})
+
 minetest.register_node("vessels:glass_bottle", {
 	description = "Glass Bottle (empty)",
 	drawtype = "plantlike",
diff --git a/mods/vessels/textures/vessels_shelf.png b/mods/vessels/textures/vessels_shelf.png
new file mode 100644
index 0000000000000000000000000000000000000000..87c69b28954009b8d719d477168a53fd91cde343
GIT binary patch
literal 354
zcmV-o0iFJdP)<h;3K|Lk000e1NJLTq000mG000mO0{{R3C@l|D0001ZP)t-s6%GlZ
zp}lijG{nT#SVJTi4+s$p25nR?UPve#5)6rIJYrsGQ$HhRO({ez9v&17udl{|c6oJa
zZ+&4lZd5A@2Lqdyq?3%3g?fBiSY(A~I*)>advkbhYH?&!Om$f;UqURgvB+><RYgER
zJ}4Qmug6+VNG%-_;rh)D0001`Nkl<Z7}HJ8(Gr3n6h+Z<A-I;HDNt&rmRA4&hk;Bp
z?T7We;e_zRDK&@`i~?|sWeq$uon_f0Yaw(9q|3Tiq@oP3a31Besa{?31Opl`SDL6x
zwg&F_ktEx$%6i!1@Snvz#DjuGjy()wTK_b#xR-H3XEmb;p%0`~U8>{^q3-MBCadP1
z+#F25()H5Nw7VTJV{GHXa@$=T1hXynEHexD1+yRvcurvH-T(jq07*qoM6N<$f|F^B
AV*mgE

literal 0
HcmV?d00001