From bcd7baec75d382a8bb2710d2d75e75f1b681a334 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mikita=20Wi=C5=9Bniewski?= <rudzik8@protonmail.com>
Date: Sat, 11 Jan 2025 21:08:42 +0700
Subject: [PATCH] Respect node's max stack count on pickblock

---
 mods/PLAYER/vl_pickblock/init.lua | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/mods/PLAYER/vl_pickblock/init.lua b/mods/PLAYER/vl_pickblock/init.lua
index ee2a8792e..aa0c37a0d 100644
--- a/mods/PLAYER/vl_pickblock/init.lua
+++ b/mods/PLAYER/vl_pickblock/init.lua
@@ -1,5 +1,13 @@
 vl_pickblock = {}
 
+local function get_stack_count(player, def)
+	local switch = player:get_meta():get_int("mcl_inventory:switch_stack")
+	if switch == 64 then
+		return def.stack_max or switch
+	end
+	return 1
+end
+
 -- The main Pickblock handler function.
 -- To be called in hand's `on_place`
 -- (assumes that pointed_thing.type == "node")
@@ -41,7 +49,7 @@ function vl_pickblock.pickblock(itemstack, placer, pointed_thing)
 	end
 
 	local rstack = ItemStack(rnode)
-	rstack:set_count(placer:get_meta():get_int("mcl_inventory:switch_stack"))
+	rstack:set_count(get_stack_count(placer, def))
 	return rstack
 end