mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 18:13:46 +01:00
New feature: drop a item instead a stack while...
sneaking
This commit is contained in:
parent
c6a9eae3ae
commit
9675d9e9cb
@ -335,20 +335,26 @@ function core.item_place(itemstack, placer, pointed_thing, param2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function core.item_drop(itemstack, dropper, pos)
|
function core.item_drop(itemstack, dropper, pos)
|
||||||
if dropper.get_player_name then
|
if dropper.is_player then
|
||||||
local v = dropper:get_look_dir()
|
local v = dropper:get_look_dir()
|
||||||
local p = {x=pos.x+v.x, y=pos.y+1.5+v.y, z=pos.z+v.z}
|
local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
|
||||||
local obj = core.add_item(p, itemstack)
|
local cs = itemstack:get_count()
|
||||||
|
if dropper:get_player_control().sneak then
|
||||||
|
cs = 1
|
||||||
|
end
|
||||||
|
local item = itemstack:take_item(cs)
|
||||||
|
local obj = core.add_item(p, item)
|
||||||
if obj then
|
if obj then
|
||||||
v.x = v.x*2
|
v.x = v.x*2
|
||||||
v.y = v.y*2 + 1
|
v.y = v.y*2 + 2
|
||||||
v.z = v.z*2
|
v.z = v.z*2
|
||||||
obj:setvelocity(v)
|
obj:setvelocity(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
core.add_item(pos, itemstack)
|
core.add_item(pos, itemstack)
|
||||||
end
|
end
|
||||||
return ItemStack("")
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
function core.item_eat(hp_change, replace_with_item)
|
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
|
|||||||
on_drop = nil,
|
on_drop = nil,
|
||||||
on_use = nil,
|
on_use = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user