4 #include <unordered_map> 7 #include "../Mobs/Wolf.h" 8 #include "../Mobs/Horse.h" 9 #include "../BoundingBox.h" 10 #include "../ChatColor.h" 11 #include "../Server.h" 12 #include "../UI/InventoryWindow.h" 13 #include "../UI/WindowOwner.h" 14 #include "../Bindings/PluginManager.h" 15 #include "../BlockEntities/BlockEntity.h" 16 #include "../BlockEntities/EnderChestEntity.h" 19 #include "../Items/ItemHandler.h" 20 #include "../FastRandom.h" 21 #include "../ClientHandle.h" 23 #include "../WorldStorage/StatSerializer.h" 24 #include "../CompositeChat.h" 26 #include "../Blocks/BlockHandler.h" 27 #include "../Blocks/BlockSlab.h" 28 #include "../Blocks/ChunkInterface.h" 30 #include "../IniFile.h" 31 #include "json/json.h" 34 #define PLAYER_INVENTORY_SAVE_INTERVAL 6000 37 #define PLAYER_LIST_TIME_MS std::chrono::milliseconds(1000) 43 cUUID GetOldStyleOfflineUUID(
const AString & a_PlayerName)
48 BaseUUID[8] = (BaseUUID[8] & 0x0f) | 0x80;
66 res.append(UUID, 0, 2);
89 super(etPlayer, 0.6, 1.8),
91 m_FoodLevel(MAX_FOOD_LEVEL),
92 m_FoodSaturationLevel(5.0),
94 m_FoodExhaustionLevel(0.0),
97 m_EnderChestContents(9, 3),
98 m_CurrentWindow(nullptr),
99 m_InventoryWindow(nullptr),
102 m_ClientHandle(a_Client),
104 m_NormalMaxSpeed(1.0),
105 m_SprintingMaxSpeed(1.3),
106 m_FlyingMaxSpeed(1.0),
108 m_IsSprinting(false),
112 m_EatingFinishTick(-1),
113 m_LifetimeTotalXp(0),
115 m_bDirtyExperience(false),
116 m_IsChargingBow(false),
118 m_FloaterID(
cEntity::INVALID_ID),
122 m_bIsTeleporting(false),
123 m_UUID((a_Client != nullptr) ? a_Client->GetUUID() :
cUUID{}),
128 ASSERT(a_PlayerName.length() <= 16);
153 FLOGD(
"Player \"{0}\" is connecting for the first time, spawning at default world spawn {1:.2f}",
192 GetWorld()->
AddPlayer(std::unique_ptr<cPlayer>(static_cast<cPlayer *>(a_Self.release())));
208 if (!
cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*
this))
214 LOGD(
"Deleting cPlayer \"%s\" at %p, ID %d",
GetName().c_str(), static_cast<void *>(
this),
GetUniqueID());
223 LOGD(
"Player %p deleted", static_cast<void *>(
this));
266 ASSERT(!
"Player ticked whilst in the process of destruction!");
279 ASSERT(!
"Player ticked whilst in the process of destruction!");
405 else if (
GetWorld()->GetWorldAge() % 100 == 0)
436 return static_cast<int>((151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7);
440 return static_cast<int>((29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal)))) / 3);
458 return static_cast<int>((3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220);
462 return static_cast<int>((1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360);
481 int currentLevel_XpBase =
XpForLevel(currentLevel);
483 return static_cast<float>(
m_CurrentXp - currentLevel_XpBase) /
484 static_cast<float>(
XpForLevel(1 + currentLevel) - currentLevel_XpBase);
493 if (!(a_CurrentXp >= 0) || (a_CurrentXp > (std::numeric_limits<int>::max() -
m_LifetimeTotalXp)))
495 LOGWARNING(
"Tried to update experiece with an invalid Xp value: %d", a_CurrentXp);
513 if (a_Xp_delta > (std::numeric_limits<int>().max() -
m_CurrentXp))
516 LOGWARNING(
"Attempt was made to increment Xp by %d, which overflowed the int datatype. Ignoring.", a_Xp_delta);
532 LOGD(
"Player \"%s\" gained / lost %d experience, total is now: %d",
GetName().c_str(), a_Xp_delta,
m_CurrentXp);
546 LOGD(
"Player \"%s\" started charging their bow",
GetName().c_str());
615 if (
cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*
this, FoodLevel))
711 if (!ItemHandler->
EatItem(
this, &Item))
951 ASSERT(a_World !=
nullptr);
989 short ArmorDamage =
static_cast<short>(std::max(a_DamageBlocked / 4, 1));
991 for (
int i = 0; i < 4; i++)
1056 ASSERT(a_Opponent !=
nullptr);
1060 if (a_Entity.
IsMob())
1062 auto & Mob =
static_cast<cMonster&
>(a_Entity);
1063 if (Mob.GetMobType() ==
mtWolf)
1065 auto & Wolf =
static_cast<cWolf&
>(Mob);
1110 const AString DamageText = [&]
1115 case dtLightning:
return "was plasmified by lightining";
1119 case dtStarving:
return "forgot the importance of food";
1123 case dtWithering:
return "is a husk of their former selves";
1124 case dtOnFire:
return "forgot to stop, drop, and roll";
1126 case dtInVoid:
return "somehow fell out of the world";
1129 case dtAdmin:
return "was administrator'd";
1131 case dtAttack:
return "was attacked by thin air";
1137 if (DeathMessage !=
AString(
""))
1142 else if (a_TDI.
Attacker ==
nullptr)
1151 if (DeathMessage !=
AString(
""))
1159 KillerClass.erase(KillerClass.begin());
1160 AString DeathMessage =
Printf(
"%s was killed by a %s",
GetName().c_str(), KillerClass.c_str());
1162 if (DeathMessage !=
AString(
""))
1187 else if (a_Victim->
IsMob())
1351 if (
cRoot::Get()->GetPluginManager()->CallHookPlayerOpeningWindow(*
this, a_Window))
1527 if ((a_GameMode <
gmMin) || (a_GameMode >=
gmMax))
1640 return static_cast<unsigned int>(New);
1732 return res * a_SpeedCoeff;
1785 if (a_Permission.empty())
1822 size_t lenP = a_Permission.size();
1823 size_t lenT = a_Template.size();
1824 size_t minLen = std::min(lenP, lenT);
1825 for (
size_t i = 0; i < minLen; i++)
1827 if (a_Template[i] ==
"*")
1832 if (a_Permission[i] != a_Template[i])
1896 else if ((
GetName().length() <= 14) && !Color.empty())
1929 char NewAmount = a_Amount;
1938 Drops.push_back(DroppedItem);
1955 Item.
m_ItemCount = std::min(OriginalItemAmount, a_Amount);
1956 Drops.push_back(Item);
1958 if (OriginalItemAmount > a_Amount)
1978 Drops.push_back(a_Item);
1996 double vX = 0, vY = 0, vZ = 0;
2008 ASSERT(a_World !=
nullptr);
2018 if (
cRoot::Get()->GetPluginManager()->CallHookEntityChangingWorld(*
this, *a_World))
2057 if (a_ShouldSendRespawn)
2080 LOGD(
"Warping player \"%s\" from world \"%s\" to \"%s\". Source chunk: (%d, %d) ",
2088 a_World->
AddPlayer(std::unique_ptr<cPlayer>(PlayerPtr), &a_OldWorld);
2118 (
m_UUID == OfflineUUID) &&
2127 const char * OfflineUsage =
" (unused)";
2128 if (
cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData())
2138 if (
cRoot::Get()->GetServer()->ShouldLoadNamedPlayerData())
2153 LOG(
"Player data file not found for %s (%s, offline %s%s), will be reset to defaults.",
2157 if (a_World ==
nullptr)
2180 LOGWARNING(
"Cannot read player data from file \"%s\"", a_FileName.c_str());
2187 Json::Reader reader;
2188 if (!reader.parse(buffer, root,
false))
2190 LOGWARNING(
"Cannot parse player data in file \"%s\"", a_FileName.c_str());
2195 Json::Value & JSON_PlayerPosition = root[
"position"];
2196 if (JSON_PlayerPosition.size() == 3)
2198 SetPosX(JSON_PlayerPosition[0].asDouble());
2199 SetPosY(JSON_PlayerPosition[1].asDouble());
2200 SetPosZ(JSON_PlayerPosition[2].asDouble());
2204 Json::Value & JSON_PlayerRotation = root[
"rotation"];
2205 if (JSON_PlayerRotation.size() == 3)
2207 SetYaw (static_cast<float>(JSON_PlayerRotation[0].asDouble()));
2208 SetPitch (static_cast<float>(JSON_PlayerRotation[1].asDouble()));
2209 SetRoll (static_cast<float>(JSON_PlayerRotation[2].asDouble()));
2212 m_Health = root.get(
"health", 0).asFloat();
2220 m_IsFlying = root.get(
"isflying", 0).asBool();
2231 int equippedSlotNum = root.get(
"equippedItemSlot", 0).asInt();
2238 if (a_World ==
nullptr)
2257 StatSerializer.
Load();
2259 FLOGD(
"Player {0} was read from file \"{1}\", spawning at {2:.2f} in world \"{3}\"",
2280 auto & Mob =
static_cast<cMonster &
>(*m_AttachedTo);
2282 if (Mob.GetMobType() !=
mtHorse)
2287 auto & Horse =
static_cast<cHorse &
>(Mob);
2304 Json::Value JSON_PlayerPosition;
2305 JSON_PlayerPosition.append(Json::Value(
GetPosX()));
2306 JSON_PlayerPosition.append(Json::Value(
GetPosY()));
2307 JSON_PlayerPosition.append(Json::Value(
GetPosZ()));
2309 Json::Value JSON_PlayerRotation;
2310 JSON_PlayerRotation.append(Json::Value(
GetYaw()));
2311 JSON_PlayerRotation.append(Json::Value(
GetPitch()));
2312 JSON_PlayerRotation.append(Json::Value(
GetRoll()));
2314 Json::Value JSON_Inventory;
2317 Json::Value JSON_EnderChestInventory;
2321 root[
"position"] = JSON_PlayerPosition;
2322 root[
"rotation"] = JSON_PlayerRotation;
2323 root[
"inventory"] = JSON_Inventory;
2325 root[
"enderchestinventory"] = JSON_EnderChestInventory;
2335 root[
"lastknownname"] =
GetName();
2350 root[
"gamemode"] =
static_cast<int>(
m_GameMode);
2360 Json::StyledWriter writer;
2361 std::string JsonData = writer.write(root);
2368 LOGWARNING(
"Error writing player \"%s\" to file \"%s\" - cannot open file. Player will lose their progress.",
2369 GetName().c_str(), SourceFile.c_str()
2373 if (f.
Write(JsonData.c_str(), JsonData.size()) != static_cast<int>(JsonData.size()))
2375 LOGWARNING(
"Error writing player \"%s\" to file \"%s\" - cannot save data. Player will lose their progress. ",
2376 GetName().c_str(), SourceFile.c_str()
2384 if (!StatSerializer.
Save())
2438 ? (0.6 + (0.4 / (UnbreakingLevel + 1))) : (1.0 / (UnbreakingLevel + 1));
2442 std::binomial_distribution<short> Dist(a_Damage, chance);
2548 default:
return false;
2575 if (a_DeltaPos.
y > 0.0)
2593 if ((a_DeltaPos.
y > 0.0) && a_PreviousIsOnGround)
2598 else if (a_DeltaPos.
y < 0.0)
2673 sSetBlockVector blk{{a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta}};
2685 for (
int y = a_BlockY - a_Range + 1; y < a_BlockY + a_Range; y++)
2687 for (
int z = a_BlockZ - a_Range + 1; z < a_BlockZ + a_Range; z++)
2689 for (
int x = a_BlockX - a_Range + 1; x < a_BlockX + a_Range; x++)
2699 LOGD(
"%s: Cannot query all blocks, not sending an update", __FUNCTION__);
2704 std::unordered_map<cChunkCoords, sSetBlockVector, cChunkCoordsHash> Changes;
2705 for (
const auto & blk: blks)
2707 Changes[
cChunkCoords(blk.m_ChunkX, blk.m_ChunkZ)].push_back(blk);
2712 for (
auto itr = Changes.cbegin(), end = Changes.cend(); itr != end; ++itr)
2714 m_ClientHandle->SendBlockChanges(itr->first.m_ChunkX, itr->first.m_ChunkZ, itr->second);
2725 std::vector<cBoundingBox> PlacementBoxes;
2727 bool HasInitializedBounds =
false;
2728 for (
auto blk: a_Blocks)
2742 BlockBox.
Move(x, y, z);
2744 PlacementBoxes.push_back(BlockBox);
2746 if (HasInitializedBounds)
2748 PlacingBounds = PlacingBounds.
Union(BlockBox);
2752 PlacingBounds = BlockBox;
2753 HasInitializedBounds =
true;
2763 const double EPSILON = 0.0005;
2770 for (
auto BlockBox : PlacementBoxes)
2773 BlockBox.
Expand(-EPSILON, -EPSILON, -EPSILON);
2774 if (EntBox.DoesIntersect(BlockBox))
2793 for (
auto blk2: a_Blocks)
2802 for (
auto blk: a_Blocks)
2807 for (
auto blk2: a_Blocks)
2820 for (
auto blk: a_Blocks)
2827 for (
auto blk: a_Blocks)
2900 for (
int x = PosX - 1; x <= (PosX + 1); ++x)
2902 for (
int y = PosY; y <= (PosY + 3); ++y)
2904 for (
int z = PosZ - 1; z <= (PosZ + 1); ++z)
2939 res.append(UUID, 0, 2);
2941 res.append(UUID, 2, AString::npos);
2942 res.append(
".json");
2991 return static_cast<float>(a_Meta + 1) / 9.0f;
3007 float f1 =
static_cast<float>(
m_Stance + 1) - f;
3022 if (efficiencyModifier > 0)
3024 f += (efficiencyModifier * efficiencyModifier) + 1;
3029 if (Haste !=
nullptr)
3031 int intensity = Haste->GetIntensity() + 1;
3032 f *= 1.0f + (intensity * 0.2f);
3036 if (MiningFatigue !=
nullptr)
3038 int intensity = MiningFatigue->GetIntensity();
3041 case 0: f *= 0.3f;
break;
3042 case 1: f *= 0.09f;
break;
3043 case 2: f *= 0.0027f;
break;
3044 default: f *= 0.00081f;
break;
3072 return (blockHardness < 0) ? 0 : ((digSpeed / blockHardness) / canHarvestBlockDivisor);
void SetMessageType(eMessageType a_MessageType, const AString &a_AdditionalMessageTypeData="")
Sets the message type, which is indicated by prefixes added to the message when serializing Takes opt...
void SetSprint(bool a_IsSprinting)
Starts or stops sprinting, sends the max speed update to the client, if needed.
void SetCanFly(bool a_CanFly)
If true the player can fly even when he's not in creative.
AString ToLongString() const
Converts the UUID to a long form string (i.e.
AString m_MsgNameColorCode
double GetPosY(void) const
void SetBlocks(const sSetBlockVector &a_Blocks)
Performs the specified single-block set operations simultaneously, as if SetBlock() was called for ea...
void SetFlyingMaxSpeed(double a_Speed)
Sets the flying relative maximum speed.
void SetFlying(bool a_IsFlying)
Flags the player as flying.
void CopyToItems(cItems &a_Items)
Copies the non-empty slots into a_ItemStacks; preserves the original a_Items contents.
bool IsValid(void) const
Returns true iff the chunk block data is valid (loaded / generated)
void SetFoodSaturationLevel(double a_FoodSaturationLevel)
virtual bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback) override
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox...
int FinishChargingBow(void)
Finishes charging the current bow.
const cItem & GetEquippedBoots(void) const
double GetPitch(void) const
virtual void BroadcastEntityAnimation(const cEntity &a_Entity, Int8 a_Animation, const cClientHandle *a_Exclude=nullptr) override
bool IsClimbing(void) const
Returns whether the player is climbing (ladders, vines etc.)
void SendMessage(const AString &a_Message)
double GetPosX(void) const
static bool Delete(const AString &a_Path)
Deletes a file or a folder, returns true if successful.
void SendHotbarActiveSlot(void)
void SetTeam(cTeam *a_Team)
Sets the player team, nullptr if none.
BLOCKTYPE GetBlock(Vector3i a_BlockPos)
Returns the block type at the specified position.
int m_FoodLevel
Represents the food bar, one point equals half a "drumstick".
StatValue GetValue(const eStatistic a_Stat) const
Return the value of the specified stat.
void SendMessageFatal(const AString &a_Message)
eEntityType GetEntityType(void) const
eMonsterType GetMobType(void) const
cTeam * UpdateTeam(void)
Forces the player to query the scoreboard for his team.
int GetXpLevel(void)
Gets the current level - XpLevel.
cItemHandler * GetHandler(void) const
Returns the cItemHandler responsible for this item type.
virtual bool IsCrouched(void) const override
void OpenHorseInventory()
Opens the inventory of any tame horse the player is riding.
virtual void BroadcastSpawnEntity(cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
static bool Rename(const AString &a_OrigPath, const AString &a_NewPath)
Renames a file or folder, returns true if successful.
double m_FlyingMaxSpeed
Max speed, relative to the game default flying max speed, when flying.
void SendEntityVelocity(const cEntity &a_Entity)
static eStatistic GetPrerequisite(const eStatistic a_Type)
Returns stat prerequisite.
cSlotNums m_InventoryPaintSlots
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType)
Returns whether this tool / item can harvest a specific block (e.g.
virtual bool DoesPreventBlockPlacement(void) const
Returns whether blocks can be placed intersecting this entities' hitbox.
void SendMessagePrivateMsg(const AString &a_Message, const AString &a_Sender)
void SendMessageInfo(const AString &a_Message)
bool AllowsFriendlyFire(void) const
void SetSprintingMaxSpeed(double a_Speed)
Sets the sprinting relative maximum speed.
cChunk * GetParentChunk()
Returns the chunk responsible for ticking this entity.
static void LoadFromJson(const Json::Value &a_Value, cItemGrid &a_Grid)
const AString & GetDefaultRank(void) const
Returns the name of the default rank.
void SetNormalMaxSpeed(double a_Speed)
Sets the normal relative maximum speed.
AString ToShortString() const
Converts the UUID to a short form string (i.e without dashes).
void SetInvulnerableTicks(int a_InvulnerableTicks)
Set the invulnerable ticks from the entity.
int GetEquippedSlotNum(void)
Returns slot number of equiped item.
static bool IsSolid(BLOCKTYPE a_Type)
void SendAboveActionBarMessage(const AString &a_Message)
unsigned int AwardAchievement(const eStatistic a_Ach)
Awards the player an achievement.
AString GetPrefix(void) const
Returns the player name prefix, may contain @ format directives.
unsigned char BLOCKTYPE
The datatype used by blockdata.
void SetFoodLevel(int a_FoodLevel)
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI)
Makes this entity take damage specified in the a_TDI.
bool HasCustomName(void) const
Returns true if the player has a custom name.
bool RemoveOneEquippedItem(void)
Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed.
bool m_IsFrozen
If true, we are locking m_Position to m_FrozenPosition.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
double GetMaxSpeed(void) const
Returns the current relative maximum speed (takes current sprinting / flying state into account) ...
void SendExperience(void)
double m_LastGroundHeight
void SendBlocksAround(int a_BlockX, int a_BlockY, int a_BlockZ, int a_Range=1)
Sends the block in the specified range around the specified coord to the client as a block change pac...
long GetSize(void) const
Returns the size of file, in bytes, or -1 for failure; asserts if not open.
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override
Sets the speed and sends it to the client, so that they are forced to move so.
virtual bool DoMoveToWorld(cWorld *a_World, bool a_ShouldSendRespawn, Vector3d a_NewPosition) override
Moves the player to the specified world.
static cBlockHandler * GetHandler(BLOCKTYPE a_Type)
cWindow * GetWindow(void)
void SetPosition(double a_PosX, double a_PosY, double a_PosZ)
void StartEating(void)
Starts eating the currently equipped item.
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
int m_SkinParts
Displayed skin part bit mask.
void SendPlayerSpawn(const cPlayer &a_Player)
void TossEquippedItem(char a_Amount=1)
tosses the item in the selected hotbar slot
AString GetPlayerListName(void) const
Returns the name that is used in the playerlist.
virtual void Heal(int a_Health) override
Heals the player by the specified amount of HPs (positive only); sends health update.
cClientHandlePtr m_ClientHandle
virtual void Detach(void)
Detaches from the currently attached entity, if any.
const cItem & GetEquippedItem(void) const
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block)
Returns the strength to break a specific block.
void Unfreeze()
Cancels Freeze(...) and allows the player to move naturally.
AString GetPlayerRankName(const cUUID &a_PlayerUUID)
Returns the name of the rank that the specified player has assigned to them.
void Expand(double a_ExpandX, double a_ExpandY, double a_ExpandZ)
Expands the bounding box by the specified amount in each direction (so the box becomes larger by 2 * ...
void SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem &a_Item)
void SetSkinParts(int a_Parts)
int ChangeSlotCount(int a_SlotNum, int a_AddToCount)
Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot...
cItem & GetDraggingItem(void)
In UI windows, get the item that the player is dragging.
AStringVector GetPlayerPermissions(const cUUID &a_PlayerUUID)
Returns the permissions that the specified player has assigned to them.
virtual void Detach(void) override
Detaches from the currently attached entity, if any.
virtual void BroadcastPlayerListUpdatePing(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
void SetIsTicking(bool a_IsTicking)
Set the entity's status to either ticking or not ticking.
AStringVector GetPlayerRestrictions(const cUUID &a_PlayerUUID)
Returns the restrictions that the specified player has assigned to them.
virtual void OnPlacedByPlayer(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const sSetBlock &a_BlockChange)
Called by cPlayer::PlaceBlocks() for each block after it has been set to the world.
void TossHeldItem(char a_Amount=1)
tosses the item held in hand (when in UI windows)
static cItemHandler * GetItemHandler(int a_ItemType)
static const char * Delimiter
void ScheduleMoveToWorld(cWorld *a_World, Vector3d a_NewPosition, bool a_ShouldSetPortalCooldown=false, bool a_ShouldSendRespawn=false)
Schedules a MoveToWorld call to occur on the next Tick of the entity.
bool LoadFromDisk(cWorldPtr &a_World)
Loads the player data from the disk file Sets a_World to the world where the player will spawn...
bool AddPlayer(const AString &a_Name)
Adds a new player to the team.
bool GetRankVisuals(const AString &a_RankName, AString &a_MsgPrefix, AString &a_MsgSuffix, AString &a_MsgNameColorCode)
Returns the message visuals of an existing rank.
cWorld * GetWorld(const AString &a_WorldName)
Returns a pointer to the world specified.
AString GetSuffix(void) const
Returns the player name suffix, may contain @ format directives.
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action)
Get the durability lost which the item will get, when a specified action was performed.
unsigned int GetLevel(int a_EnchantmentID) const
Returns the level for the specified enchantment; 0 if not stored.
cRankManager * GetRankManager(void)
void SendPlayerMaxSpeed(void)
Informs the client of the maximum player speed (1.6.1+)
virtual bool IsInWater(void) const
Returns true if any part of the entity is in a water block.
OwnedEntity RemoveEntity(cEntity &a_Entity)
Releases ownership of the given entity if it was found in this chunk.
virtual bool IsOnGround(void) const override
Returns whether the entity is on ground or not.
cWindow * m_InventoryWindow
void TossItems(const cItems &a_Items)
Tosses a list of items.
void SetPitch(double a_Pitch)
const AString & GetName(void) const
bool LoadFromFile(const AString &a_FileName, cWorldPtr &a_World)
Loads the player data from the specified file Sets a_World to the world where the player will spawn...
virtual void SpawnOn(cClientHandle &a_Client) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
void HandleFood(void)
Called in each tick to handle food-related processing.
void SetVisible(bool a_bVisible)
const AString & GetLoadedWorldName()
void SetBedPos(const Vector3i &a_Pos)
Sets the player's bed (home / respawn) position to the specified position.
bool CallHookKilled(cEntity &a_Victim, TakeDamageInfo &a_TDI, AString &a_DeathMessage)
void SetGameMode(eGameMode a_GameMode)
Sets the gamemode for the player.
void UseItem(int a_SlotNumber, short a_Damage=1)
Damage the item in a_SlotNumber by a_Damage, possibly less if the equipped item is enchanted...
eWeather GetWeather(void) const
Returns the current weather.
static const int MAX_FOOD_LEVEL
Represents two sets of coords, minimum and maximum for each direction.
int ReadRestOfFile(AString &a_Contents)
Reads the file from current position till EOF into an AString; returns the number of bytes read or -1...
bool SaveToDisk(void)
Saves all player data, such as inventory, to JSON.
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
bool PlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Calls the block-placement hook and places the block in the world, unless refused by the hook...
AString GetColor(void) const
Returns the full color code to use for this player, based on their rank.
double GetWidth(void) const
static bool PermissionMatches(const AStringVector &a_Permission, const AStringVector &a_Template)
Returns true iff a_Permission matches the a_Template.
int m_FoodTickTimer
Count-up to the healing or damaging action, based on m_FoodLevel.
static cPluginManager * Get(void)
Returns the instance of the Plugin Manager (there is only ever one)
AStringVector m_Permissions
All the permissions that this player has, based on their rank.
virtual void Destroyed() override
void SpawnItemPickups(const cItems &a_Pickups, Vector3i a_BlockPos, double a_FlyAwaySpeed=1.0, bool a_IsPlayerCreated=false)
Spawns item pickups for each item in the list.
void CloseWindowIfID(char a_WindowID, bool a_CanRefuse=true)
Closes the current window if it matches the specified ID, resets current window to m_InventoryWindow...
static void SaveToJson(Json::Value &a_Value, const cItemGrid &a_Grid)
virtual bool DoTakeDamage(TakeDamageInfo &TDI) override
Filters out damage for creative mode / friendly fire.
StatValue AddValue(const eStatistic a_Stat, const StatValue a_Delta=1)
Increments the specified stat.
double GetRoll(void) const
bool DoWithEntityByID(UInt32 a_UniqueID, cEntityCallback a_Callback)
Calls the callback if the entity with the specified ID is found, with the entity object as the callba...
bool IsGameModeSpectator(void) const
Returns true if the world is in Spectator mode.
NIBBLETYPE GetBlockMeta(Vector3i a_BlockPos)
Returns the block meta at the specified position.
void SetPosY(double a_PosY)
void SendWeather(eWeather a_Weather)
const cItem & GetEquippedItem(void) const
Returns current equiped item.
void CancelChargingBow(void)
Cancels the current bow charging.
Vector3d GetThrowStartPos(void) const
Returns the position where projectiles thrown by this player should start, player eye position + adju...
void SetFoodExhaustionLevel(double a_FoodExhaustionLevel)
virtual void Destroy(bool a_ShouldBroadcast=true)
Destroys the entity and schedules it for memory freeing; if a_ShouldBroadcast is set to true...
void SetTouchGround(bool a_bTouchGround)
virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item)
Called after the player has eaten this item.
virtual ~cPlayer() override
double GetHeight(void) const
void SendCameraSetTo(const cEntity &a_Entity)
virtual void TeleportToEntity(cEntity &a_Entity)
Teleports to the entity specified.
void QueueTask(std::function< void(cWorld &)> a_Task)
Queues a task onto the tick thread.
void AddInventoryPaintSlot(int a_SlotNum)
Adds a slot to the list for inventory painting.
void SetMainHand(eMainHand a_Hand)
void SetMaxHealth(float a_MaxHealth)
Sets the maximum value for the health.
bool CallHookSpawnedEntity(cWorld &a_World, cEntity &a_Entity)
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override
bool PlaceBlocks(const sSetBlockVector &a_Blocks)
Calls the block placement hooks and places the blocks in the world.
std::vector< AString > AStringVector
Utilities to allow casting a cWorld to one of its interfaces without including World.h.
void SetIP(const AString &a_IP)
cBoundingBox Union(const cBoundingBox &a_Other)
Returns the union of the two bounding boxes.
cEnchantments m_Enchantments
const cSlotNums & GetInventoryPaintSlots(void) const
Returns the list of slots currently stored for inventory painting.
bool IsGameModeAdventure(void) const
Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current wor...
void Move(double a_OffX, double a_OffY, double a_OffZ)
Moves the entire boundingbox by the specified offset.
cWorld * m_SpawnWorld
The world which the player respawns in upon death.
void SetIsFishing(bool a_IsFishing, UInt32 a_FloaterID=cEntity::INVALID_ID)
void SetRoll(double a_Roll)
static cUUID GenerateVersion3(const AString &a_Name)
Generates a version 3, variant 1 UUID based on the md5 hash of a_Name.
void UpdateItems(void)
Update items (e.g.
static bool IsFile(const AString &a_Path)
Returns true if the specified path is a regular file.
void LoadRank(void)
(Re)loads the rank and permissions from the cRankManager.
Container for a single chat message composed of multiple functional parts.
bool GetBlocks(sSetBlockVector &a_Blocks, bool a_ContinueOnFailure)
Retrieves block types of the specified blocks.
virtual void BroadcastDestroyEntity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
void SendMessageFailure(const AString &a_Message)
bool DoesPlacingBlocksIntersectEntity(const sSetBlockVector &a_Blocks)
Whether placing the given blocks would intersect any entitiy.
const cItem & GetEquippedLeggings(void) const
Int64 m_EatingFinishTick
The world tick in which eating will be finished.
Vector3d GetLookVector(void) const
double GetSpawnY(void) const
bool CallHookPlayerPlacingBlock(cPlayer &a_Player, const sSetBlock &a_BlockChange)
unsigned int m_TicksUntilNextSave
How long till the player's inventory will be saved Default save interval is #defined in PLAYER_INVENT...
bool IsFrozen()
Is the player frozen?
float GetLiquidHeightPercent(NIBBLETYPE a_Meta)
Returns how high the liquid is in percent.
eGameMode GetGameMode(void) const
Returns the current game mode.
void Add(const cItem &a_Item)
void SendEntityHeadLook(const cEntity &a_Entity)
double m_SprintingMaxSpeed
Max speed, relative to the game default max speed, when sprinting.
bool IsTicking(void) const
Returns true if the entity is valid and ticking.
bool IsFlying(void) const
Returns true if the player is currently flying.
bool m_IsManuallyFrozen
Was the player frozen manually by a plugin or automatically by the server?
double m_FoodSaturationLevel
"Overcharge" for the m_FoodLevel; is depleted before m_FoodLevel
bool Open(const AString &iFileName, eMode iMode)
double GetNormalMaxSpeed(void) const
Gets the normal relative maximum speed.
cEntityEffect * GetEntityEffect(cEntityEffect::eType a_EffectType)
Returns the entity effect, if it is currently applied or nullptr if not.
void InvalidateCachedSentChunk()
#define PLAYER_INVENTORY_SAVE_INTERVAL
double Length(void) const
static const int MAX_HEALTH
virtual void OpenedByPlayer(cPlayer &a_Player)
void SetCrouch(bool a_IsCrouched)
Sets the crouch status, broadcasts to all visible players.
float GetXpPercentage(void)
Gets the experience bar percentage - XpP.
Vector3< double > Vector3d
float GetDigSpeed(BLOCKTYPE a_Block)
Returns the dig speed using the current tool on the block a_Block.
const cItem & GetEquippedHelmet(void) const
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
void CollectPickupsByPlayer(cPlayer &a_Player)
double GetEyeHeight(void) const
virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP)
Returns the relative bounding box that must be entity-free in order for the block to be placed...
void RemoveClientHandle(void)
Called by cClientHandle when the client is being destroyed.
bool IsDestroyed() const
Deprecated.
void LOGINFO(const char *a_Format, fmt::ArgList a_ArgList)
float GetPlayerRelativeBlockHardness(BLOCKTYPE a_Block)
Returns the relative block hardness for the block a_Block.
std::chrono::steady_clock::time_point m_LastPlayerListTime
AString & Printf(AString &str, const char *format, fmt::ArgList args)
Output the formatted text into the string.
double m_FoodExhaustionLevel
A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel...
bool CallHookPlayerPlacedBlock(cPlayer &a_Player, const sSetBlock &a_BlockChange)
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
Does the actual speed-setting.
int DeltaExperience(int a_Xp_delta)
#define PLAYER_LIST_TIME_MS
virtual Int64 GetWorldAge(void) const override
void SetViewDistance(int a_ViewDistance)
Sets the maximal view distance.
float GetHealth(void) const
Returns the health of this entity.
bool IsGameModeCreative(void) const
Returns true if the world is in Creative mode.
cScoreboard & GetScoreBoard(void)
Returns the associated scoreboard instance.
bool Feed(int a_Food, double a_Saturation)
Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full".
virtual void BroadcastPlayerListAddPlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
void LOGWARNING(const char *a_Format, fmt::ArgList a_ArgList)
cWindow * m_CurrentWindow
bool UpdatePlayerName(const cUUID &a_PlayerUUID, const AString &a_NewPlayerName)
Updates the playername that is saved with this uuid.
Vector3i m_LastBedPos
The player's last saved bed position.
void SetWorld(cWorld *a_World)
Sets the internal world pointer to a new cWorld, doesn't update anything else.
virtual eDimension GetDimension(void) const override
virtual void BroadcastPlayerListUpdateGameMode(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
void StartChargingBow(void)
Starts charging the equipped bow.
void NotifyNearbyWolves(cPawn *a_Opponent, bool a_IsPlayerInvolved)
Notify nearby wolves that the player or one of the player's wolves took damage or did damage to an en...
void CloseWindow(bool a_CanRefuse=true)
Closes the current window, resets current window to m_InventoryWindow.
void SendEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item)
void SendMessageRaw(const AString &a_MessageRaw, eChatType a_Type=eChatType::ctChatBox)
void SendPlayerPosition(void)
float GetMaxHealth(void) const
virtual void ResetPosition(Vector3d a_NewPosition) override
Set the entities position and last sent position.
int m_AirLevel
Air level of a mobile.
void Clear(void)
Removes all items from the entire inventory.
void FreezeInternal(const Vector3d &a_Location, bool a_ManuallyFrozen)
Pins the player to a_Location until Unfreeze() is called.
double GetSpawnZ(void) const
Vector3i GetLastBedPos(void) const
Gets the last position that the player slept in This is initialised to the world spawn point if the p...
void UpdateMovementStats(const Vector3d &a_DeltaPos, bool a_PreviousIsOnGround)
Update movement-related statistics.
void ClearInventoryPaintSlots(void)
Clears the list of slots that are being inventory-painted.
void Freeze(const Vector3d &a_Location)
Prevent the player from moving and lock him into a_Location.
bool ShouldBroadcastDeathMessages(void) const
void BroadcastChatLeave(const AString &a_Message)
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
Sets the speed of the entity, measured in m / sec.
T Clamp(T a_Value, T a_Min, T a_Max)
Clamp X to the specified range.
virtual void BroadcastTeleportEntity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastPlayerListRemovePlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
cBlockHandler * BlockHandler(BLOCKTYPE a_BlockType)
virtual void Killed(cEntity *a_Victim) override
Called when the entity kills another entity.
bool IsArmor(short a_ItemType)
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override
Teleports to the coordinates specified.
void SendMessageSuccess(const AString &a_Message)
void SendWholeWindow(cClientHandle &a_Client)
Sends the contents of the whole window to the specified client.
bool IsSatiated(void) const
Returns true if the player is satiated, i.
void SendMessageWarning(const AString &a_Message)
eMainHand m_MainHand
The main hand of the player.
static bool CreateFolderRecursive(const AString &a_FolderPath)
Creates a new folder with the specified name, creating its parents if needed.
const cItem & GetSlot(int a_SlotNum) const
Returns current item in a_SlotNum slot.
void FromRaw(const std::array< Byte, 16 > &a_Raw)
Assigns from raw memory representation, respecting UUID variant.
virtual bool ClosedByPlayer(cPlayer &a_Player, bool a_CanRefuse)
Called when a player closes this window; notifies all slot areas.
AStringVectorVector m_SplitRestrictions
All the restrictions that this player has, based on their rank, split into individual dot-delimited p...
cWorld * GetDefaultWorld(void)
double GetYaw(void) const
cChunkMap * GetChunkMap(void)
void TakeDamage(cEntity &a_Attacker)
Makes this pawn take damage from an attack by a_Attacker.
cEntity * m_AttachedTo
The entity to which this entity is attached (vehicle), nullptr if none.
void GenerateOfflineUUID(void)
Generates an UUID based on the username stored for this client, and stores it in the m_UUID member...
const AString & GetName(void) const
Returns the name of the world.
void EulerToVector(double a_Pan, double a_Pitch, double &a_X, double &a_Y, double &a_Z)
bool IsPlayer(void) const
bool HasPermission(const AString &a_Permission)
double GetSprintingMaxSpeed(void) const
Gets the sprinting relative maximum speed.
void SendRotation(double a_YawDegrees, double a_PitchDegrees)
Sends the "look" packet to the player, forcing them to set their rotation to the specified values...
static const int MAX_AIR_LEVEL
Maximum air an entity can have.
void FinishEating(void)
Finishes eating the currently equipped item.
virtual void Heal(int a_HitPoints)
Heals the specified amount of HPs.
static int XpForLevel(int a_Level)
Calculates the amount of XP needed for a given level Ref: https://minecraft.gamepedia.com/XP.
static int CalcLevelFromXp(int a_CurrentXp)
Inverse of XpForLevel Ref: https://minecraft.gamepedia.com/XP values are as per this with pre-calcula...
bool LoadFromJson(Json::Value &a_Value)
void SendPlayerMoveLook(void)
void AddShowAchievementPart(const AString &a_PlayerName, const AString &a_Achievement, const AString &a_Style="")
Adds a part that fully formats a specified achievement using client translatable strings Takes achiev...
cTeam * QueryPlayerTeam(const AString &a_Name)
virtual void AttachTo(cEntity *a_AttachTo) override
Attaches to the specified entity; detaches from any previous one first.
void SetCustomName(const AString &a_CustomName)
Sets the custom name of this player.
void AbortEating(void)
Aborts the current eating operation.
bool IsGameModeSurvival(void) const
Returns true if the player is in Survival mode, either explicitly, or by inheriting from current worl...
AString m_LoadedWorldName
void TossPickup(const cItem &a_Item)
tosses a pickup newly created from a_Item
void LOG(const char *a_Format, fmt::ArgList a_ArgList)
double GetFlyingMaxSpeed(void) const
Gets the flying relative maximum speed.
int m_LifetimeTotalXp
Player Xp level.
virtual void BroadcastChatDeath(const AString &a_Message, const cClientHandle *a_Exclude=nullptr) override
Vector3d GetEyePosition(void) const
bool m_bIsTeleporting
Flag used by food handling system to determine whether a teleport has just happened Will not apply fo...
void UseEquippedItem(short a_Damage=1)
Damage the player's equipped item by a_Damage, possibly less if the equipped item is enchanted...
double m_NormalMaxSpeed
Max speed, relative to the game default.
void SendSystemMessage(const AString &a_Message)
void PlayerOpenWindow(cPlayer &a_Player)
virtual bool IsSprinting(void) const override
AStringVector StringSplit(const AString &str, const AString &delim)
Split the string at any of the listed delimiters.
bool RandBool(double a_TrueProbability=0.5)
Return a random bool with the given probability of being true.
virtual void ApplyArmorDamage(int DamageBlocked) override
Applies damage to the armor after the armor blocked the given amount.
void HandleFloater(void)
Called in each tick if the player is fishing to make sure the floater dissapears when the player does...
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
bool CanMobsTarget(void) const
Returns true if the player can be targeted by Mobs.
void ForceSetSpeed(const Vector3d &a_Speed)
Forces the player to move in the given direction.
virtual void AttachTo(cEntity *a_AttachTo)
Attaches to the specified entity; detaches from any previous one first.
void SetFoodTickTimer(int a_FoodTickTimer)
std::unique_ptr< cEntity > OwnedEntity
virtual float GetExplosionExposureRate(Vector3d a_ExplosionPosition, float a_ExlosionPower) override
get player explosion exposure rate
int Write(const void *a_Buffer, size_t a_NumBytes)
Writes up to a_NumBytes bytes from a_Buffer, returns the number of bytes actually written...
bool ShouldBroadcastAchievementMessages(void) const
void SendPlayerAbilities(void)
virtual void Destroyed(void) override
bool SetCurrentExperience(int a_XpTotal)
Sets the experience total Returns true on success "should" really only be called at init or player de...
double GetPosZ(void) const
AString m_Rank
The name of the rank assigned to this player.
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
static const int EATING_TICKS
Number of ticks it takes to eat an item.
char GetWindowID(void) const
void AddPlayer(std::unique_ptr< cPlayer > a_Player, cWorld *a_OldWorld=nullptr)
Adds the player to the world.
bool DamageItem(int a_SlotNum, short a_Amount)
Adds the specified damage to the specified item; deletes the item and returns true if the item broke...
Vector3d GetThrowSpeed(double a_SpeedCoeff) const
Returns the initial speed vector of a throw, with a 3D length of a_SpeedCoeff.
void StopEveryoneFromTargetingMe()
Tells all pawns which are targeting us to stop targeting us.
cPlayer(cClientHandlePtr a_Client, const AString &a_PlayerName)
virtual const char * GetClass(void) const
Returns the topmost class name for the object.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
const cUUID & GetUUID(void) const
Returns the UUID that has been read from the client, or nil if not available.
void SetYaw(double a_Yaw)
bool IsGameModeSpectator(void) const
Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current wor...
void StopBurning(void)
Stops the entity from burning, resets all burning timers.
void SetPosX(double a_PosX)
cItemGrid m_EnderChestContents
An item grid that stores the player specific enderchest contents.
eGameMode GetEffectiveGameMode(void) const
Returns the current effective gamemode (inherited gamemode is resolved before returning) ...
virtual float GetExplosionExposureRate(Vector3d a_ExplosionPosition, float a_ExlosionPower)
a lightweight calculation approach to get explosion exposure rate
cItem m_DraggingItem
The item being dragged by the cursor while in a UI window.
void SaveToJson(Json::Value &a_Value)
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
cItemGrid & GetHotbarGrid(void)
Returns the cItemGrid object representing the hotbar slots.
AStringVectorVector m_SplitPermissions
All the permissions that this player has, based on their rank, split into individual dot-delimited pa...
AString StrToLower(const AString &s)
Returns a lower-cased copy of the string.
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default)
cInventory & GetInventory(void)
void ReceiveNearbyFightInfo(const cUUID &a_PlayerUUID, cPawn *a_Opponent, bool a_IsPlayerInvolved)
Notfies the wolf of a nearby fight.
void SetPosZ(double a_PosZ)
eDurabilityLostAction
Actions that may cause durability of an item may be lost, where the magnitude of the loss depends on ...
const cItem & GetEquippedChestplate(void) const
#define UNREACHABLE(x)
Use to mark code that should be impossible to reach.
cItemHandler * ItemHandler(int a_ItemType)
void AddFoodExhaustion(double a_Exhaustion)
Adds the specified exhaustion to m_FoodExhaustion.
void AddPlayerScore(const AString &a_Name, cObjective::eType a_Type, cObjective::Score a_Value=1)
AString GetUUIDFileName(const cUUID &a_UUID)
Returns the filename for the player data based on the UUID given.
std::vector< sSetBlock > sSetBlockVector
#define PREPARE_REL_AND_CHUNK(Position, OriginalChunk)
std::shared_ptr< cClientHandle > cClientHandlePtr
UInt32 GetUniqueID(void) const
cInventory m_Inventory
Stores the player's inventory, consisting of crafting grid, hotbar, and main slots.
void OpenWindow(cWindow &a_Window)
Opens the specified window; closes the current one first using CloseWindow()
virtual void SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer &a_Player) override
Sends the block on those coords to the player.
std::array< Byte, 16 > ToRaw() const
Converts UUID to raw memory representation, respecting UUID variant.
cUUID m_UUID
The UUID of the player, as read from the ClientHandle.
virtual void BroadcastChat(const AString &a_Message, const cClientHandle *a_Exclude=nullptr, eMessageType a_ChatPrefix=mtCustom) override
bool RemovePlayer(const AString &a_Name)
Removes a player from the team.
cWorld * GetWorld(void) const
This class bridges a vector of cItem for safe access via Lua.
cClientHandle * GetClientHandle(void) const
Returns the raw client handle associated with the player.
virtual bool EatItem(cPlayer *a_Player, cItem *a_Item)
Lets the player eat a selected item.
cPluginManager * GetPluginManager(void)
std::vector< int > cSlotNums
List of slot numbers, used for inventory-painting.
void SetEquippedSlotNum(int a_SlotNum)
Sets equiped item to the a_SlotNum slot number.
void SetDraggingItem(const cItem &a_Item)
In UI windows, set the item that the player is dragging.
static float GetHardness(BLOCKTYPE a_Type)
virtual void BroadcastMovementUpdate(const cClientHandle *a_Exclude=nullptr)
Updates clients of changes in the entity.
AStringVector m_Restrictions
All the restrictions that this player has, based on their rank.
double GetSpawnX(void) const
static const AString & GetName(const eStatistic a_Type)
Type -> Name.
virtual bool Initialize(OwnedEntity a_Self, cWorld &a_World) override
Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed).
bool IsInsideWater()
Checks if the player is inside of water.