From fb93388f06fe87ee75aaaf04cf6edcf01a26d981 Mon Sep 17 00:00:00 2001
From: SmallJoker <mk939@ymail.com>
Date: Thu, 19 Jul 2018 14:36:21 +0200
Subject: [PATCH] Replace deprecated invsize[] with size[]

---
 technic_chests/register.lua |   36 +++++++++---------------------------
 1 files changed, 9 insertions(+), 27 deletions(-)

diff --git a/technic_chests/register.lua b/technic_chests/register.lua
index b697bfd..61d49d3 100644
--- a/technic_chests/register.lua
+++ b/technic_chests/register.lua
@@ -90,8 +90,8 @@
 				"image_button[0,0.35;1,0.6",
 				"splitstacks",
 				{
-					{text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
-					{text="", texture="pipeworks_button_on.png",  addopts="false;false;pipeworks_button_interm.png"}
+					pipeworks.button_off,
+					pipeworks.button_on
 				}
 			)..allow_label
 
@@ -137,38 +137,20 @@
 			local m = st:get_metadata()
 			local k = string.format("%s %05d %s", n, w, m)
 			if not typecnt[k] then
-				typecnt[k] = {
-					name = n,
-					wear = w,
-					metadata = m,
-					stack_max = st:get_stack_max(),
-					count = 0,
-				}
+				typecnt[k] = {st}
 				table.insert(typekeys, k)
+			else
+				table.insert(typecnt[k], st)
 			end
-			typecnt[k].count = typecnt[k].count + st:get_count()
 		end
 	end
 	table.sort(typekeys)
-	local outlist = {}
+	inv:set_list("main", {})
 	for _, k in ipairs(typekeys) do
-		local tc = typecnt[k]
-		while tc.count > 0 do
-			local c = math.min(tc.count, tc.stack_max)
-			table.insert(outlist, ItemStack({
-				name = tc.name,
-				wear = tc.wear,
-				metadata = tc.metadata,
-				count = c,
-			}))
-			tc.count = tc.count - c
+		for _, item in ipairs(typecnt[k]) do
+			inv:add_item("main", item)
 		end
 	end
-	if #outlist > #inlist then return end
-	while #outlist < #inlist do
-		table.insert(outlist, ItemStack(nil))
-	end
-	inv:set_list("main", outlist)
 end
 
 local function get_receive_fields(name, data)
@@ -305,7 +287,7 @@
 		on_receive_fields = get_receive_fields(name, data),
 		on_metadata_inventory_move = self.on_inv_move,
 		on_metadata_inventory_put = self.on_inv_put,
-		on_metadata_inventory_take = self.on_inv_take,		
+		on_metadata_inventory_take = self.on_inv_take,
 		on_blast = function(pos)
 			local drops = {}
 			default.get_inventory_drops(pos, "main", drops)

--
Gitblit v1.8.0