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 "net.minecraft.world.level.levelgen.structure.h"
3#include "StructureFeatureIO.h"
4
5unordered_map<wstring, structureStartCreateFn> StructureFeatureIO::startIdClassMap;
6unordered_map<unsigned int, wstring> StructureFeatureIO::startClassIdMap;
7
8unordered_map<wstring, structurePieceCreateFn> StructureFeatureIO::pieceIdClassMap;
9unordered_map<unsigned int, wstring> StructureFeatureIO::pieceClassIdMap;
10
11void StructureFeatureIO::setStartId(EStructureStart clas, structureStartCreateFn createFn, const wstring &id)
12{
13 startIdClassMap[id] = createFn;
14 startClassIdMap[clas] = id;
15}
16
17void StructureFeatureIO::setPieceId(EStructurePiece clas, structurePieceCreateFn createFn, const wstring &id)
18{
19 pieceIdClassMap[id] = createFn;
20 pieceClassIdMap[clas] = id;
21}
22
23void StructureFeatureIO::staticCtor()
24{
25 setStartId(eStructureStart_MineShaftStart, MineShaftStart::Create, L"Mineshaft");
26 setStartId(eStructureStart_VillageStart, VillageFeature::VillageStart::Create, L"Village");
27 setStartId(eStructureStart_NetherBridgeStart, NetherBridgeFeature::NetherBridgeStart::Create, L"Fortress");
28 setStartId(eStructureStart_StrongholdStart, StrongholdFeature::StrongholdStart::Create, L"Stronghold");
29 setStartId(eStructureStart_ScatteredFeatureStart, RandomScatteredLargeFeature::ScatteredFeatureStart::Create, L"Temple");
30
31 MineShaftPieces::loadStatic();
32 VillagePieces::loadStatic();
33 NetherBridgePieces::loadStatic();
34 StrongholdPieces::loadStatic();
35 ScatteredFeaturePieces::loadStatic();
36}
37
38wstring StructureFeatureIO::getEncodeId(StructureStart *start)
39{
40 AUTO_VAR(it, startClassIdMap.find( start->GetType() ) );
41 if(it != startClassIdMap.end())
42 {
43 return it->second;
44 }
45 else
46 {
47 return L"";
48 }
49}
50
51wstring StructureFeatureIO::getEncodeId(StructurePiece *piece)
52{
53 AUTO_VAR(it, pieceClassIdMap.find( piece->GetType() ) );
54 if(it != pieceClassIdMap.end())
55 {
56 return it->second;
57 }
58 else
59 {
60 return L"";
61 }
62}
63
64StructureStart *StructureFeatureIO::loadStaticStart(CompoundTag *tag, Level *level)
65{
66 StructureStart *start = NULL;
67
68 AUTO_VAR(it, startIdClassMap.find( tag->getString(L"id") ) );
69 if(it != startIdClassMap.end())
70 {
71 start = (it->second)();
72 }
73
74 if (start != NULL)
75 {
76 start->load(level, tag);
77 }
78 else
79 {
80 app.DebugPrintf( "Skipping Structure with id %ls", tag->getString(L"id").c_str() );
81 }
82 return start;
83}
84
85StructurePiece *StructureFeatureIO::loadStaticPiece(CompoundTag *tag, Level *level)
86{
87 StructurePiece *piece = NULL;
88
89 AUTO_VAR(it, pieceIdClassMap.find( tag->getString(L"id") ) );
90 if(it != pieceIdClassMap.end())
91 {
92 piece = (it->second)();
93 }
94
95 if (piece != NULL)
96 {
97 piece->load(level, tag);
98 }
99 else
100 {
101 app.DebugPrintf( "Skipping Piece with id %ls", tag->getString(L"id").c_str() );
102 }
103 return piece;
104}