2026-03-01 12:16:08 +08:00
|
|
|
#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:
|
2026-03-02 15:58:20 +07:00
|
|
|
const std::shared_ptr<Player> player;
|
2026-03-01 12:16:08 +08:00
|
|
|
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
|
2026-03-02 15:58:20 +07:00
|
|
|
HoldingPlayer(std::shared_ptr<Player> player, const MapItemSavedData *parent);
|
2026-03-01 12:16:08 +08:00
|
|
|
~HoldingPlayer();
|
2026-03-02 15:58:20 +07:00
|
|
|
charArray nextUpdatePacket(std::shared_ptr<ItemInstance> itemInstance);
|
2026-03-01 12:16:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
int x, z;
|
|
|
|
|
char dimension;
|
|
|
|
|
byte scale;
|
|
|
|
|
byteArray colors;
|
|
|
|
|
int step;
|
2026-03-02 15:58:20 +07:00
|
|
|
vector<std::shared_ptr<HoldingPlayer> > carriedBy;
|
2026-03-01 12:16:08 +08:00
|
|
|
|
|
|
|
|
private:
|
2026-03-02 15:58:20 +07:00
|
|
|
typedef unordered_map<std::shared_ptr<Player> , std::shared_ptr<HoldingPlayer> , PlayerKeyHash, PlayerKeyEq> playerHoldingPlayerMapType;
|
2026-03-01 12:16:08 +08:00
|
|
|
playerHoldingPlayerMapType carriedByPlayers;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
vector<MapDecoration *> decorations;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// 4J Stu added
|
|
|
|
|
unordered_map<int, MapDecoration *> nonPlayerDecorations;
|
|
|
|
|
static const int END_PORTAL_DECORATION_KEY;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
MapItemSavedData(const wstring& id);
|
|
|
|
|
~MapItemSavedData();
|
|
|
|
|
|
|
|
|
|
virtual void load(CompoundTag *tag);
|
|
|
|
|
virtual void save(CompoundTag *tag);
|
|
|
|
|
|
2026-03-02 15:58:20 +07:00
|
|
|
void tickCarriedBy(std::shared_ptr<Player> player, std::shared_ptr<ItemInstance> item);
|
2026-03-01 12:16:08 +08:00
|
|
|
|
2026-03-02 15:58:20 +07:00
|
|
|
charArray getUpdatePacket(std::shared_ptr<ItemInstance> itemInstance, Level *level, std::shared_ptr<Player> player);
|
2026-03-01 12:16:08 +08:00
|
|
|
|
|
|
|
|
using SavedData::setDirty;
|
|
|
|
|
void setDirty(int x, int y0, int y1);
|
|
|
|
|
void handleComplexItemData(charArray &data);
|
|
|
|
|
|
|
|
|
|
// 4J Stu Added
|
2026-03-02 15:58:20 +07:00
|
|
|
void mergeInMapData(std::shared_ptr<MapItemSavedData> dataToAdd);
|
|
|
|
|
void removeItemFrameDecoration(std::shared_ptr<ItemInstance> item);
|
2026-03-01 12:16:08 +08:00
|
|
|
};
|