From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.World/MapItemSavedData.h | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Minecraft.World/MapItemSavedData.h (limited to 'Minecraft.World/MapItemSavedData.h') diff --git a/Minecraft.World/MapItemSavedData.h b/Minecraft.World/MapItemSavedData.h new file mode 100644 index 00000000..fcbe5e30 --- /dev/null +++ b/Minecraft.World/MapItemSavedData.h @@ -0,0 +1,89 @@ +#pragma once + +#include "Player.h" +#include "SavedData.h" + +class MapItemSavedData : public SavedData +{ +public: + static const int MAP_SIZE = 64; + static const int MAX_SCALE = 4; + +#ifdef _LARGE_WORLDS + static const int DEC_PACKET_BYTES = 8; +#else + static const int DEC_PACKET_BYTES = 7; +#endif + + class MapDecoration + { + public: + char img, x, y, rot; + int entityId; // 4J Added + bool visible; + + MapDecoration(char img, char x, char y, char rot, int entityId, bool visible); // 4J added entityId, visible param + }; + + class HoldingPlayer + { + public: + const shared_ptr player; + intArray rowsDirtyMin; + intArray rowsDirtyMax; + + private: + int tick; + int sendPosTick; + charArray lastSentDecorations; + + protected: + const MapItemSavedData *parent; + + public: + // 4J Stu - Had to add a reference to the MapItemSavedData object that created us as we try to access it's member variables + HoldingPlayer(shared_ptr player, const MapItemSavedData *parent); + ~HoldingPlayer(); + charArray nextUpdatePacket(shared_ptr itemInstance); + }; + +public: + int x, z; + char dimension; + byte scale; + byteArray colors; + int step; + vector > carriedBy; + +private: + typedef unordered_map , shared_ptr , PlayerKeyHash, PlayerKeyEq> playerHoldingPlayerMapType; + playerHoldingPlayerMapType carriedByPlayers; + +public: + vector decorations; + +private: + // 4J Stu added + unordered_map nonPlayerDecorations; + static const int END_PORTAL_DECORATION_KEY; + + +public: + MapItemSavedData(const wstring& id); + ~MapItemSavedData(); + + virtual void load(CompoundTag *tag); + virtual void save(CompoundTag *tag); + + void tickCarriedBy(shared_ptr player, shared_ptr item); + + charArray getUpdatePacket(shared_ptr itemInstance, Level *level, shared_ptr player); + + using SavedData::setDirty; + void setDirty(int x, int y0, int y1); + void handleComplexItemData(charArray &data); + + // 4J Stu Added + void mergeInMapData(shared_ptr dataToAdd); + void removeItemFrameDecoration(shared_ptr item); +}; -- cgit v1.2.3