the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 118 lines 3.9 kB view raw
1#include "stdafx.h" 2#include "..\..\..\Minecraft.World\StringHelpers.h" 3#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" 4#include "..\..\..\Minecraft.World\net.minecraft.world.item.h" 5#include "..\..\..\Minecraft.World\net.minecraft.network.packet.h" 6#include "..\..\Minecraft.h" 7#include "..\..\MultiPlayerLocalPlayer.h" 8#include "..\..\ClientConnection.h" 9#include "..\..\Common\GameRules\ConsoleGameRules.h" 10#include "XUI_DebugItemEditor.h" 11 12#ifdef _DEBUG_MENUS_ENABLED 13HRESULT CScene_DebugItemEditor::OnInit( XUIMessageInit *pInitData, BOOL &bHandled ) 14{ 15 MapChildControls(); 16 17 ItemEditorInput *initData = (ItemEditorInput *)pInitData->pvInitData; 18 m_iPad = initData->iPad; 19 m_slot = initData->slot; 20 m_menu = initData->menu; 21 if(m_slot != NULL) m_item = m_slot->getItem(); 22 23 if(m_item!=NULL) 24 { 25 m_icon->SetIcon(m_iPad, m_item->id,m_item->getAuxValue(),m_item->count,10,31,false,m_item->isFoil()); 26 m_itemName.SetText( app.GetString( Item::items[m_item->id]->getDescriptionId(m_item) ) ); 27 28 m_itemId .SetText( _toString<int>(m_item->id).c_str() ); 29 m_itemAuxValue .SetText( _toString<int>(m_item->getAuxValue()).c_str() ); 30 m_itemCount .SetText( _toString<int>(m_item->count).c_str() ); 31 m_item4JData .SetText( _toString<int>(m_item->get4JData()).c_str() ); 32 } 33 34 m_itemId .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric); 35 m_itemAuxValue .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric); 36 m_itemCount .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric); 37 m_item4JData .SetKeyboardType(C_4JInput::EKeyboardMode_Numeric); 38 39 m_generatedXml.SetText( CollectItemRuleDefinition::generateXml(m_item).c_str() ); 40 41 delete initData; 42 43 return S_OK; 44} 45 46HRESULT CScene_DebugItemEditor::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) 47{ 48 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode); 49 50 switch(pInputData->dwKeyCode) 51 { 52 53 case VK_PAD_B: 54 case VK_PAD_START: 55 case VK_PAD_BACK: 56 // We need to send a packet to the server to update it's representation of this item 57 if(m_slot != NULL && m_menu != NULL) 58 { 59 m_slot->set(m_item); 60 61 Minecraft *pMinecraft = Minecraft::GetInstance(); 62 shared_ptr<MultiplayerLocalPlayer> player = pMinecraft->localplayers[m_iPad]; 63 if(player != NULL && player->connection) player->connection->send( shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(m_menu->containerId, m_slot->index, m_item) ) ); 64 } 65 // kill the crafting xui 66 app.NavigateBack(m_iPad); 67 68 rfHandled = TRUE; 69 70 break; 71 72 } 73 74 return S_OK; 75} 76 77HRESULT CScene_DebugItemEditor::OnNotifyValueChanged( HXUIOBJ hObjSource, XUINotifyValueChanged *pNotifyValueChangedData, BOOL &bHandled) 78{ 79 if(m_item == NULL) m_item = shared_ptr<ItemInstance>( new ItemInstance(0,1,0) ); 80 if(hObjSource == m_itemId) 81 { 82 int id = 0; 83 wstring value = m_itemId.GetText(); 84 if(!value.empty()) id = _fromString<int>( value ); 85 86 // TODO Proper validation of the valid item ids 87 if(id > 0 && Item::items[id] != NULL) m_item->id = id; 88 } 89 else if(hObjSource == m_itemAuxValue) 90 { 91 int auxVal = 0; 92 wstring value = m_itemAuxValue.GetText(); 93 if(!value.empty()) auxVal = _fromString<int>( value ); 94 if(auxVal >= 0) m_item->setAuxValue( auxVal ); 95 } 96 else if(hObjSource == m_itemCount) 97 { 98 int count = 0; 99 wstring value = m_itemCount.GetText(); 100 if(!value.empty()) count = _fromString<int>( value ); 101 if(count > 0 && count <= Item::items[m_item->id]->getMaxStackSize()) m_item->count = count; 102 } 103 else if(hObjSource == m_item4JData) 104 { 105 int data = 0; 106 wstring value = m_item4JData.GetText(); 107 if(!value.empty()) data = _fromString<int>( value ); 108 m_item->set4JData(data); 109 } 110 111 m_icon->SetIcon(m_iPad, m_item->id,m_item->getAuxValue(),m_item->count,10,31,false,m_item->isFoil()); 112 113 m_itemName.SetText( app.GetString( Item::items[m_item->id]->getDescriptionId(m_item) ) ); 114 115 m_generatedXml.SetText( CollectItemRuleDefinition::generateXml(m_item).c_str() ); 116 return S_OK; 117} 118#endif