the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 90 lines 2.9 kB view raw
1#pragma once 2using namespace std; 3 4#define XBOX_SCHEMATIC_ORIGINAL_VERSION 1 5#define XBOX_SCHEMATIC_CURRENT_VERSION 2 6 7#include "..\..\..\Minecraft.World\ArrayWithLength.h" 8 9class Level; 10class DataOutputStream; 11class DataInputStream; 12class TileEntity; 13class LevelChunk; 14class AABB; 15class Vec3; 16 17class ConsoleSchematicFile 18{ 19public: 20 enum ESchematicRotation 21 { 22 eSchematicRot_0, 23 eSchematicRot_90, 24 eSchematicRot_180, 25 eSchematicRot_270 26 }; 27private: 28 int m_refCount; 29 30public: 31 void incrementRefCount() { ++m_refCount; } 32 void decrementRefCount() { --m_refCount; } 33 bool shouldDelete() { return m_refCount <= 0; } 34 35 typedef struct _XboxSchematicInitParam 36 { 37 wchar_t name[64]; 38 int startX; 39 int startY; 40 int startZ; 41 int endX; 42 int endY; 43 int endZ; 44 bool bSaveMobs; 45 46 Compression::ECompressionTypes compressionType; 47 48 _XboxSchematicInitParam() 49 { 50 ZeroMemory(name,64*(sizeof(wchar_t))); 51 startX = startY = startZ = endX = endY = endZ = 0; 52 bSaveMobs = false; 53 compressionType = Compression::eCompressionType_None; 54 } 55 } XboxSchematicInitParam; 56private: 57 int m_xSize, m_ySize, m_zSize; 58 vector<shared_ptr<TileEntity> > m_tileEntities; 59 vector< pair<Vec3 *, CompoundTag *> > m_entities; 60 61public: 62 byteArray m_data; 63 64public: 65 ConsoleSchematicFile(); 66 ~ConsoleSchematicFile(); 67 68 int getXSize() { return m_xSize; } 69 int getYSize() { return m_ySize; } 70 int getZSize() { return m_zSize; } 71 72 void save(DataOutputStream *dos); 73 void load(DataInputStream *dis); 74 75 __int64 applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot); 76 __int64 applyLighting(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot); 77 void applyTileEntities(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot); 78 79 static void generateSchematicFile(DataOutputStream *dos, Level *level, int xStart, int yStart, int zStart, int xEnd, int yEnd, int zEnd, bool bSaveMobs, Compression::ECompressionTypes); 80 static void setBlocksAndData(LevelChunk *chunk, byteArray blockData, byteArray dataData, byteArray data, int x0, int y0, int z0, int x1, int y1, int z1, int &blocksP, int &dataP, int &blockLightP, int &skyLightP); 81private: 82 void save_tags(DataOutputStream *dos); 83 void load_tags(DataInputStream *dis); 84 85 static void getBlocksAndData(LevelChunk *chunk, byteArray *data, int x0, int y0, int z0, int x1, int y1, int z1, int &blocksP, int &dataP, int &blockLightP, int &skyLightP); 86 static vector<shared_ptr<TileEntity> > *getTileEntitiesInRegion(LevelChunk *chunk, int x0, int y0, int z0, int x1, int y1, int z1); 87 88 void chunkCoordToSchematicCoord(AABB *destinationBox, int chunkX, int chunkZ, ESchematicRotation rot, int &schematicX, int &schematicZ); 89 void schematicCoordToChunkCoord(AABB *destinationBox, double schematicX, double schematicZ, ESchematicRotation rot, double &chunkX, double &chunkZ); 90};