mirror of
https://github.com/theFox6/microexpansion.git
synced 2024-11-29 10:23:56 +01:00
don't stack items with different metadata
This commit is contained in:
parent
a47336ae3e
commit
347cec5894
@ -4,8 +4,7 @@ local networks = me.networks
|
|||||||
local path = microexpansion.get_module_path("network")
|
local path = microexpansion.get_module_path("network")
|
||||||
|
|
||||||
local function split_stack_values(stack)
|
local function split_stack_values(stack)
|
||||||
local stack_name
|
local stack_name, stack_count, stack_meta
|
||||||
local stack_count
|
|
||||||
if type(stack) == "string" then
|
if type(stack) == "string" then
|
||||||
local split_string = stack:split(" ")
|
local split_string = stack:split(" ")
|
||||||
stack_name = split_string[1]
|
stack_name = split_string[1]
|
||||||
@ -17,19 +16,21 @@ local function split_stack_values(stack)
|
|||||||
else
|
else
|
||||||
stack_name = stack:get_name()
|
stack_name = stack:get_name()
|
||||||
stack_count = stack:get_count()
|
stack_count = stack:get_count()
|
||||||
|
stack_meta = stack:get_meta()
|
||||||
end
|
end
|
||||||
return stack_name, stack_count
|
return stack_name, stack_count, stack_meta
|
||||||
end
|
end
|
||||||
|
|
||||||
function me.insert_item(stack, inv, listname)
|
function me.insert_item(stack, inv, listname)
|
||||||
if me.settings.huge_stacks == false then
|
if me.settings.huge_stacks == false then
|
||||||
return inv:add_item(listname, stack)
|
return inv:add_item(listname, stack)
|
||||||
end
|
end
|
||||||
local stack_name,stack_count = split_stack_values(stack)
|
local stack_name,stack_count,stack_meta = split_stack_values(stack)
|
||||||
local found = false
|
local found = false
|
||||||
for i = 0, inv:get_size(listname) do
|
for i = 0, inv:get_size(listname) do
|
||||||
local inside = inv:get_stack(listname, i)
|
local inside = inv:get_stack(listname, i)
|
||||||
if inside:get_name() == stack_name then
|
if inside:get_name() == stack_name then
|
||||||
|
if inside:get_meta():equals(stack_meta) then
|
||||||
local total_count = inside:get_count() + stack_count
|
local total_count = inside:get_count() + stack_count
|
||||||
-- bigger item count is not possible we only have unsigned 16 bit
|
-- bigger item count is not possible we only have unsigned 16 bit
|
||||||
if total_count <= math.pow(2,16) then
|
if total_count <= math.pow(2,16) then
|
||||||
@ -43,6 +44,7 @@ function me.insert_item(stack, inv, listname)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if not found then
|
if not found then
|
||||||
return inv:add_item(listname, stack)
|
return inv:add_item(listname, stack)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user