9 #include "../Bindings/PluginManager.h"
10 #include "../EffectID.h"
11 #include "../Entities/Player.h"
13 #include "../UI/DropSpenserWindow.h"
20 Super(a_BlockType, a_BlockMeta, a_Pos, ContentsWidth, ContentsHeight, a_World),
21 m_ShouldDropSpense(false)
40 LOGWARNING(
"%s: Unhandled direction: %d", __FUNCTION__, a_Direction);
50 std::array<int, 9> OccupiedSlots;
56 OccupiedSlots[SlotsCnt] = i;
69 const int SpenseSlot = OccupiedSlots[RandomSlot];
124 if (Window !=
nullptr)
127 Window->OwnerDestroyed();
174 if (Window ==
nullptr)
180 if (Window !=
nullptr)
204 int PickupSpeedX = 0, PickupSpeedY = 0, PickupSpeedZ = 0;
215 double MicroX, MicroY, MicroZ;
216 MicroX = dispCoord.
x + 0.5;
217 MicroY = dispCoord.
y + 0.4;
218 MicroZ = dispCoord.
z + 0.5;
@ E_META_DROPSPENSER_FACING_ZM
@ E_META_DROPSPENSER_FACING_XM
@ E_META_DROPSPENSER_FACING_YP
@ E_META_DROPSPENSER_FACING_YM
@ E_META_DROPSPENSER_FACING_ZP
@ E_META_DROPSPENSER_FACING_XP
@ E_META_DROPSPENSER_FACING_MASK
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
void LOGWARNING(std::string_view a_Format, const Args &... args)
static cPluginManager * Get(void)
Returns the instance of the Plugin Manager (there is only ever one)
BLOCKTYPE m_BlockType
The blocktype representing this particular instance in the world.
Vector3i GetRelPos() 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.
virtual void DropSpenseFromSlot(cChunk &a_Chunk, int a_SlotNum)=0
Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
void DropFromSlot(cChunk &a_Chunk, int a_SlotNum)
Helper function, drops one item from the specified slot (like a dropper)
void DropSpense(cChunk &a_Chunk)
Does the actual work on dropspensing an item.
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
void Activate(void)
Sets the dropspenser to dropspense an item in the next tick.
cDropSpenserEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
bool m_ShouldDropSpense
If true, the dropspenser will dropspense an item in the next tick.
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.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
virtual void OnRemoveFromWorld() override
Called when the block entity object is removed from a world.
void AddDropSpenserDir(Vector3i &a_RelCoord, NIBBLETYPE a_Direction)
Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups sho...
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
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()
cWindow * GetWindow(void)
IntType RandInt(IntType a_Min, IntType a_Max)
Return a random IntType in the range [a_Min, a_Max].
bool IsEmpty(void) const
Returns true if the item represents an empty stack - either the type is invalid, or count is zero.
This class bridges a vector of cItem for safe access via Lua.
void CopyFrom(const cItemGrid &a_Src)
Copies all items from a_Src to this grid.
const cItem & GetSlot(int a_X, int a_Y) const
int GetNumSlots(void) const
cItem RemoveOneItem(int a_SlotNum)
Removes one item from the stack in the specified slot, and returns it.
std::unordered_map< CustomStatistic, StatValue > Custom
cWindow * GetWindow(void) const
void OpenWindow(cWindow *a_Window)
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle *a_Exclude=nullptr) 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 BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override