the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2class Entity;
3//class ServerPlayer;
4#include "ServerPlayer.h"
5class Packet;
6using namespace std;
7
8class EntityTracker;
9
10#define TRACKED_ENTITY_MINIMUM_VIEW_DISTANCE 4
11
12class TrackedEntity
13{
14private:
15 static const int TOLERANCE_LEVEL = 4;
16
17public:
18 shared_ptr<Entity> e;
19
20 int range, updateInterval;
21 int xp, yp, zp, yRotp, xRotp, yHeadRotp;
22 double xap, yap, zap;
23 int tickCount;
24
25private:
26 double xpu, ypu, zpu;
27 bool updatedPlayerVisibility;
28 bool trackDelta;
29 int teleportDelay;
30 shared_ptr<Entity> lastRidingEntity;
31 bool wasRiding;
32
33public:
34 bool moved;
35
36 unordered_set<shared_ptr<ServerPlayer> , PlayerKeyHash, PlayerKeyEq > seenBy;
37
38 TrackedEntity(shared_ptr<Entity> e, int range, int updateInterval, bool trackDelta);
39
40 void tick(EntityTracker *tracker, vector<shared_ptr<Player> > *players);
41
42private:
43 void sendDirtyEntityData();
44
45public:
46 void broadcast(shared_ptr<Packet> packet);
47 void broadcastAndSend(shared_ptr<Packet> packet);
48 void broadcastRemoved();
49 void removePlayer(shared_ptr<ServerPlayer> sp);
50
51private:
52 bool canBySeenBy(shared_ptr<ServerPlayer> player);
53
54 enum eVisibility
55 {
56 eVisibility_NotVisible = 0,
57 eVisibility_IsVisible = 1,
58 eVisibility_SeenAndVisible = 2,
59 };
60
61 eVisibility isVisible(EntityTracker *tracker, shared_ptr<ServerPlayer> sp, bool forRider = false); // 4J Added forRider
62
63public:
64 void updatePlayer(EntityTracker *tracker, shared_ptr<ServerPlayer> sp);
65 void updatePlayers(EntityTracker *tracker, vector<shared_ptr<Player> > *players);
66private:
67 void sendEntityData(shared_ptr<PlayerConnection> conn);
68 shared_ptr<Packet> getAddEntityPacket();
69public:
70 void clear(shared_ptr<ServerPlayer> sp);
71};