5 #include "../BlockInfo.h"
6 #include "../BlockArea.h"
7 #include "../Entities/Player.h"
8 #include "../UI/BeaconWindow.h"
9 #include "../ClientHandle.h"
16 Super(a_BlockType, a_BlockMeta, a_Pos, 1, 1, a_World),
36 int MinY = std::max(
GetPosY() - 4, 0);
37 int MaxY = std::max(
GetPosY() - 1, 0);
50 for (
int Y = (Area.
GetSizeY() - 1); Y >= 0; Y--)
52 for (
int X = MiddleXZ - Layer; X <= (MiddleXZ + Layer); X++)
54 for (
int Z = MiddleXZ - Layer; Z <= (MiddleXZ + Layer); Z++)
58 return static_cast<char>(Layer - 1);
65 return static_cast<char>(Layer - 1);
86 LOGD(
"%s: Invalid beacon effect: %d", __FUNCTION__,
static_cast<int>(a_Effect));
209 a_Player.AwardAchievement(CustomStatistic::AchFullBeacon);
228 double Radius =
static_cast<double>(
m_BeaconLevel) * 10 + 10;
229 short EffectLevel = 0;
244 auto & Player =
static_cast<cPlayer &
>(a_Entity);
247 if (HasSecondaryEffect)
277 if (Window !=
nullptr)
280 Window->OwnerDestroyed();
299 using namespace std::chrono_literals;
302 if ((
GetWorld()->GetWorldTickAge() % 4s) == 0s)
319 if (Window ==
nullptr)
325 if (Window !=
nullptr)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
unsigned char Distance(const BlockState Block)
BLOCKTYPE GetRelBlockType(int a_RelX, int a_RelY, int a_RelZ) const
bool Read(cForEachChunkProvider &a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes=baTypes|baMetas|baBlockEntities)
Reads an area of blocks specified.
bool SetPrimaryEffect(cEntityEffect::eType a_Effect)
Sets the primary effect.
void UpdateBeacon(void)
Update the beacon.
virtual void OnRemoveFromWorld() override
Called when the block entity object is removed from a world.
virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking.
static bool IsMineralBlock(BLOCKTYPE a_BlockType)
Returns true if the block is a diamond block, a golden block, an iron block or an emerald block.
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
cEntityEffect::eType m_PrimaryEffect
char CalculatePyramidLevel(void)
Calculate the amount of layers the pyramid below the beacon has.
static bool IsValidEffect(cEntityEffect::eType a_Effect, char a_BeaconLevel)
Returns true if the effect can be used.
void GiveEffects(void)
Give the near-players the effects.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
bool IsBeaconBlocked(void)
Is the beacon blocked by non-transparent blocks that are higher than the beacon?
cEntityEffect::eType m_SecondaryEffect
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
bool SetSecondaryEffect(cEntityEffect::eType a_Effect)
Sets the secondary effect.
cBeaconEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
cWorld * GetWorld() const
Vector3i m_Pos
Position in absolute block coordinates.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
static bool IsTransparent(BLOCKTYPE Block)
Is a block transparent? (https://minecraft.wiki/w/Opacity)
Represents two sets of coords, minimum and maximum for each direction.
void SendUpdateBlockEntity(cBlockEntity &a_BlockEntity)
bool IsPlayer(void) const
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
eType
All types of entity effects (numbers correspond to protocol / storage types)
void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier=1)
Applies an entity effect.
StatisticsManager & GetStatistics()
Return the associated statistic and achievement manager.
void OpenWindow(cWindow &a_Window)
Opens the specified window; closes the current one first using CloseWindow()
void CopyFrom(const cItemGrid &a_Src)
Copies all items from a_Src to this grid.
std::unordered_map< CustomStatistic, StatValue > Custom
virtual void SetProperty(size_t a_Property, short a_Value)
Updates a numerical property associated with the window.
cWindow * GetWindow(void) const
void OpenWindow(cWindow *a_Window)
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
Returns the block type at the specified position.
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.
virtual bool ForEachPlayer(cPlayerListCallback a_Callback) override
Calls the callback for each player in the list; returns true if all players processed,...