1
0

Some updates for enchanting

This commit is contained in:
daniel0916 2014-01-24 20:01:21 +01:00
parent 0c2b307eab
commit bfac00f280
5 changed files with 29 additions and 17 deletions

View File

@ -120,6 +120,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
cPlayer::~cPlayer(void)
{
cRoot::Get()->GetPluginManager()->CallHookPlayerDestroying(*this);
LOGD("Deleting cPlayer \"%s\" at %p, ID %d", m_PlayerName.c_str(), this, GetUniqueID());
// Notify the server that the player is being destroyed
@ -134,6 +136,8 @@ cPlayer::~cPlayer(void)
delete m_InventoryWindow;
LOGD("Player %p deleted", this);
cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this);
}

View File

@ -1143,7 +1143,7 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
case 0x0e: HandlePacketWindowClick (a_ByteBuffer); return true;
case 0x0f: // Confirm transaction - not used in MCS
case 0x10: HandlePacketCreativeInventoryAction(a_ByteBuffer); return true;
case 0x11: HandlePacketEnchanting (a_ByteBuffer); return true;
case 0x11: HandlePacketEnchanting (a_ByteBuffer); return true;
case 0x12: HandlePacketUpdateSign (a_ByteBuffer); return true;
case 0x13: HandlePacketPlayerAbilities (a_ByteBuffer); return true;
case 0x14: HandlePacketTabComplete (a_ByteBuffer); return true;
@ -1551,11 +1551,19 @@ void cProtocol172::HandlePacketEnchanting(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, WindowID);
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Enchantment);
//TODO: EnchantItem (getWindow, getItem, Enchant)
LOGWARN("Enchantment Packet received!");
//Get Item from Window Slot
cItem EnchantItem = *m_Client->GetPlayer()->GetWindow()->GetSlot(*m_Client->GetPlayer(), 0);
//Enchant item with Sharpness 5
EnchantItem.m_Enchantments.SetLevel(cEnchantments::enchSharpness, 5);
LOG("Enchantment Paket empfangen!");
//Set Enchanted Item to Window Slot
m_Client->GetPlayer()->GetWindow()->SetSlot(*m_Client->GetPlayer(), 0, EnchantItem);
LOGWARN("Item enchanted!");
}

View File

@ -258,7 +258,7 @@ protected:
void HandlePacketTabComplete (cByteBuffer & a_ByteBuffer);
void HandlePacketUpdateSign (cByteBuffer & a_ByteBuffer);
void HandlePacketUseEntity (cByteBuffer & a_ByteBuffer);
void HandlePacketEnchanting (cByteBuffer & a_ByteBuffer);
void HandlePacketEnchanting (cByteBuffer & a_ByteBuffer);
void HandlePacketWindowClick (cByteBuffer & a_ByteBuffer);
void HandlePacketWindowClose (cByteBuffer & a_ByteBuffer);

View File

@ -576,7 +576,7 @@ cSlotAreaTemporary(a_NumSlots, a_ParentWindow)
void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
{
LOG("Clicked");
LOGWARN("Clicked");
// Check if Slot is in the Enchantment Table
if (a_SlotNum == 0)
{
@ -610,28 +610,28 @@ void cSlotAreaEnchanting::OnPlayerRemoved(cPlayer & a_Player)
void cSlotAreaEnchanting::ClickedResult(cPlayer & a_Player)
{
LOG("Click!");
LOGWARN("Click!");
if (a_Player.GetDraggingItem().IsEmpty())
{
LOG("EMPTY");
this->m_ParentWindow.SetProperty(0, NULL);
this->m_ParentWindow.SetProperty(1, NULL);
this->m_ParentWindow.SetProperty(2, NULL);
LOGWARN("EMPTY");
this->m_ParentWindow.SetProperty(0, 0);
this->m_ParentWindow.SetProperty(1, 0);
this->m_ParentWindow.SetProperty(2, 0);
}
else if (a_Player.GetDraggingItem().IsEnchantable)
{
LOG("Enchantable");
LOGWARN("Enchantable");
this->m_ParentWindow.SetProperty(0, 30);
this->m_ParentWindow.SetProperty(1, 20);
this->m_ParentWindow.SetProperty(2, 10);
}
else
{
LOG("Not Enchantable");
this->m_ParentWindow.SetProperty(0, NULL);
this->m_ParentWindow.SetProperty(1, NULL);
this->m_ParentWindow.SetProperty(2, NULL);
LOGWARN("Not Enchantable");
this->m_ParentWindow.SetProperty(0, 0);
this->m_ParentWindow.SetProperty(1, 0);
this->m_ParentWindow.SetProperty(2, 0);
}
}
@ -641,7 +641,7 @@ void cSlotAreaEnchanting::ClickedResult(cPlayer & a_Player)
void cSlotAreaEnchanting::ShiftClickedResult(cPlayer & a_Player)
{
LOG("Shift Click!");
LOGWARN("Shift Click!");
}

View File

@ -785,7 +785,7 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
// cEnchantingWindow:
cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
cWindow(wtEnchantment, "Enchantment Table")
cWindow(wtEnchantment, "Enchant")
{
m_SlotAreas.push_back(new cSlotAreaEnchanting(1, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));