From 1cca9b13b3d320ff767cfc552413265b2ef6e0d6 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 6 Jun 2012 20:18:50 +0000 Subject: Item-dropping code rewritten and centralized - now there's only one place to modify if we want to split or merge same-item drops: cWorld:SpawnItemPickups(). Also, mined blocks can now drop more items, and they recognize if they're being mined by the correct tool. git-svn-id: http://mc-server.googlecode.com/svn/trunk@561 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cCraftingWindow.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'source/cCraftingWindow.cpp') diff --git a/source/cCraftingWindow.cpp b/source/cCraftingWindow.cpp index 94bc3cde8..8d499c514 100644 --- a/source/cCraftingWindow.cpp +++ b/source/cCraftingWindow.cpp @@ -10,6 +10,7 @@ #include "cInventory.h" #include "cPickup.h" #include "cRoot.h" +#include "cWorld.h" #include "packets/cPacket_WindowClick.h" #include "packets/cPacket_InventorySlot.h" @@ -116,23 +117,24 @@ void cCraftingWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_P -void cCraftingWindow::Close( cPlayer & a_Player ) +void cCraftingWindow::Close(cPlayer & a_Player) { // Start from slot 1, don't drop what's in the result slot + cItems Drops; for( int i = 1; i < GetNumSlots(); i++ ) { - cItem* Item = GetSlot( i ); - if( Item->m_ItemID > 0 && Item->m_ItemCount > 0 ) + cItem * Item = GetSlot(i); + if (!Item->IsEmpty()) { - float vX = 0, vY = 0, vZ = 0; - EulerToVector( -a_Player.GetRotation(), a_Player.GetPitch(), vZ, vX, vY ); - vY = -vY*2 + 1.f; - cPickup* Pickup = new cPickup( (int)(a_Player.GetPosX()*32), (int)(a_Player.GetPosY()*32) + (int)(1.6f*32), (int)(a_Player.GetPosZ()*32), *Item, vX*2, vY*2, vZ*2 ); - Pickup->Initialize( a_Player.GetWorld() ); + Drops.push_back(*Item); } Item->Empty(); } - cWindow::Close( a_Player ); + float vX = 0, vY = 0, vZ = 0; + EulerToVector( -a_Player.GetRotation(), a_Player.GetPitch(), vZ, vX, vY); + vY = -vY*2 + 1.f; + a_Player.GetWorld()->SpawnItemPickups(Drops, a_Player.GetPosX(), a_Player.GetPosY() + 1.6f, a_Player.GetPosZ(), vX * 2, vY * 2, vZ * 2); + cWindow::Close(a_Player); } -- cgit v1.2.3