Commit
- added enchanting table block handler and added it to the blockhandler - added enchanting window - drop item in the slot 0 when the player close the window - added enchanting packet (1.7 only) - some more...
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
#pragma once | ||
|
||
#include "BlockHandler.h" | ||
#include "../UI/Window.h" | ||
#include "../Entities/Player.h" | ||
|
||
|
||
|
||
|
||
|
||
class cBlockEnchantmentTableHandler : | ||
public cBlockHandler | ||
{ | ||
public: | ||
cBlockEnchantmentTableHandler(BLOCKTYPE a_BlockType) | ||
: cBlockHandler(a_BlockType) | ||
{ | ||
} | ||
|
||
|
||
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override | ||
{ | ||
cWindow * Window = new cEnchantingWindow(a_BlockX, a_BlockY, a_BlockZ); | ||
a_Player->OpenWindow(Window); | ||
} | ||
|
||
|
||
virtual bool IsUseable(void) override | ||
{ | ||
return true; | ||
} | ||
}; | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1143,6 +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; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
daniel0916
Author
Owner
|
||
case 0x12: HandlePacketUpdateSign (a_ByteBuffer); return true; | ||
case 0x13: HandlePacketPlayerAbilities (a_ByteBuffer); return true; | ||
case 0x14: HandlePacketTabComplete (a_ByteBuffer); return true; | ||
|
@@ -1545,6 +1546,22 @@ void cProtocol172::HandlePacketUseEntity(cByteBuffer & a_ByteBuffer) | |
|
||
|
||
|
||
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) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
|
||
|
||
LOG("Enchantment Paket empfangen!"); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
void cProtocol172::HandlePacketWindowClick(cByteBuffer & a_ByteBuffer) | ||
{ | ||
HANDLE_READ(a_ByteBuffer, ReadChar, char, WindowID); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,6 +258,7 @@ class cProtocol172 : | |
void HandlePacketTabComplete (cByteBuffer & a_ByteBuffer); | ||
void HandlePacketUpdateSign (cByteBuffer & a_ByteBuffer); | ||
void HandlePacketUseEntity (cByteBuffer & a_ByteBuffer); | ||
void HandlePacketEnchanting (cByteBuffer & a_ByteBuffer); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
madmaxoft
|
||
void HandlePacketWindowClick (cByteBuffer & a_ByteBuffer); | ||
void HandlePacketWindowClose (cByteBuffer & a_ByteBuffer); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -562,6 +562,92 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player) | |
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// cSlotAreaEnchanting: | ||
|
||
cSlotAreaEnchanting::cSlotAreaEnchanting(int a_NumSlots, cWindow & a_ParentWindow) : | ||
cSlotAreaTemporary(a_NumSlots, a_ParentWindow) | ||
{ | ||
} | ||
|
||
|
||
|
||
|
||
|
||
void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) | ||
{ | ||
LOG("Clicked"); | ||
// Check if Slot is in the Enchantment Table | ||
if (a_SlotNum == 0) | ||
{ | ||
if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) | ||
{ | ||
ShiftClickedResult(a_Player); | ||
} | ||
else | ||
{ | ||
ClickedResult(a_Player); | ||
} | ||
return; | ||
} | ||
super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
void cSlotAreaEnchanting::OnPlayerRemoved(cPlayer & a_Player) | ||
{ | ||
// Toss the item in the enchanting slot | ||
TossItems(a_Player, 0, 0); | ||
// Player not found - that is acceptable | ||
} | ||
|
||
|
||
|
||
|
||
|
||
void cSlotAreaEnchanting::ClickedResult(cPlayer & a_Player) | ||
{ | ||
LOG("Click!"); | ||
|
||
if (a_Player.GetDraggingItem().IsEmpty()) | ||
{ | ||
LOG("EMPTY"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
daniel0916
Author
Owner
|
||
this->m_ParentWindow.SetProperty(0, NULL); | ||
this->m_ParentWindow.SetProperty(1, NULL); | ||
this->m_ParentWindow.SetProperty(2, NULL); | ||
} | ||
else if (a_Player.GetDraggingItem().IsEnchantable) | ||
{ | ||
LOG("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); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
void cSlotAreaEnchanting::ShiftClickedResult(cPlayer & a_Player) | ||
{ | ||
LOG("Shift Click!"); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// cSlotAreaEnderChest: | ||
|
||
|
Are you using tabs instead of spaces inside lines?