Drop only 1 item if sneak is pressed
This commit is contained in:
parent
3c1e1a20da
commit
3c26abba0e
@ -6,6 +6,7 @@ local abs, atan2, cos, floor, max, sin, random =
|
|||||||
math.abs, math.atan2, math.cos, math.floor, math.max, math.sin, math.random
|
math.abs, math.atan2, math.cos, math.floor, math.max, math.sin, math.random
|
||||||
local vadd, vnew, vmultiply, vnormalize, vsubtract =
|
local vadd, vnew, vmultiply, vnormalize, vsubtract =
|
||||||
vector.add, vector.new, vector.multiply, vector.normalize, vector.subtract
|
vector.add, vector.new, vector.multiply, vector.normalize, vector.subtract
|
||||||
|
local tcopy = table.copy
|
||||||
|
|
||||||
local creative_mode = core.settings:get_bool("creative_mode")
|
local creative_mode = core.settings:get_bool("creative_mode")
|
||||||
local node_drop = core.settings:get_bool("node_drop")
|
local node_drop = core.settings:get_bool("node_drop")
|
||||||
@ -529,14 +530,15 @@ end
|
|||||||
|
|
||||||
function core.item_drop(itemstack, dropper, pos)
|
function core.item_drop(itemstack, dropper, pos)
|
||||||
local dropper_is_player = dropper and dropper:is_player()
|
local dropper_is_player = dropper and dropper:is_player()
|
||||||
local p = table.copy(pos)
|
local p = tcopy(pos)
|
||||||
local cnt = itemstack:get_count()
|
|
||||||
if not core.is_valid_pos(p) then
|
if not core.is_valid_pos(p) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if dropper_is_player then
|
if dropper_is_player then
|
||||||
p.y = p.y + 1.2
|
p.y = p.y + 1.2
|
||||||
end
|
end
|
||||||
|
local sneak = dropper_is_player and dropper:get_player_control().sneak
|
||||||
|
local cnt = sneak and 1 or itemstack:get_count()
|
||||||
local item = itemstack:take_item(cnt)
|
local item = itemstack:take_item(cnt)
|
||||||
local obj = core.add_item(p, item)
|
local obj = core.add_item(p, item)
|
||||||
if obj then
|
if obj then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user