Skip to content

Commit 9675d9e

Browse files
Lord89JamesBlockMen
authored andcommittedJun 10, 2014
New feature: drop a item instead a stack while...
sneaking
1 parent c6a9eae commit 9675d9e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed
 

‎builtin/game/item.lua

+11-6
Original file line numberDiff line numberDiff line change
@@ -335,20 +335,26 @@ function core.item_place(itemstack, placer, pointed_thing, param2)
335335
end
336336

337337
function core.item_drop(itemstack, dropper, pos)
338-
if dropper.get_player_name then
338+
if dropper.is_player then
339339
local v = dropper:get_look_dir()
340-
local p = {x=pos.x+v.x, y=pos.y+1.5+v.y, z=pos.z+v.z}
341-
local obj = core.add_item(p, itemstack)
340+
local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
341+
local cs = itemstack:get_count()
342+
if dropper:get_player_control().sneak then
343+
cs = 1
344+
end
345+
local item = itemstack:take_item(cs)
346+
local obj = core.add_item(p, item)
342347
if obj then
343348
v.x = v.x*2
344-
v.y = v.y*2 + 1
349+
v.y = v.y*2 + 2
345350
v.z = v.z*2
346351
obj:setvelocity(v)
347352
end
353+
348354
else
349355
core.add_item(pos, itemstack)
350356
end
351-
return ItemStack("")
357+
return itemstack
352358
end
353359

354360
function core.item_eat(hp_change, replace_with_item)
@@ -592,4 +598,3 @@ core.noneitemdef_default = { -- This is used for the hand and unknown items
592598
on_drop = nil,
593599
on_use = nil,
594600
}
595-

0 commit comments

Comments
 (0)
Please sign in to comment.