5 #include "../Mobs/Wolf.h"
6 #include "../Mobs/Horse.h"
7 #include "../BoundingBox.h"
8 #include "../ChatColor.h"
10 #include "../UI/InventoryWindow.h"
11 #include "../UI/WindowOwner.h"
12 #include "../Bindings/PluginManager.h"
13 #include "../BlockEntities/BlockEntity.h"
14 #include "../BlockEntities/EnderChestEntity.h"
17 #include "../Items/ItemHandler.h"
18 #include "../FastRandom.h"
19 #include "../ClientHandle.h"
21 #include "../WorldStorage/StatisticsSerializer.h"
22 #include "../CompositeChat.h"
24 #include "../Blocks/BlockHandler.h"
25 #include "../Blocks/BlockSlab.h"
26 #include "../Blocks/ChunkInterface.h"
28 #include "../IniFile.h"
29 #include "../JsonUtils.h"
30 #include "json/json.h"
32 #include "../CraftingRecipes.h"
48 res.append(UUID, 0, 2);
64 #define EATING_TICKS 30_tick
67 #define PLAYER_INVENTORY_SAVE_INTERVAL 6000
70 #define RESPAWN_FOOD_SATURATION 5
72 #define XP_TO_LEVEL15 255
73 #define XP_PER_LEVEL_TO15 17
74 #define XP_TO_LEVEL30 825
157 LOGD(
"Deleting cPlayer \"%s\" at %p, ID %d",
GetName().c_str(),
static_cast<void *
>(
this),
GetUniqueID());
166 LOGD(
"Player %p deleted",
static_cast<void *
>(
this));
195 return static_cast<int>((151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7);
199 return static_cast<int>((29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal)))) / 3);
226 return static_cast<int>((3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220);
230 return static_cast<int>((1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360);
249 int currentLevel_XpBase =
XpForLevel(currentLevel);
251 return static_cast<float>(
m_CurrentXp - currentLevel_XpBase) /
252 static_cast<float>(
XpForLevel(1 + currentLevel) - currentLevel_XpBase);
261 if (!(a_CurrentXp >= 0) || (a_CurrentXp > (std::numeric_limits<int>::max() -
m_LifetimeTotalXp)))
263 LOGWARNING(
"Tried to update experiece with an invalid Xp value: %d", a_CurrentXp);
281 if (a_Xp_delta > (std::numeric_limits<int>().max() -
m_CurrentXp))
284 LOGWARNING(
"Attempt was made to increment Xp by %d, which overflowed the int datatype. Ignoring.", a_Xp_delta);
300 LOGD(
"Player \"%s\" gained / lost %d experience, total is now: %d",
GetName().c_str(), a_Xp_delta,
m_CurrentXp);
314 LOGD(
"Player \"%s\" started charging their bow",
GetName().c_str());
383 if (
cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*
this, FoodLevel))
453 return std::holds_alternative<BodyStanceSleeping>(
m_BodyStance);
471 return std::holds_alternative<BodyStanceStanding>(
m_BodyStance);
503 else if (!a_GoToBed &&
IsInBed())
538 Item.m_ItemCount = 1;
539 auto & ItemHandler =
Item.GetHandler();
540 if (!ItemHandler.EatItem(
this, &
Item))
833 ASSERT(a_Opponent !=
nullptr);
837 if (a_Entity.
IsMob())
839 auto & Mob = static_cast<cMonster&>(a_Entity);
840 if (Mob.GetMobType() == mtWolf)
842 auto & Wolf = static_cast<cWolf&>(Mob);
843 Wolf.ReceiveNearbyFightInfo(GetUUID(), a_Opponent, a_IsPlayerInvolved);
906 else if (a_Victim.
IsMob())
908 const auto & Monster =
static_cast<const cMonster &
>(a_Victim);
917 const double DistX =
GetPosX() - Monster.GetPosX();
918 const double DistZ =
GetPosZ() - Monster.GetPosZ();
920 if ((DistX * DistX + DistZ * DistZ) >= 2500.0)
1125 if (
cRoot::Get()->GetPluginManager()->CallHookPlayerOpeningWindow(*
this, a_Window))
1310 if ((a_GameMode <
gmMin) || (a_GameMode >=
gmMax))
1473 if (a_Target ==
this)
1485 if (a_Target ==
nullptr)
1524 return res * a_SpeedCoeff;
1588 if (a_Permission.empty())
1625 size_t lenP = a_Permission.size();
1626 size_t lenT = a_Template.size();
1627 size_t minLen = std::min(lenP, lenT);
1628 for (
size_t i = 0; i < minLen; i++)
1630 if (a_Template[i] ==
"*")
1635 if (a_Permission[i] != a_Template[i])
1644 return (lenP == lenT);
1693 else if ((
GetName().length() <= 14) && !Color.empty())
1695 return fmt::format(FMT_STRING(
"{}{}"), Color,
GetName());
1726 char NewAmount = a_Amount;
1735 Drops.push_back(DroppedItem);
1748 char ItemCountToToss = a_Item.
m_ItemCount -
static_cast<char>(PlacedCount);
1750 if (ItemCountToToss == 0)
1755 cItem Pickup = a_Item;
1768 if (!
Item.IsEmpty())
1770 char OriginalItemAmount =
Item.m_ItemCount;
1771 Item.m_ItemCount = std::min(OriginalItemAmount, a_Amount);
1772 Drops.push_back(
Item);
1774 if (OriginalItemAmount > a_Amount)
1776 Item.m_ItemCount = OriginalItemAmount - a_Amount;
1794 Drops.push_back(a_Item);
1808 const auto & UUID =
GetUUID();
1820 catch (
const InputFileStream::failure &)
1822 if (errno != ENOENT)
1829 LOG(
"Player \"%s\" (%s) save or statistics file not found, resetting to defaults",
GetName().c_str(), UUID.ToShortString().c_str());
1835 if (
const auto & PlayerPosition = Root[
"position"]; PlayerPosition.size() == 3)
1837 SetPosition(PlayerPosition[0].asDouble(), PlayerPosition[1].asDouble(), PlayerPosition[2].asDouble());
1844 if (
const auto & PlayerRotation = Root[
"rotation"]; PlayerRotation.size() == 3)
1846 SetYaw (PlayerRotation[0].asDouble());
1847 SetPitch(PlayerRotation[1].asDouble());
1848 SetRoll (PlayerRotation[2].asDouble());
1859 m_IsFlying = Root.get(
"isflying", 0).asBool();
1862 Json::Value & JSON_KnownItems = Root[
"knownItems"];
1863 for (
UInt32 i = 0; i < JSON_KnownItems.size(); i++)
1866 Item.FromJson(JSON_KnownItems[i]);
1872 Json::Value & JSON_KnownRecipes = Root[
"knownRecipes"];
1873 for (
UInt32 i = 0; i < JSON_KnownRecipes.size(); i++)
1875 auto RecipeId = RecipeNameMap.find(JSON_KnownRecipes[i].asString());
1876 if (RecipeId != RecipeNameMap.end())
1895 FLOGD(
"Player \"{0}\" with save file \"{1}\" is spawning at {2:.2f} in world \"{3}\"",
1914 auto & Mob =
static_cast<cMonster &
>(*m_AttachedTo);
1916 if (Mob.GetMobType() !=
mtHorse)
1921 auto & Horse =
static_cast<cHorse &
>(Mob);
1935 const auto & UUID =
GetUUID();
1939 Json::Value JSON_PlayerPosition;
1940 JSON_PlayerPosition.append(Json::Value(
GetPosX()));
1941 JSON_PlayerPosition.append(Json::Value(
GetPosY()));
1942 JSON_PlayerPosition.append(Json::Value(
GetPosZ()));
1944 Json::Value JSON_PlayerRotation;
1945 JSON_PlayerRotation.append(Json::Value(
GetYaw()));
1946 JSON_PlayerRotation.append(Json::Value(
GetPitch()));
1947 JSON_PlayerRotation.append(Json::Value(
GetRoll()));
1949 Json::Value JSON_Inventory;
1952 Json::Value JSON_EnderChestInventory;
1955 Json::Value JSON_KnownItems;
1958 Json::Value JSON_Item;
1959 KnownItem.GetJson(JSON_Item);
1960 JSON_KnownItems.append(JSON_Item);
1963 Json::Value JSON_KnownRecipes;
1967 JSON_KnownRecipes.append(Recipe->m_RecipeName);
1971 root[
"position"] = JSON_PlayerPosition;
1972 root[
"rotation"] = JSON_PlayerRotation;
1973 root[
"inventory"] = JSON_Inventory;
1974 root[
"knownItems"] = JSON_KnownItems;
1975 root[
"knownRecipes"] = JSON_KnownRecipes;
1977 root[
"enderchestinventory"] = JSON_EnderChestInventory;
1987 root[
"lastknownname"] =
GetName();
1995 root[
"gamemode"] =
static_cast<int>(
m_GameMode);
2003 LOGWARNING(
"Error writing player \"%s\" to file \"%s\": cannot open file. Player will lose their progress",
2004 GetName().c_str(), SourceFile.c_str()
2008 if (f.
Write(JsonData.c_str(), JsonData.size()) !=
static_cast<int>(JsonData.size()))
2010 LOGWARNING(
"Error writing player \"%s\" to file \"%s\": cannot save data. Player will lose their progress",
2011 GetName().c_str(), SourceFile.c_str()
2025 LOGWARNING(
"Error writing player \"%s\" statistics to file",
GetName().c_str());
2054 short Dmg =
Item.GetHandler().GetDurabilityLossByAction(a_Action);
2075 ? (0.6 + (0.4 / (UnbreakingLevel + 1))) : (1.0 / (UnbreakingLevel + 1));
2079 std::binomial_distribution<short> Dist(a_Damage, chance);
2095 switch (a_SlotNumber)
2208 default:
return false;
2224 const auto Value = FloorC<StatisticsManager::StatValue>(a_DeltaPos.
Length() * 100 + 0.5);
2235 if (a_DeltaPos.
y > 0.0)
2273 if ((a_DeltaPos.
y > 0.0) && a_PreviousIsOnGround)
2278 else if (a_DeltaPos.
y < 0.0)
2329 for (
int y = a_BlockPos.
y - a_Range + 1; y < a_BlockPos.
y + a_Range; y++)
2331 for (
int z = a_BlockPos.
z - a_Range + 1; z < a_BlockPos.
z + a_Range; z++)
2333 for (
int x = a_BlockPos.
x - a_Range + 1; x < a_BlockPos.
x + a_Range; x++)
2343 LOGD(
"%s: Cannot query all blocks, not sending an update", __FUNCTION__);
2348 std::unordered_map<cChunkCoords, sSetBlockVector, cChunkCoordsHash> Changes;
2349 for (
const auto & blk: blks)
2351 Changes[
cChunkCoords(blk.m_ChunkX, blk.m_ChunkZ)].push_back(blk);
2356 for (
auto itr = Changes.cbegin(), end = Changes.cend(); itr != end; ++itr)
2358 m_ClientHandle->SendBlockChanges(itr->first.m_ChunkX, itr->first.m_ChunkZ, itr->second);
2369 std::vector<cBoundingBox> PlacementBoxes;
2371 bool HasInitializedBounds =
false;
2372 for (
auto blk: a_Blocks)
2385 BlockBox.
Move(x, y, z);
2387 PlacementBoxes.push_back(BlockBox);
2389 if (HasInitializedBounds)
2391 PlacingBounds = PlacingBounds.
Union(BlockBox);
2395 PlacingBounds = BlockBox;
2396 HasInitializedBounds =
true;
2403 return !
World->ForEachEntityInBox(PlacingBounds, [&](
cEntity & a_Entity)
2406 const double EPSILON = 0.0005;
2413 for (
auto BlockBox : PlacementBoxes)
2416 BlockBox.
Expand(-EPSILON, -EPSILON, -EPSILON);
2417 if (EntBox.DoesIntersect(BlockBox))
2442 return PlaceBlocks({ { a_Position, a_BlockType, a_BlockMeta } });
2454 for (
const auto & ResendBlock : a_Blocks)
2456 m_World->
SendBlockTo(ResendBlock.GetX(), ResendBlock.GetY(), ResendBlock.GetZ(), *
this);
2464 for (
const auto &
Block : a_Blocks)
2469 return cBlockHandler::For(Block.m_BlockType).CanBeAt(a_Chunk, Block.GetRelativePos(), Block.m_BlockMeta);
2479 for (
const auto & ResendBlock : a_Blocks)
2481 m_World->
SendBlockTo(ResendBlock.GetX(), ResendBlock.GetY(), ResendBlock.GetZ(), *
this);
2488 for (
const auto &
Block : a_Blocks)
2519 res.append(UUID, 0, 2);
2521 res.append(UUID, 2, AString::npos);
2522 res.append(
".json");
2571 return static_cast<float>(a_Meta + 1) / 9.0f;
2599 float f1 =
static_cast<float>(EyeHeight + 1) - f;
2600 return EyeHeight < f1;
2617 if (MiningSpeed > 1.0f)
2620 if (EfficiencyModifier > 0)
2622 MiningSpeed += (EfficiencyModifier * EfficiencyModifier) + 1;
2633 if (Haste !=
nullptr)
2635 int intensity = Haste->GetIntensity() + 1;
2636 MiningSpeed *= 1.0f + (intensity * 0.2f);
2641 if (MiningFatigue !=
nullptr)
2643 int intensity = MiningFatigue->GetIntensity();
2646 case 0: MiningSpeed *= 0.3f;
break;
2647 case 1: MiningSpeed *= 0.09f;
break;
2648 case 2: MiningSpeed *= 0.0027f;
break;
2649 default: MiningSpeed *= 0.00081f;
break;
2657 MiningSpeed /= 5.0f;
2663 MiningSpeed /= 5.0f;
2684 ASSERT(BlockHardness > 0);
2689 return GetDigSpeed(a_Block) / (20.0f * BlockHardness);
2716 if (!Response.second)
2724 for (
const auto & RecipeId : Recipes)
2737 if (!Response.second)
2787 else if ((
GetWorld()->GetWorldTickAge() % 100_tick) == 0_tick)
2809 const auto & UUID =
GetUUID();
2850 short ArmorDamage =
static_cast<short>(std::max(a_DamageBlocked / 4, 1));
2852 for (
int i = 0; i < 4; i++)
2951 return std::holds_alternative<BodyStanceCrouching>(
m_BodyStance);
2960 return std::holds_alternative<BodyStanceSprinting>(
m_BodyStance);
2969 return std::holds_alternative<BodyStanceGliding>(
m_BodyStance);
3051 for (
int x = PosX - 1; x <= (PosX + 1); ++x)
3053 for (
int y = PosY; y <= (PosY + 3); ++y)
3055 for (
int z = PosZ - 1; z <= (PosZ + 1); ++z)
3093 if (!
cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*
this))
3112 if (DestinationDimension ==
dimEnd)
3116 else if (DestinationDimension ==
dimNether)
3218 using namespace std::chrono_literals;
3220 auto & TicksFlying = std::get<BodyStanceGliding>(
m_BodyStance).TicksElytraFlying;
3221 const auto TotalFlew = TicksFlying + a_Dt;
3222 const auto Periods =
static_cast<short>(TotalFlew / 1s);
3223 TicksFlying = std::chrono::duration_cast<cTickTime>(TotalFlew - Periods * 1s);
3247 if ((
m_EatingFinishTick >= 0_tick) && (m_EatingFinishTick <= m_World->GetWorldAge()))
static int GetBlock(lua_State *a_LuaState)
Templated bindings for the GetBlock___() functions.
@ E_BLOCK_STATIONARY_WATER
#define PREPARE_REL_AND_CHUNK(Position, OriginalChunk)
std::vector< sSetBlock > sSetBlockVector
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
@ PawnOffHandEquipmentBreaks
@ PawnFeetEquipmentBreaks
@ PawnMainHandEquipmentBreaks
@ PawnLegsEquipmentBreaks
@ PawnHeadEquipmentBreaks
@ PawnChestEquipmentBreaks
eDamageType
Damage type, used in the TakeDamageInfo structure and related functions.
std::vector< int > cSlotNums
List of slot numbers, used for inventory-painting.
#define RESPAWN_FOOD_SATURATION
#define XP_PER_LEVEL_TO15
#define PLAYER_INVENTORY_SAVE_INTERVAL
MTRand & GetRandomProvider()
Returns the current thread's random number source.
T Clamp(T a_Value, T a_Min, T a_Max)
Clamp X to the specified range.
void LOGWARNING(std::string_view a_Format, const Args &... args)
void LOG(std::string_view a_Format, const Args &... args)
void LOGINFO(std::string_view a_Format, const Args &... args)
FileStream< std::ifstream > InputFileStream
AStringVector StringSplit(const AString &str, const AString &delim)
Split the string at any of the listed delimiters.
std::vector< AString > AStringVector
Vector3< double > Vector3d
bool IsArmor(short a_ItemType)
AString WriteStyledString(const Json::Value &a_Root)
Utilities to allow casting a cWorld to one of its interfaces without including World....
void Save(const StatisticsManager &Manager, const std::string &WorldPath, std::string &&FileName)
void Load(StatisticsManager &Manager, const std::string &WorldPath, std::string &&FileName)
static cPluginManager * Get(void)
Returns the instance of the Plugin Manager (there is only ever one)
bool CallHookPlayerCrouched(cPlayer &a_Player)
bool CallHookPlayerPlacingBlock(cPlayer &a_Player, const sSetBlock &a_BlockChange)
bool CallHookPlayerSpawned(cPlayer &a_Player)
bool CallHookPlayerPlacedBlock(cPlayer &a_Player, const sSetBlock &a_BlockChange)
static void LoadFromJson(const Json::Value &a_Value, cItemGrid &a_Grid)
static void SaveToJson(Json::Value &a_Value, const cItemGrid &a_Grid)
static float GetHardness(BLOCKTYPE Block)
Block's hardness.
static bool IsSolid(BLOCKTYPE Block)
Is this block solid (player cannot walk through)?
static bool IsOneHitDig(BLOCKTYPE Block)
Is a block destroyed after a single hit? Warning: IsOneHitDig does not take into account enchantments...
virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const
Returns the relative bounding box that must be entity-free in order for the block to be placed.
static const cBlockHandler & For(BLOCKTYPE a_BlockType)
Represents two sets of coords, minimum and maximum for each direction.
void Move(double a_OffX, double a_OffY, double a_OffZ)
Moves the entire boundingbox by the specified offset.
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 * ...
cBoundingBox Union(const cBoundingBox &a_Other)
Returns the union of the two bounding boxes.
static const char * Delimiter
bool IsValid(void) const
Returns true iff the chunk block data is valid (loaded / generated)
Wraps the chunk coords into a single structure.
static bool IsValidHeight(Vector3i a_BlockPosition)
Validates a height-coordinate.
void SendEntityHeadLook(const cEntity &a_Entity)
void SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem &a_Item)
void SendPlayerSpawn(const cPlayer &a_Player)
void SendEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item)
void SendPlayerPosition(void)
Container for a single chat message composed of multiple functional parts.
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 AddTextPart(const AString &a_Message, const AString &a_Style="")
Adds a plain text part, with optional style.
const std::map< AString, UInt32 > & GetRecipeNameMap()
Gets a map of all recipes with name and recipe id.
cRecipe * GetRecipeById(UInt32 a_RecipeId)
Returns the recipe by id.
std::vector< UInt32 > FindNewRecipesForItem(const cItem &a_Item, const std::set< cItem, cItem::sItemCompare > &a_KnownItems)
Find recipes and returns the RecipeIds which contain the new item and all ingredients are in the know...
unsigned int GetLevel(int a_EnchantmentID) const
Returns the level for the specified enchantment; 0 if not stored.
void SetPitch(double a_Pitch)
virtual void OnAddToWorld(cWorld &a_World)
Called when the entity is added to a world.
bool IsPlayer(void) const
cBoundingBox GetBoundingBox() const
void BroadcastDeathMessage(TakeDamageInfo &a_TDI)
Announces a death message on chat about killing the entity.
void SetRoll(double a_Roll)
virtual float GetEnchantmentBlastKnockbackReduction()
Returns explosion knock back reduction percent from blast protection level.
void Detach(void)
Detaches from the currently attached entity, if any.
virtual bool IsInWater(void) const
Returns true if any part of the entity is in a water block.
bool MoveToWorld(cWorld &a_World, Vector3d a_NewPosition, bool a_ShouldSetPortalCooldown=false, bool a_ShouldSendRespawn=true)
void SetYaw(double a_Yaw)
cChunk * GetParentChunk()
Returns the chunk responsible for ticking this entity.
float GetMaxHealth(void) const
virtual bool DoesPreventBlockPlacement(void) const
Returns whether blocks can be placed intersecting this entities' hitbox.
static const UInt32 INVALID_ID
Special ID that is considered an "invalid value", signifying no entity.
int m_AirLevel
Air level of a mobile.
double GetRoll(void) const
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
Sets the speed of the entity, measured in m / sec.
double GetPosX(void) const
sWorldChangeInfo m_WorldChangeInfo
If field m_NewWorld not nullptr, a world change is scheduled and a task is queued in the current worl...
void SetPosition(double a_PosX, double a_PosY, double a_PosZ)
double GetPosZ(void) const
UInt32 GetUniqueID(void) const
void OnAcquireSpectator(cPlayer &a_Player)
Called when a player begins spectating this entity.
void Destroy()
Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet.
bool IsWorldChangeScheduled() const
Returns true if a world change is scheduled to happen.
void SetInvulnerableTicks(int a_InvulnerableTicks)
Set the invulnerable ticks from the entity.
eEntityType GetEntityType(void) const
double GetPitch(void) const
double GetPosY(void) const
Vector3d m_Speed
Measured in meters / second (m / s)
bool m_IsHeadInWater
If the entity's head is in a water block.
void TakeDamage(cEntity &a_Attacker)
Makes this pawn take damage from an attack by a_Attacker.
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI)
Makes this entity take damage specified in the a_TDI.
void StopBurning(void)
Stops the entity from burning, resets all burning timers.
double GetYaw(void) const
float GetHealth(void) const
Returns the health of this entity.
void SetMaxHealth(float a_MaxHealth)
Sets the maximum value for the health.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
virtual void Heal(int a_HitPoints)
Heals the specified amount of HPs.
virtual bool IsRiding(void) const
void SetSize(float a_Width, float a_Height)
Update an entity's size, for example, on body stance changes.
Vector3d GetLookVector(void) const
void OnLoseSpectator(cPlayer &a_Player)
Called when a player stops spectating this entity.
virtual void BroadcastMovementUpdate(const cClientHandle *a_Exclude=nullptr)
Updates clients of changes in the entity.
cWorld * GetWorld(void) const
static const int MAX_AIR_LEVEL
Maximum air an entity can have.
cEntity * m_AttachedTo
The entity to which this entity is attached (vehicle), nullptr if none.
virtual bool IsInvisible() const override
cEntityEffect * GetEntityEffect(cEntityEffect::eType a_EffectType) const
Returns the entity effect, if it is currently applied or nullptr if not.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
virtual void OnRemoveFromWorld(cWorld &a_World) override
Called when the entity is removed from a world.
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
cTeam * UpdateTeam(void)
Forces the player to query the scoreboard for his team.
void SendMessage(const AString &a_Message)
void SendMessageWarning(const AString &a_Message)
std::string m_CurrentWorldName
The name of the world which the player currently resides in.
cClientHandle * GetClientHandle(void) const
bool m_IsFlightCapable
If this is true the player can fly.
void SendAboveActionBarMessage(const AString &a_Message)
void SetFlying(bool a_ShouldFly)
Starts or stops flying, broadcasting the state change.
const AString & GetName(void) const
int m_SkinParts
Displayed skin part bit mask.
bool m_IsFrozen
If true, we are locking m_Position to m_FrozenPosition.
const cSlotNums & GetInventoryPaintSlots(void) const
Returns the list of slots currently stored for inventory painting.
Vector3i GetLastBedPos(void) const
Gets the player's potential respawn position (named LastBedPos for compatibility reasons).
bool IsStanding() const
Returns true if a player is standing normally, that is, in a neutral pose.
void HandleFood(void)
Called in each tick to handle food-related processing.
void ClearInventoryPaintSlots(void)
Clears the list of slots that are being inventory-painted.
void UpdateMovementStats(const Vector3d &a_DeltaPos, bool a_PreviousIsOnGround)
Update movement-related statistics.
void AwardAchievement(CustomStatistic a_Ach)
Awards the player an achievement.
void HandleFloater(void)
Called in each tick if the player is fishing to make sure the floater dissapears when the player does...
AString GetColor(void) const
Returns the full color code to use for this player, based on their rank.
unsigned int m_TicksUntilNextSave
How long till the player's inventory will be saved Default save interval is #defined in PLAYER_INVENT...
std::string m_SpawnWorldName
The name of the world which the player respawns in upon death.
bool DoesPlacingBlocksIntersectEntity(std::initializer_list< sSetBlock > a_Blocks) const
Whether placing the given blocks would intersect any entitiy.
bool SetCurrentExperience(int a_XpTotal)
Sets the experience total Returns true on success "should" really only be called at init or player de...
std::variant< BodyStanceCrouching, BodyStanceSleeping, BodyStanceSprinting, BodyStanceStanding, BodyStanceGliding > m_BodyStance
The current body stance the player has adopted.
void LoadFromDisk()
Loads the player data from the save file.
void SendMessageInfo(const AString &a_Message)
bool IsFrozen()
Is the player frozen?
void AddInventoryPaintSlot(int a_SlotNum)
Adds a slot to the list for inventory painting.
double GetSprintingMaxSpeed(void) const
Gets the sprinting relative maximum speed.
double m_NormalMaxSpeed
Max speed, relative to the game default.
virtual cItem GetEquippedChestplate(void) const override
Returns the currently equipped chestplate; empty item if none.
void SetNormalMaxSpeed(double a_Speed)
Sets the normal relative maximum speed.
cWorld * GetRespawnWorld()
double m_FlyingMaxSpeed
Max speed, relative to the game default flying max speed, when flying.
void CloseWindow(bool a_CanRefuse=true)
Closes the current window, resets current window to m_InventoryWindow.
void RefreshRank()
(Re)loads the rank and permissions from the cRankManager.
const cUUID & GetUUID(void) const
Returns the UUID that has been read from the client, or nil if not available.
bool m_IsLeftHanded
Whether the player is left-handed, or right-handed.
virtual void Killed(const cEntity &a_Victim, eDamageType a_DamageType) override
Called when the entity kills another entity.
double m_SprintingMaxSpeed
Max speed, relative to the game default max speed, when sprinting.
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.
cItemGrid m_EnderChestContents
An item grid that stores the player specific enderchest contents.
bool PlaceBlocks(std::initializer_list< sSetBlock > a_Blocks)
Calls the block placement hooks and places the blocks in the world.
void TossItems(const cItems &a_Items)
Tosses a list of items.
const cItem & GetEquippedItem(void) const
void CancelChargingBow(void)
Cancels the current bow charging.
cPlayer(const std::shared_ptr< cClientHandle > &a_Client)
bool HasCustomName(void) const
Returns true if the player has a custom name.
bool Feed(int a_Food, double a_Saturation)
Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed,...
float GetXpPercentage(void) const
Gets the experience bar percentage - XpP.
void SpectateEntity(cEntity *a_Target)
Spectates the target entity.
void SendSystemMessage(const AString &a_Message)
void UpdateCapabilities()
Updates player's capabilities - flying, visibility, etc.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
void SendMessageFatal(const AString &a_Message)
void AbortEating(void)
Aborts the current eating operation.
static bool PermissionMatches(const AStringVector &a_Permission, const AStringVector &a_Template)
Returns true iff a_Permission matches the a_Template.
std::string m_DefaultWorldPath
The save path of the default world.
void SetIsFishing(bool a_IsFishing, UInt32 a_FloaterID=cEntity::INVALID_ID)
void SaveToDisk(void)
Saves all player data, such as inventory, to JSON.
virtual bool IsInvisible() const override
int FinishChargingBow(void)
Finishes charging the current bow.
void OpenWindow(cWindow &a_Window)
Opens the specified window; closes the current one first using CloseWindow()
void AddKnownItem(const cItem &a_Item)
Adds an Item to the list of known items.
double GetEyeHeight(void) const
float GetDigSpeed(BLOCKTYPE a_Block)
Returns the dig speed using the current tool on the block a_Block.
AStringVector m_Permissions
All the permissions that this player has, based on their rank.
bool IsGameModeSurvival(void) const
Returns true if the player is in Survival mode, either explicitly, or by inheriting from current worl...
virtual void ApplyArmorDamage(int DamageBlocked) override
Applies damage to the armor after the armor blocked the given amount.
void OpenHorseInventory()
Opens the inventory of any tame horse the player is riding.
std::set< cItem, cItem::sItemCompare > m_KnownItems
List of known items as Ids.
void TossPickup(const cItem &a_Item)
tosses a pickup newly created from a_Item
virtual bool IsElytraFlying(void) const override
void SendMessageFailure(const AString &a_Message)
void LoadRank(void)
(Re)loads the rank and permissions from the cRankManager and sends a permission level update to the c...
double m_FoodSaturationLevel
"Overcharge" for the m_FoodLevel; is depleted before m_FoodLevel
bool m_IsManuallyFrozen
Was the player frozen manually by a plugin or automatically by the server?
int DeltaExperience(int a_Xp_delta)
std::shared_ptr< cClientHandle > m_ClientHandle
double GetFlyingMaxSpeed(void) const
Gets the flying relative maximum speed.
void AddKnownRecipe(UInt32 RecipeId)
Add the recipe Id to the known recipes.
int m_FoodLevel
Represents the food bar, one point equals half a "drumstick".
void SetBedPos(Vector3i a_Position)
Sets the player's bed position to the specified position.
void SetFoodTickTimer(int a_FoodTickTimer)
AString GetSuffix(void) const
Returns the player name suffix, may contain @ format directives.
int GetXpLevel(void) const
Gets the current level - XpLevel.
void SetSprintingMaxSpeed(double a_Speed)
Sets the sprinting relative maximum speed.
virtual void Heal(int a_Health) override
Heals the player by the specified amount of HPs (positive only); sends health update.
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.
void SetFlyingMaxSpeed(double a_Speed)
Sets the flying relative maximum speed.
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...
static const int MAX_HEALTH
AString GetIP(void) const
virtual bool IsCrouched(void) const override
bool IsLeftHanded() const
Returns true if the player's left hand is dominant.
bool m_IsTeleporting
Flag used by food handling system to determine whether a teleport has just happened.
int m_LifetimeTotalXp
Player Xp level.
void TossEquippedItem(char a_Amount=1)
tosses the item in the selected hotbar slot
void StartChargingBow(void)
Starts charging the equipped bow.
static int CalcLevelFromXp(int a_CurrentXp)
Inverse of XpForLevel Ref: https://minecraft.wiki/w/XP values are as per this with pre-calculations.
cItem m_DraggingItem
The item being dragged by the cursor while in a UI window.
AString GetUUIDFileName(const cUUID &a_UUID)
Returns the filename for the player data based on the UUID given.
void SetDraggingItem(const cItem &a_Item)
In UI windows, set the item that the player is dragging.
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
unsigned int m_EnchantmentSeed
bool IsClimbing(void) const
Returns whether the player is climbing (ladders, vines etc.)
void SetRespawnPosition(Vector3i a_Position, const cWorld &a_World)
Sets the player's forced respawn position and world.
virtual ~cPlayer() override
cWindow * m_InventoryWindow
cTickTimeLong m_EatingFinishTick
The world tick in which eating will be finished.
cInventory & GetInventory(void)
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
void TossHeldItem(char a_Amount=1)
tosses the item held in hand (when in UI windows)
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override
Teleports to the coordinates specified.
void SetVisible(bool a_bVisible)
void FreezeInternal(const Vector3d &a_Location, bool a_ManuallyFrozen)
Pins the player to a_Location until Unfreeze() is called.
virtual void OnDetach() override
Called when this entity dismounts from m_AttachedTo.
cItem & GetDraggingItem(void)
In UI windows, get the item that the player is dragging.
virtual void BroadcastMovementUpdate(const cClientHandle *a_Exclude=nullptr) override
Updates clients of changes in the entity.
void AddFoodExhaustion(double a_Exhaustion)
Adds the specified exhaustion to m_FoodExhaustion.
bool CanMobsTarget(void) const
Returns true if the player can be targeted by Mobs.
void SetFoodLevel(int a_FoodLevel)
static const int MAX_FOOD_LEVEL
Vector3d GetThrowSpeed(double a_SpeedCoeff) const
Returns the initial speed vector of a throw, with a 3D length of a_SpeedCoeff.
void Freeze(const Vector3d &a_Location)
Prevent the player from moving and lock him into a_Location.
bool IsInBed(void) const
Returns true if a player is sleeping in a bed.
AStringVector m_Restrictions
All the restrictions that this player has, based on their rank.
cEntity * m_Spectating
The entity that this player is spectating, nullptr if none.
void PermuteEnchantmentSeed()
Permute the seed for enchanting related PRNGs, don't use this for other purposes.
void SetSkinParts(int a_Parts)
double GetNormalMaxSpeed(void) const
Gets the normal relative maximum speed.
bool IsGameModeSpectator(void) const
Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current wor...
void SetLeftHanded(bool a_IsLeftHanded)
Sets the dominant hand of the player.
int m_FoodTickTimer
Count-up to the healing or damaging action, based on m_FoodLevel.
bool CanInstantlyMine(BLOCKTYPE a_Block)
Given tool, enchantments, status effects, and world position returns whether a_Block would be instant...
bool HasPermission(const AString &a_Permission) const
bool IsFlying(void) const
Returns true if the player is currently flying.
bool IsInsideWater()
Checks if the player is inside of water.
void SendMessageSuccess(const AString &a_Message)
const std::set< UInt32 > & GetKnownRecipes() const
Gets the set of IDs for recipes this player has discovered.
void SetFoodExhaustionLevel(double a_FoodExhaustionLevel)
void SetTeam(cTeam *a_Team)
Sets the player team, nullptr if none.
void SetElytraFlight(bool a_ShouldElytraFly)
Starts or stops elytra flight, if our current body stance permits, broadcasting the state change.
AString m_Rank
The name of the rank assigned to this player.
virtual void OnAddToWorld(cWorld &a_World) override
Called when the entity is added to a world.
virtual float GetEnchantmentBlastKnockbackReduction() override
Returns explosion knock back reduction percent from blast protection level.
void SendMessageRaw(const AString &a_MessageRaw, eChatType a_Type=eChatType::ctChatBox)
cWindow * GetWindow(void)
void StartEating(void)
Starts eating the currently equipped item.
void SetCrouch(bool a_ShouldCrouch)
Starts or stops crouching, if our current body stance permits, broadcasting the state change.
void SendBlocksAround(Vector3i a_BlockPos, int a_Range=1)
Sends the block in the specified range around the specified coord to the client as a block change pac...
cInventory m_Inventory
Stores the player's inventory, consisting of crafting grid, hotbar, and main slots.
Vector3i m_RespawnPosition
The player's potential respawn position, initialised to world spawn by default.
cWindow * m_CurrentWindow
void SendMessagePrivateMsg(const AString &a_Message, const AString &a_Sender)
void ForceSetSpeed(const Vector3d &a_Speed)
Forces the player to move in the given direction.
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.
AStringVectorVector m_SplitRestrictions
All the restrictions that this player has, based on their rank, split into individual dot-delimited p...
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...
void SetFoodSaturationLevel(double a_FoodSaturationLevel)
Vector3d GetEyePosition(void) const
virtual bool IsSprinting(void) const override
bool IsSatiated(void) const
Returns true if the player is satiated, i.
Vector3d GetThrowStartPos(void) const
Returns the position where projectiles thrown by this player should start, player eye position + adju...
void SetSprint(bool a_ShouldSprint)
Starts or stops sprinting, if our current body stance permits, broadcasting the state change.
float GetLiquidHeightPercent(NIBBLETYPE a_Meta)
Returns how high the liquid is in percent.
AStringVectorVector m_SplitPermissions
All the permissions that this player has, based on their rank, split into individual dot-delimited pa...
void Unfreeze()
Cancels Freeze(...) and allows the player to move naturally.
void SetCustomName(const AString &a_CustomName)
Sets the custom name of this player.
AString GetPrefix(void) const
Returns the player name prefix, may contain @ format directives.
void ReplaceOneEquippedItemTossRest(const cItem &)
Removes one item from the the current equipped item stack, and attempts to add the specified item sta...
bool IsGameModeAdventure(void) const
Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current wor...
AString GetPlayerListName(void) const
Returns the name that is used in the playerlist.
void SetCanFly(bool a_CanFly)
If true the player can fly even when he's not in creative.
void SetTouchGround(bool a_bTouchGround)
virtual void OnRemoveFromWorld(cWorld &a_World) override
Called when the entity is removed from a world.
double m_FoodExhaustionLevel
A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel.
StatisticsManager m_Stats
MTRand GetEnchantmentRandomProvider()
Get a copy of the PRNG for enchanting related generation, don't use this for other purposes.
double GetMaxSpeed(void) const
Returns the current relative maximum speed (takes current sprinting / flying state into account)
void OnLoseSpectated()
Called when spectation stops, because the player crouched or when the entity we're spectating gets re...
virtual bool DoTakeDamage(TakeDamageInfo &TDI) override
Makes this entity take damage specified in the a_TDI.
static int XpForLevel(int a_Level)
Calculates the amount of XP needed for a given level Ref: https://minecraft.wiki/w/XP.
virtual bool IsOnGround(void) const override
Returns whether the entity is on ground or not.
void FinishEating(void)
Finishes eating the currently equipped item.
float GetMiningProgressPerTick(BLOCKTYPE a_Block)
Returns the progress mined per tick for the block a_Block as a fraction (1 would be completely mined)...
std::set< UInt32 > m_KnownRecipes
List on known recipes as Ids.
eGameMode GetEffectiveGameMode(void) const
Returns the current effective gamemode (inherited gamemode is resolved before returning)
void UseEquippedItem(short a_Damage=1)
Damage the player's equipped item by a_Damage, possibly less if the equipped item is enchanted.
cSlotNums m_InventoryPaintSlots
void SetIsInBed(bool a_IsInBed)
Sets a player's in-bed state.
bool m_IsRespawnPointForced
Whether we unconditionally respawn to m_RespawnPosition, or check if a bed is unobstructed and availa...
bool PlaceBlock(Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Attempts to place the block in the world with a call to PlaceBlocks.
AString m_MsgNameColorCode
void SetGameMode(eGameMode a_GameMode)
Sets the gamemode for the player.
Tag representing a sneaking pose.
BodyStanceCrouching(cPlayer &a_Player)
Tag representing a sleeping pose.
BodyStanceSleeping(cPlayer &a_Player)
Tag representing a sprinting pose.
Tag representing the neutral stance.
BodyStanceStanding(cPlayer &a_Player)
Tag representing a swimming or elytra flying pose.
BodyStanceGliding(cPlayer &a_Player)
Class to wrap any random engine to provide a more convenient interface.
IntType RandInt(IntType a_Min, IntType a_Max)
Return a random IntType in the range [a_Min, a_Max].
bool LoadFromJson(Json::Value &a_Value)
void UpdateItems(void)
Update items (e.g.
const cItem & GetEquippedChestplate(void) const
cItemGrid & GetHotbarGrid(void)
Returns the cItemGrid object representing the hotbar slots.
void CopyToItems(cItems &a_Items)
Copies the non-empty slots into a_ItemStacks; preserves the original a_Items contents.
void SetEquippedSlotNum(int a_SlotNum)
Sets equiped item to the a_SlotNum slot number.
void SaveToJson(Json::Value &a_Value)
const cItem & GetEquippedBoots(void) const
const cItem & GetSlot(int a_SlotNum) const
Returns current item in a_SlotNum slot.
const cItem & GetEquippedHelmet(void) const
void Clear(void)
Removes all items from the entire inventory.
int ReplaceOneEquippedItem(const cItem &a_Item, bool a_TryOtherSlots=true)
Removes one item from the the current equipped item stack, and attempts to add the specified item sta...
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.
int GetEquippedSlotNum(void)
Returns slot number of equiped item.
const cItem & GetEquippedItem(void) const
Returns current equiped item.
const cItem & GetEquippedLeggings(void) const
const cItemHandler & GetHandler(void) const
Returns the cItemHandler responsible for this item type.
cEnchantments m_Enchantments
bool IsEmpty(void) const
Returns true if the item represents an empty stack - either the type is invalid, or count is zero.
void Empty(void)
Empties the item and frees up any dynamic storage used by the internals.
cItem CopyOne(void) const
Returns a copy of this item with m_ItemCount set to 1.
This class bridges a vector of cItem for safe access via Lua.
void Add(const cItem &a_Item)
char ChangeSlotCount(int a_SlotNum, char a_AddToCount)
Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot.
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) const
Returns the strength to break a specific block.
eDurabilityLostAction
Actions that may cause durability of an item may be lost, where the magnitude of the loss depends on ...
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) const
Returns whether this tool / item can harvest a specific block (e.g.
void PlayerOpenWindow(cPlayer &a_Player)
eMonsterType GetMobType(void) const
static bool CreateFolderRecursive(const AString &a_FolderPath)
Creates a new folder with the specified name, creating its parents if needed.
bool Open(const AString &iFileName, eMode iMode)
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,...
AStringVector GetPlayerPermissions(const cUUID &a_PlayerUUID)
Returns the permissions that the specified player has assigned to them.
bool GetRankVisuals(const AString &a_RankName, AString &a_MsgPrefix, AString &a_MsgSuffix, AString &a_MsgNameColorCode)
Returns the message visuals of an existing rank.
const AString & GetDefaultRank(void) const
Returns the name of the default rank.
AString GetPlayerRankName(const cUUID &a_PlayerUUID)
Returns the name of the rank that the specified player has assigned to them.
bool UpdatePlayerName(const cUUID &a_PlayerUUID, const AString &a_NewPlayerName)
Updates the playername that is saved with this uuid.
AStringVector GetPlayerRestrictions(const cUUID &a_PlayerUUID)
Returns the restrictions that the specified player has assigned to them.
The root of the object hierarchy.
cServer * GetServer(void)
cWorld * GetDefaultWorld(void)
void BroadcastChatLeave(const AString &a_Message)
cCraftingRecipes * GetCraftingRecipes(void)
cPluginManager * GetPluginManager(void)
cWorld * GetWorld(const AString &a_WorldName)
Returns a pointer to the world specified.
void BroadcastPlayerListsRemovePlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr)
Broadcast playerlist removal through all worlds.
cRankManager * GetRankManager(void)
bool AllowsFriendlyFire(void) const
bool RemovePlayer(const AString &a_Name)
Removes a player from the team.
bool AddPlayer(const AString &a_Name)
Adds a new player to the team.
cTeam * QueryPlayerTeam(const AString &a_Name)
void AddPlayerScore(const AString &a_Name, cObjective::eType a_Type, cObjective::Score a_Value=1)
void SendTo(cClientHandle &a_Client)
Send this scoreboard to the specified client.
void PlayerDestroyed()
Notifies the server that a player is being destroyed; the server uses this to adjust the number of pl...
bool SatisfiesPrerequisite(CustomStatistic a_Stat) const
Returns whether the prerequisite for awarding an achievement are satisfied.
std::unordered_map< CustomStatistic, StatValue > Custom
virtual void OpenedByPlayer(cPlayer &a_Player)
virtual bool ClosedByPlayer(cPlayer &a_Player, bool a_CanRefuse)
Called when a player closes this window; notifies all slot areas.
char GetWindowID(void) const
void SendWholeWindow(cClientHandle &a_Client)
Sends the contents of the whole window to the specified client.
AString ToShortString() const
Converts the UUID to a short form string (i.e without dashes).
AString ToLongString() const
Converts the UUID to a long form string (i.e.
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.
Vector3< int > Floor(void) const
Returns a new Vector3i with coords set to std::floor() of this vector's coords.
double Length(void) const
void Set(T a_x, T a_y, T a_z)
double SqrLength(void) const
cScoreboard & GetScoreBoard(void)
Returns the associated scoreboard instance.
virtual void BroadcastPlayerListUpdateGameMode(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
void BroadcastEntityProperties(const cEntity &a_Entity)
void RemoveClientFromChunks(cClientHandle *a_Client)
Removes the client from all chunks it is present in.
int GetSpawnX(void) const
bool DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback)
Calls the callback for the chunk at the block position specified, with ChunkMapCS locked.
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastPlayerListAddPlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastEntityAnimation(const cEntity &a_Entity, EntityAnimation a_Animation, const cClientHandle *a_Exclude=nullptr) override
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
Returns the block type at the specified position.
virtual cTickTimeLong GetWorldAge(void) const override
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...
const AString & GetName(void) const
Returns the name of the world.
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Retrieves the block type and meta at the specified coords.
bool ShouldBroadcastAchievementMessages(void) const
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 GetSpawnZ(void) const
virtual eDimension GetDimension(void) const override
eGameMode GetGameMode(void) const
Returns the current game mode.
virtual void BroadcastSpawnEntity(cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual bool IsDaylightCycleEnabled(void) const
Is the daylight cycle enabled?
eWeather GetWeather(void) const
Returns the current weather.
void PlaceBlock(const Vector3i a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta)
Replaces the specified block with another, and calls the OnPlaced block handler.
virtual void BroadcastChat(const AString &a_Message, const cClientHandle *a_Exclude=nullptr, eMessageType a_ChatPrefix=mtCustom) 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.
virtual void SendBlockTo(int a_X, int a_Y, int a_Z, const cPlayer &a_Player) override
Sends the block at the specified coords to the player.
bool GetBlocks(sSetBlockVector &a_Blocks, bool a_ContinueOnFailure)
Retrieves block types of the specified blocks.
int GetSpawnY(void) const
cTickTimeLong GetWorldDate() const
cChunkMap * GetChunkMap(void)
virtual void BroadcastPlayerListRemovePlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override