A bucket will be removed from the wielded itemstack, rather than from any slot in the "main" inventory list.
This is consistent with how the mobs API handles other things like removing the item used to feed animals
It solves the problem of buckets being duplicated in the feedlot mod's milker (https://forum.minetest.net/viewtopic.php?f=9&t=18811).
(I'm not sure whether the empty bucket should still be removed in creative mode, but the buckets mod acts the same way)
added with changes :) thanks