the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2
3#include "..\..\..\Minecraft.World\Slot.h"
4#include "..\..\..\Minecraft.World\ItemInstance.h"
5
6#include "SlotItemControlBase.h"
7#include "SlotProgressControl.h"
8
9int SlotProgressControl::GetValue()
10{
11 int value = 0;
12
13 HXUIOBJ hVisual, hParent;
14 this->GetParent( &hVisual );
15 XuiElementGetParent( hVisual, &hParent);
16
17 void* pvUserData;
18 XuiElementGetUserData( hParent, &pvUserData );
19
20 if( pvUserData != NULL )
21 {
22 SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
23
24 shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>();
25
26 if( pUserDataContainer->slot != NULL )
27 {
28 item = pUserDataContainer->slot->getItem();
29 }
30 else
31 {
32 item = pUserDataContainer->item;
33 }
34
35 if( item != NULL )
36 {
37 // TODO Should use getDamage instead even though it returns the same value
38 if( item->isDamaged() )
39 value = item->getDamageValue();
40 else
41 value = 0;
42 }
43 }
44 else
45 {
46 LPCWSTR name;
47 XuiElementGetId( hParent, &name );
48
49 OutputDebugStringW( name );
50 OutputDebugString( "\n" );
51 }
52
53 return value;
54}
55
56void SlotProgressControl::GetRange(int *pnRangeMin, int *pnRangeMax)
57{
58 *pnRangeMin = 0;
59 *pnRangeMax = 0;
60
61 HXUIOBJ hVisual, hParent;
62 this->GetParent( &hVisual );
63 XuiElementGetParent( hVisual, &hParent);
64
65 void* pvUserData;
66 XuiElementGetUserData( hParent, &pvUserData );
67
68 if( pvUserData != NULL )
69 {
70 SlotControlUserDataContainer* pUserDataContainer = (SlotControlUserDataContainer*)pvUserData;
71
72 shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>();
73
74 if( pUserDataContainer->slot != NULL )
75 {
76 item = pUserDataContainer->slot->getItem();
77 }
78 else
79 {
80 item = pUserDataContainer->item;
81 }
82
83 if( item != NULL )
84 {
85 *pnRangeMax = item->getMaxDamage();
86 }
87 }
88}