6 #include "../BlockInfo.h"
7 #include "../Defines.h"
9 #include "../Entities/Boat.h"
10 #include "../Entities/ProjectileEntity.h"
11 #include "../Simulator/FluidSimulator.h"
12 #include "../Items/ItemSpawnEgg.h"
13 #include "../Items/ItemDye.h"
18 Super(a_BlockType, a_BlockMeta, a_Pos, a_World)
30 auto Meta = a_Chunk.
GetMeta(DispRelCoord);
33 if (DispChunk ==
nullptr)
40 auto DispAbsCoord = DispChunk->RelativeToAbsolute(DispRelCoord);
56 LOGD(
"Dispensing empty bucket in slot %d; DispBlock is \"%s\" (%d).", a_SlotNum,
ItemTypeToString(DispBlock).c_str(), DispBlock);
88 LOGD(
"Dispensing water bucket in slot %d; DispBlock is \"%s\" (%d).", a_SlotNum,
ItemTypeToString(DispBlock).c_str(), DispBlock);
102 LOGD(
"Dispensing lava bucket in slot %d; DispBlock is \"%s\" (%d).", a_SlotNum,
ItemTypeToString(DispBlock).c_str(), DispBlock);
116 double MobX = 0.5 + DispAbsCoord.x;
117 double MobZ = 0.5 + DispAbsCoord.z;
250 spawnPos +=
Vector3d(0.5, 0.5, 0.5);
283 a_Kind,
nullptr, a_Item, &a_ShootVector
302 LOGWARNING(
"Unhandled dispenser meta: %d", a_Meta);
303 ASSERT(!
"Unhandled dispenser facing");
313 cItem LiquidBucket(a_ResultingBucketItemType);
bool IsBlockWater(BLOCKTYPE a_BlockType)
bool IsBlockRail(BLOCKTYPE a_BlockType)
bool IsBlockLiquid(BLOCKTYPE a_BlockType)
AString ItemTypeToString(short a_ItemType)
Translates itemtype into a string.
@ 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
@ E_BLOCK_STATIONARY_LAVA
@ E_BLOCK_STATIONARY_WATER
@ E_ITEM_BOTTLE_O_ENCHANTING
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
void LOGWARNING(std::string_view a_Format, const Args &... args)
Vector3< double > Vector3d
bool IsMinecart(short a_ItemType)
Vector3i GetRelPos() const
cDispenserEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
Constructor used for normal operation.
static Vector3d GetShootVector(NIBBLETYPE a_BlockMeta)
Returns a unit vector in the cardinal direction of where the dispenser with the specified meta would ...
bool EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum)
If the a_BlockInFront can be washed away by liquid and the empty bucket can fit, does the m_Contents ...
bool ScoopUpLiquid(int a_SlotNum, short a_ResultingBucketItemType)
If such a bucket can fit, adds it to m_Contents and returns true.
virtual void DropSpenseFromSlot(cChunk &a_Chunk, int a_SlotNum) override
Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...
UInt32 SpawnProjectileFromDispenser(Vector3i a_BlockPos, cProjectileEntity::eKind a_Kind, const Vector3d &a_Speed, const cItem *a_Item=nullptr)
Spawns a projectile of the given kind in front of the dispenser with the specified speed.
void DropFromSlot(cChunk &a_Chunk, int a_SlotNum)
Helper function, drops one item from the specified slot (like a dropper)
void AddDropSpenserDir(Vector3i &a_RelCoord, NIBBLETYPE a_Direction)
Modifies the block coords to match the dropspenser direction given (where the dropspensed pickups sho...
static bool IsSolid(BLOCKTYPE Block)
Is this block solid (player cannot walk through)?
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
cChunk * GetRelNeighborChunkAdjustCoords(Vector3i &a_RelPos) const
Returns the chunk into which the relatively-specified block belongs.
static eMaterial ItemToMaterial(const cItem &a_Item)
Returns the eMaterial that should be used for a boat created from the specified item.
static const UInt32 INVALID_ID
Special ID that is considered an "invalid value", signifying no entity.
eKind
The kind of the projectile.
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.
void SetSlot(int a_X, int a_Y, const cItem &a_Item)
const cItem & GetSlot(int a_X, int a_Y) const
int HowManyCanFit(const cItem &a_ItemStack, bool a_AllowNewStacks=true)
Returns number of items out of a_ItemStack that can fit in the storage.
bool DamageItem(int a_SlotNum, short a_Amount)
Adds the specified damage to the specified item; returns true if the item broke (but the item is left...
char AddItem(cItem &a_ItemStack, bool a_AllowNewStacks=true, int a_PrioritySlot=-1)
Adds as many items out of a_ItemStack as can fit.
static bool FertilizePlant(cWorld &a_World, Vector3i a_BlockPos)
Attempts to use the bonemeal on the plant at the specified (absolute) position.
static eMonsterType ItemDamageToMonsterType(short a_ItemDamage)
Converts the Spawn egg item damage to the monster type to spawn.
static bool CanWashAway(BLOCKTYPE a_BlockType)
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.
UInt32 SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec=80, double a_InitialVelocityCoeff=1, bool a_ShouldPlayFuseSound=true)
virtual UInt32 SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType, bool a_Baby=false) override
Spawns a mob of the specified type.
UInt32 SpawnBoat(double a_X, double a_Y, double a_Z, cBoat::eMaterial a_Material)
UInt32 SpawnMinecart(Vector3d a_Pos, int a_MinecartType, const cItem &a_Content=cItem(), int a_BlockHeight=1)
Spawns an minecart at the given coordinates.
UInt32 CreateProjectile(Vector3d a_Pos, cProjectileEntity::eKind a_Kind, cEntity *a_Creator, const cItem *a_Item, const Vector3d *a_Speed=nullptr)
Creates a projectile of the specified type.