the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "CompleteAllRuleDefinition.h"
3#include "ConsoleGameRules.h"
4#include "..\..\..\Minecraft.World\StringHelpers.h"
5#include "..\..\..\Minecraft.World\Connection.h"
6#include "..\..\..\Minecraft.World\net.minecraft.network.packet.h"
7
8void CompleteAllRuleDefinition::getChildren(vector<GameRuleDefinition *> *children)
9{
10 CompoundGameRuleDefinition::getChildren(children);
11}
12
13bool CompleteAllRuleDefinition::onUseTile(GameRule *rule, int tileId, int x, int y, int z)
14{
15 bool statusChanged = CompoundGameRuleDefinition::onUseTile(rule,tileId,x,y,z);
16 if(statusChanged) updateStatus(rule);
17 return statusChanged;
18}
19
20bool CompleteAllRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item)
21{
22 bool statusChanged = CompoundGameRuleDefinition::onCollectItem(rule,item);
23 if(statusChanged) updateStatus(rule);
24 return statusChanged;
25}
26
27void CompleteAllRuleDefinition::updateStatus(GameRule *rule)
28{
29 int goal = 0;
30 int progress = 0;
31 for(AUTO_VAR(it, rule->m_parameters.begin()); it != rule->m_parameters.end(); ++it)
32 {
33 if(it->second.isPointer)
34 {
35 goal += it->second.gr->getGameRuleDefinition()->getGoal();
36 progress += it->second.gr->getGameRuleDefinition()->getProgress(it->second.gr);
37 }
38 }
39 if(rule->getConnection() != NULL)
40 {
41 PacketData data;
42 data.goal = goal;
43 data.progress = progress;
44
45 int icon = -1;
46 int auxValue = 0;
47
48 if(m_lastRuleStatusChanged != NULL)
49 {
50 icon = m_lastRuleStatusChanged->getIcon();
51 auxValue = m_lastRuleStatusChanged->getAuxValue();
52 m_lastRuleStatusChanged = NULL;
53 }
54 rule->getConnection()->send( shared_ptr<UpdateGameRuleProgressPacket>( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId,icon, auxValue, 0,&data,sizeof(PacketData))));
55 }
56 app.DebugPrintf("Updated CompleteAllRule - Completed %d of %d\n", progress, goal);
57}
58
59wstring CompleteAllRuleDefinition::generateDescriptionString(const wstring &description, void *data, int dataLength)
60{
61 PacketData *values = (PacketData *)data;
62 wstring newDesc = description;
63 newDesc = replaceAll(newDesc,L"{*progress*}",_toString<int>(values->progress));
64 newDesc = replaceAll(newDesc,L"{*goal*}",_toString<int>(values->goal));
65 return newDesc;
66}