the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 101 lines 2.4 kB view raw
1#pragma once 2 3#include "Player.h" 4#include "SavedData.h" 5 6class MapItemSavedData : public SavedData 7{ 8private: 9 static const int HEADER_COLOURS = 0; 10 static const int HEADER_DECORATIONS = 1; 11 static const int HEADER_METADATA = 2; 12 13public: 14 static const int MAP_SIZE = 64; 15 static const int MAX_SCALE = 4; 16 17#ifdef _LARGE_WORLDS 18 static const int DEC_PACKET_BYTES = 8; 19#else 20 static const int DEC_PACKET_BYTES = 7; 21#endif 22 23 class MapDecoration 24 { 25 public: 26 char img, x, y, rot; 27 int entityId; // 4J Added 28 bool visible; 29 30 MapDecoration(char img, char x, char y, char rot, int entityId, bool visible); // 4J added entityId, visible param 31 }; 32 33 class HoldingPlayer 34 { 35 public: 36 const shared_ptr<Player> player; 37 intArray rowsDirtyMin; 38 intArray rowsDirtyMax; 39 40 private: 41 int tick; 42 int sendPosTick; 43 charArray lastSentDecorations; 44 45 public: 46 int step; 47 48 private: 49 bool hasSentInitial; 50 51 protected: 52 const MapItemSavedData *parent; 53 54 public: 55 // 4J Stu - Had to add a reference to the MapItemSavedData object that created us as we try to access it's member variables 56 HoldingPlayer(shared_ptr<Player> player, const MapItemSavedData *parent); 57 ~HoldingPlayer(); 58 charArray nextUpdatePacket(shared_ptr<ItemInstance> itemInstance); 59 }; 60 61public: 62 int x, z; 63 char dimension; 64 byte scale; 65 byteArray colors; 66 vector<shared_ptr<HoldingPlayer> > carriedBy; 67 68private: 69 70 typedef unordered_map<shared_ptr<Player> , shared_ptr<HoldingPlayer> , PlayerKeyHash, PlayerKeyEq> playerHoldingPlayerMapType; 71 playerHoldingPlayerMapType carriedByPlayers; 72 73public: 74 vector<MapDecoration *> decorations; 75 76private: 77 // 4J Stu added 78 unordered_map<int, MapDecoration *> nonPlayerDecorations; 79 static const int END_PORTAL_DECORATION_KEY; 80 81 82public: 83 MapItemSavedData(const wstring& id); 84 ~MapItemSavedData(); 85 86 virtual void load(CompoundTag *tag); 87 virtual void save(CompoundTag *tag); 88 89 void tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemInstance> item); 90 91 charArray getUpdatePacket(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player); 92 93 using SavedData::setDirty; 94 void setDirty(int x, int y0, int y1); 95 void handleComplexItemData(charArray &data); 96 shared_ptr<HoldingPlayer> getHoldingPlayer(shared_ptr<Player> player); 97 98 // 4J Stu Added 99 void mergeInMapData(shared_ptr<MapItemSavedData> dataToAdd); 100 void removeItemFrameDecoration(shared_ptr<ItemInstance> item); 101};