forked from Mirrorlandia_minetest/minetest
Check item_drop amount clientside (#6242)
This commit is contained in:
parent
3cea7a349a
commit
ad9677a14f
@ -420,19 +420,16 @@ end
|
|||||||
|
|
||||||
function core.item_drop(itemstack, dropper, pos)
|
function core.item_drop(itemstack, dropper, pos)
|
||||||
if dropper and dropper:is_player() then
|
if dropper and dropper:is_player() then
|
||||||
local v = dropper:get_look_dir()
|
local dir = dropper:get_look_dir()
|
||||||
local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
|
local p = {x = pos.x, y = pos.y + 1.2, z = pos.z}
|
||||||
local cs = itemstack:get_count()
|
local cnt = itemstack:get_count()
|
||||||
if dropper:get_player_control().sneak then
|
local item = itemstack:take_item(cnt)
|
||||||
cs = 1
|
|
||||||
end
|
|
||||||
local item = itemstack:take_item(cs)
|
|
||||||
local obj = core.add_item(p, item)
|
local obj = core.add_item(p, item)
|
||||||
if obj then
|
if obj then
|
||||||
v.x = v.x*2
|
dir.x = dir.x * 2
|
||||||
v.y = v.y*2 + 2
|
dir.y = dir.y * 2 + 2
|
||||||
v.z = v.z*2
|
dir.z = dir.z * 2
|
||||||
obj:setvelocity(v)
|
obj:set_velocity(dir)
|
||||||
obj:get_luaentity().dropped_by = dropper:get_player_name()
|
obj:get_luaentity().dropped_by = dropper:get_player_name()
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
@ -1251,7 +1251,7 @@ protected:
|
|||||||
void processKeyInput();
|
void processKeyInput();
|
||||||
void processItemSelection(u16 *new_playeritem);
|
void processItemSelection(u16 *new_playeritem);
|
||||||
|
|
||||||
void dropSelectedItem();
|
void dropSelectedItem(bool single_item = false);
|
||||||
void openInventory();
|
void openInventory();
|
||||||
void openConsole(float scale, const wchar_t *line=NULL);
|
void openConsole(float scale, const wchar_t *line=NULL);
|
||||||
void toggleFreeMove();
|
void toggleFreeMove();
|
||||||
@ -2499,7 +2499,7 @@ void Game::processUserInput(f32 dtime)
|
|||||||
void Game::processKeyInput()
|
void Game::processKeyInput()
|
||||||
{
|
{
|
||||||
if (wasKeyDown(KeyType::DROP)) {
|
if (wasKeyDown(KeyType::DROP)) {
|
||||||
dropSelectedItem();
|
dropSelectedItem(isKeyDown(KeyType::SNEAK));
|
||||||
} else if (wasKeyDown(KeyType::AUTOFORWARD)) {
|
} else if (wasKeyDown(KeyType::AUTOFORWARD)) {
|
||||||
toggleAutoforward();
|
toggleAutoforward();
|
||||||
} else if (wasKeyDown(KeyType::INVENTORY)) {
|
} else if (wasKeyDown(KeyType::INVENTORY)) {
|
||||||
@ -2645,10 +2645,10 @@ void Game::processItemSelection(u16 *new_playeritem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Game::dropSelectedItem()
|
void Game::dropSelectedItem(bool single_item)
|
||||||
{
|
{
|
||||||
IDropAction *a = new IDropAction();
|
IDropAction *a = new IDropAction();
|
||||||
a->count = 0;
|
a->count = single_item ? 1 : 0;
|
||||||
a->from_inv.setCurrentPlayer();
|
a->from_inv.setCurrentPlayer();
|
||||||
a->from_list = "main";
|
a->from_list = "main";
|
||||||
a->from_i = client->getPlayerItem();
|
a->from_i = client->getPlayerItem();
|
||||||
|
Loading…
Reference in New Issue
Block a user