Changed cEntity::m_UniqueID to UInt32.
This commit is contained in:
parent
b1d4b3bb96
commit
cc069ccb2a
@ -590,7 +590,7 @@ static int tolua_DoWith(lua_State* tolua_S)
|
|||||||
template <
|
template <
|
||||||
class Ty1,
|
class Ty1,
|
||||||
class Ty2,
|
class Ty2,
|
||||||
bool (Ty1::*Func1)(int, cItemCallback<Ty2> &)
|
bool (Ty1::*Func1)(UInt32, cItemCallback<Ty2> &)
|
||||||
>
|
>
|
||||||
static int tolua_DoWithID(lua_State* tolua_S)
|
static int tolua_DoWithID(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
@ -3867,6 +3867,10 @@ void ManualBindings::Bind(lua_State * tolua_S)
|
|||||||
BindRankManager(tolua_S);
|
BindRankManager(tolua_S);
|
||||||
BindNetwork(tolua_S);
|
BindNetwork(tolua_S);
|
||||||
|
|
||||||
|
tolua_beginmodule(tolua_S, "cEntity");
|
||||||
|
tolua_constant(tolua_S, "INVALID_ID", cEntity::INVALID_ID);
|
||||||
|
tolua_endmodule(tolua_S);
|
||||||
|
|
||||||
tolua_endmodule(tolua_S);
|
tolua_endmodule(tolua_S);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
|
|||||||
{
|
{
|
||||||
double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
|
double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
|
||||||
double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
|
double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
|
||||||
if (m_World->SpawnMob(MobX, DispY, MobZ, static_cast<eMonsterType>(m_Contents.GetSlot(a_SlotNum).m_ItemDamage)) >= 0)
|
if (m_World->SpawnMob(MobX, DispY, MobZ, static_cast<eMonsterType>(m_Contents.GetSlot(a_SlotNum).m_ItemDamage)) != cEntity::INVALID_ID)
|
||||||
{
|
{
|
||||||
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
||||||
}
|
}
|
||||||
@ -144,29 +144,37 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
|
|||||||
|
|
||||||
case E_ITEM_FIRE_CHARGE:
|
case E_ITEM_FIRE_CHARGE:
|
||||||
{
|
{
|
||||||
SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkFireCharge, GetShootVector(Meta) * 20);
|
if (SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkFireCharge, GetShootVector(Meta) * 20) != cEntity::INVALID_ID)
|
||||||
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
{
|
||||||
|
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case E_ITEM_ARROW:
|
case E_ITEM_ARROW:
|
||||||
{
|
{
|
||||||
SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkArrow, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0));
|
if (SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkArrow, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0)) != cEntity::INVALID_ID)
|
||||||
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
{
|
||||||
|
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case E_ITEM_SNOWBALL:
|
case E_ITEM_SNOWBALL:
|
||||||
{
|
{
|
||||||
SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkSnowball, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0));
|
if (SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkSnowball, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0)) != cEntity::INVALID_ID)
|
||||||
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
{
|
||||||
|
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case E_ITEM_EGG:
|
case E_ITEM_EGG:
|
||||||
{
|
{
|
||||||
SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkEgg, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0));
|
if (SpawnProjectileFromDispenser(BlockX, DispY, BlockZ, cProjectileEntity::pkEgg, GetShootVector(Meta) * 20 + Vector3d(0, 1, 0)) != cEntity::INVALID_ID)
|
||||||
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
{
|
||||||
|
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,9 +196,14 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cDispenserEntity::SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_ShootVector)
|
UInt32 cDispenserEntity::SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_ShootVector)
|
||||||
{
|
{
|
||||||
m_World->CreateProjectile(static_cast<double>(a_BlockX + 0.5), static_cast<double>(a_BlockY + 0.5), static_cast<double>(a_BlockZ + 0.5), a_Kind, nullptr, nullptr, &a_ShootVector);
|
return m_World->CreateProjectile(
|
||||||
|
static_cast<double>(a_BlockX + 0.5),
|
||||||
|
static_cast<double>(a_BlockY + 0.5),
|
||||||
|
static_cast<double>(a_BlockZ + 0.5),
|
||||||
|
a_Kind, nullptr, nullptr, &a_ShootVector
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,8 +24,9 @@ public:
|
|||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
/** Spawns a projectile of the given kind in front of the dispenser with the specified speed. */
|
/** Spawns a projectile of the given kind in front of the dispenser with the specified speed.
|
||||||
void SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_Speed);
|
Returns the UniqueID of the spawned projectile, or 0 on failure. */
|
||||||
|
UInt32 SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_Speed);
|
||||||
|
|
||||||
/** Returns a unit vector in the cardinal direction of where the dispenser is facing. */
|
/** Returns a unit vector in the cardinal direction of where the dispenser is facing. */
|
||||||
Vector3d GetShootVector(NIBBLETYPE a_Meta);
|
Vector3d GetShootVector(NIBBLETYPE a_Meta);
|
||||||
|
@ -169,7 +169,7 @@ void cMobSpawnerEntity::SpawnEntity(void)
|
|||||||
|
|
||||||
Monster->SetPosition(PosX, RelY, PosZ);
|
Monster->SetPosition(PosX, RelY, PosZ);
|
||||||
Monster->SetYaw(Random.NextFloat() * 360.0f);
|
Monster->SetYaw(Random.NextFloat() * 360.0f);
|
||||||
if (Chunk->GetWorld()->SpawnMobFinalize(Monster) != mtInvalidType)
|
if (Chunk->GetWorld()->SpawnMobFinalize(Monster) != cEntity::INVALID_ID)
|
||||||
{
|
{
|
||||||
EntitiesSpawned = true;
|
EntitiesSpawned = true;
|
||||||
Chunk->BroadcastSoundParticleEffect(2004, (int)(PosX * 8.0), (int)(RelY * 8.0), (int)(PosZ * 8.0), 0);
|
Chunk->BroadcastSoundParticleEffect(2004, (int)(PosX * 8.0), (int)(RelY * 8.0), (int)(PosZ * 8.0), 0);
|
||||||
|
@ -30,14 +30,16 @@ public:
|
|||||||
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
|
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
|
||||||
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) = 0;
|
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) = 0;
|
||||||
|
|
||||||
/** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified: */
|
/** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified. */
|
||||||
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) = 0;
|
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) = 0;
|
||||||
|
|
||||||
/** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */
|
/** Spawns a mob of the specified type.
|
||||||
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) = 0;
|
Returns the mob's UniqueID if recognized and spawned, or cEntity::INVALID_ID on failure. */
|
||||||
|
virtual UInt32 SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) = 0;
|
||||||
|
|
||||||
/** Spawns an experience orb at the given location with the given reward. It returns the UniqueID of the spawned experience orb. */
|
/** Spawns an experience orb at the given location with the given reward.
|
||||||
virtual int SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) = 0;
|
Returns the UniqueID of the spawned experience orb, or cEntity::INVALID_ID on failure. */
|
||||||
|
virtual UInt32 SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) = 0;
|
||||||
|
|
||||||
/** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */
|
/** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */
|
||||||
virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) = 0;
|
virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) = 0;
|
||||||
|
@ -1969,7 +1969,7 @@ void cChunk::RemoveEntity(cEntity * a_Entity)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChunk::HasEntity(int a_EntityID)
|
bool cChunk::HasEntity(UInt32 a_EntityID)
|
||||||
{
|
{
|
||||||
for (cEntityList::const_iterator itr = m_Entities.begin(), end = m_Entities.end(); itr != end; ++itr)
|
for (cEntityList::const_iterator itr = m_Entities.begin(), end = m_Entities.end(); itr != end; ++itr)
|
||||||
{
|
{
|
||||||
@ -2027,7 +2027,7 @@ bool cChunk::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChunk::DoWithEntityByID(int a_EntityID, cEntityCallback & a_Callback, bool & a_CallbackResult)
|
bool cChunk::DoWithEntityByID(UInt32 a_EntityID, cEntityCallback & a_Callback, bool & a_CallbackResult)
|
||||||
{
|
{
|
||||||
// The entity list is locked by the parent chunkmap's CS
|
// The entity list is locked by the parent chunkmap's CS
|
||||||
for (cEntityList::iterator itr = m_Entities.begin(), end = m_Entities.end(); itr != end; ++itr)
|
for (cEntityList::iterator itr = m_Entities.begin(), end = m_Entities.end(); itr != end; ++itr)
|
||||||
|
@ -241,7 +241,7 @@ public:
|
|||||||
|
|
||||||
void AddEntity(cEntity * a_Entity);
|
void AddEntity(cEntity * a_Entity);
|
||||||
void RemoveEntity(cEntity * a_Entity);
|
void RemoveEntity(cEntity * a_Entity);
|
||||||
bool HasEntity(int a_EntityID);
|
bool HasEntity(UInt32 a_EntityID);
|
||||||
|
|
||||||
/** Calls the callback for each entity; returns true if all entities processed, false if the callback aborted by returning true */
|
/** Calls the callback for each entity; returns true if all entities processed, false if the callback aborted by returning true */
|
||||||
bool ForEachEntity(cEntityCallback & a_Callback); // Lua-accessible
|
bool ForEachEntity(cEntityCallback & a_Callback); // Lua-accessible
|
||||||
@ -251,7 +251,7 @@ public:
|
|||||||
bool ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_Callback); // Lua-accessible
|
bool ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. Returns true if entity found. */
|
/** Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. Returns true if entity found. */
|
||||||
bool DoWithEntityByID(int a_EntityID, cEntityCallback & a_Callback, bool & a_CallbackResult); // Lua-accessible
|
bool DoWithEntityByID(UInt32 a_EntityID, cEntityCallback & a_Callback, bool & a_CallbackResult); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for each block entity; returns true if all block entities processed, false if the callback aborted by returning true */
|
/** Calls the callback for each block entity; returns true if all block entities processed, false if the callback aborted by returning true */
|
||||||
bool ForEachBlockEntity(cBlockEntityCallback & a_Callback); // Lua-accessible
|
bool ForEachBlockEntity(cBlockEntityCallback & a_Callback); // Lua-accessible
|
||||||
|
@ -373,19 +373,19 @@ void cChunkMap::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, c
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunkMap::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
|
void cChunkMap::BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSLayers);
|
cCSLock Lock(m_CSLayers);
|
||||||
int ChunkX, ChunkZ;
|
int ChunkX, ChunkZ;
|
||||||
|
|
||||||
cChunkDef::BlockToChunk(a_blockX, a_blockZ, ChunkX, ChunkZ);
|
cChunkDef::BlockToChunk(a_BlockX, a_BlockZ, ChunkX, ChunkZ);
|
||||||
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ChunkZ);
|
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ChunkZ);
|
||||||
if (Chunk == nullptr)
|
if (Chunk == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// It's perfectly legal to broadcast packets even to invalid chunks!
|
// It's perfectly legal to broadcast packets even to invalid chunks!
|
||||||
Chunk->BroadcastBlockBreakAnimation(a_entityID, a_blockX, a_blockY, a_blockZ, a_stage, a_Exclude);
|
Chunk->BroadcastBlockBreakAnimation(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage, a_Exclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1753,7 +1753,7 @@ void cChunkMap::AddEntityIfNotPresent(cEntity * a_Entity)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChunkMap::HasEntity(int a_UniqueID)
|
bool cChunkMap::HasEntity(UInt32 a_UniqueID)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSLayers);
|
cCSLock Lock(m_CSLayers);
|
||||||
for (cChunkLayerList::const_iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr)
|
for (cChunkLayerList::const_iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr)
|
||||||
@ -2045,7 +2045,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChunkMap::DoWithEntityByID(int a_UniqueID, cEntityCallback & a_Callback)
|
bool cChunkMap::DoWithEntityByID(UInt32 a_UniqueID, cEntityCallback & a_Callback)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSLayers);
|
cCSLock Lock(m_CSLayers);
|
||||||
bool res = false;
|
bool res = false;
|
||||||
@ -2996,7 +2996,7 @@ bool cChunkMap::cChunkLayer::ForEachEntity(cEntityCallback & a_Callback)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChunkMap::cChunkLayer::DoWithEntityByID(int a_EntityID, cEntityCallback & a_Callback, bool & a_CallbackReturn)
|
bool cChunkMap::cChunkLayer::DoWithEntityByID(UInt32 a_EntityID, cEntityCallback & a_Callback, bool & a_CallbackReturn)
|
||||||
{
|
{
|
||||||
// Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. Returns true if entity found.
|
// Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. Returns true if entity found.
|
||||||
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++)
|
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++)
|
||||||
@ -3016,7 +3016,7 @@ bool cChunkMap::cChunkLayer::DoWithEntityByID(int a_EntityID, cEntityCallback &
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChunkMap::cChunkLayer::HasEntity(int a_EntityID)
|
bool cChunkMap::cChunkLayer::HasEntity(UInt32 a_EntityID)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++)
|
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++)
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
// (Please keep these alpha-sorted)
|
// (Please keep these alpha-sorted)
|
||||||
void BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle);
|
void BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle);
|
||||||
void BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
|
void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
|
||||||
void BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
|
||||||
@ -217,7 +217,7 @@ public:
|
|||||||
void AddEntityIfNotPresent(cEntity * a_Entity);
|
void AddEntityIfNotPresent(cEntity * a_Entity);
|
||||||
|
|
||||||
/** Returns true if the entity with specified ID is present in the chunks */
|
/** Returns true if the entity with specified ID is present in the chunks */
|
||||||
bool HasEntity(int a_EntityID);
|
bool HasEntity(UInt32 a_EntityID);
|
||||||
|
|
||||||
/** Removes the entity from its appropriate chunk */
|
/** Removes the entity from its appropriate chunk */
|
||||||
void RemoveEntity(cEntity * a_Entity);
|
void RemoveEntity(cEntity * a_Entity);
|
||||||
@ -236,61 +236,80 @@ public:
|
|||||||
/** Destroys and returns a list of blocks destroyed in the explosion at the specified coordinates */
|
/** Destroys and returns a list of blocks destroyed in the explosion at the specified coordinates */
|
||||||
void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, cVector3iArray & a_BlockAffected);
|
void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, cVector3iArray & a_BlockAffected);
|
||||||
|
|
||||||
/** Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. Returns true if entity found and callback returned false. */
|
/** Calls the callback if the entity with the specified ID is found, with the entity object as the callback param.
|
||||||
bool DoWithEntityByID(int a_UniqueID, cEntityCallback & a_Callback); // Lua-accessible
|
Returns true if entity found and callback returned false. */
|
||||||
|
bool DoWithEntityByID(UInt32 a_EntityID, cEntityCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for each block entity in the specified chunk; returns true if all block entities processed, false if the callback aborted by returning true */
|
/** Calls the callback for each block entity in the specified chunk.
|
||||||
|
Returns true if all block entities processed, false if the callback aborted by returning true. */
|
||||||
bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback & a_Callback); // Lua-accessible
|
bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for each chest in the specified chunk; returns true if all chests processed, false if the callback aborted by returning true */
|
/** Calls the callback for each chest in the specified chunk.
|
||||||
|
Returns true if all chests processed, false if the callback aborted by returning true. */
|
||||||
bool ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback & a_Callback); // Lua-accessible
|
bool ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for each dispenser in the specified chunk; returns true if all dispensers processed, false if the callback aborted by returning true */
|
/** Calls the callback for each dispenser in the specified chunk.
|
||||||
|
Returns true if all dispensers processed, false if the callback aborted by returning true. */
|
||||||
bool ForEachDispenserInChunk(int a_ChunkX, int a_ChunkZ, cDispenserCallback & a_Callback);
|
bool ForEachDispenserInChunk(int a_ChunkX, int a_ChunkZ, cDispenserCallback & a_Callback);
|
||||||
|
|
||||||
/** Calls the callback for each dropper in the specified chunk; returns true if all droppers processed, false if the callback aborted by returning true */
|
/** Calls the callback for each dropper in the specified chunk.
|
||||||
|
Returns true if all droppers processed, false if the callback aborted by returning true. */
|
||||||
bool ForEachDropperInChunk(int a_ChunkX, int a_ChunkZ, cDropperCallback & a_Callback);
|
bool ForEachDropperInChunk(int a_ChunkX, int a_ChunkZ, cDropperCallback & a_Callback);
|
||||||
|
|
||||||
/** Calls the callback for each dropspenser in the specified chunk; returns true if all dropspensers processed, false if the callback aborted by returning true */
|
/** Calls the callback for each dropspenser in the specified chunk.
|
||||||
|
Returns true if all dropspensers processed, false if the callback aborted by returning true. */
|
||||||
bool ForEachDropSpenserInChunk(int a_ChunkX, int a_ChunkZ, cDropSpenserCallback & a_Callback);
|
bool ForEachDropSpenserInChunk(int a_ChunkX, int a_ChunkZ, cDropSpenserCallback & a_Callback);
|
||||||
|
|
||||||
/** Calls the callback for each furnace in the specified chunk; returns true if all furnaces processed, false if the callback aborted by returning true */
|
/** Calls the callback for each furnace in the specified chunk.
|
||||||
|
Returns true if all furnaces processed, false if the callback aborted by returning true. */
|
||||||
bool ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback & a_Callback); // Lua-accessible
|
bool ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */
|
/** Calls the callback for the block entity at the specified coords.
|
||||||
|
Returns false if there's no block entity at those coords, true if found. */
|
||||||
bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback); // Lua-acessible
|
bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback); // Lua-acessible
|
||||||
|
|
||||||
/** Calls the callback for the beacon at the specified coords; returns false if there's no beacon at those coords, true if found */
|
/** Calls the callback for the beacon at the specified coords.
|
||||||
|
Returns false if there's no beacon at those coords, true if found. */
|
||||||
bool DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback & a_Callback); // Lua-acessible
|
bool DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback & a_Callback); // Lua-acessible
|
||||||
|
|
||||||
/** Calls the callback for the chest at the specified coords; returns false if there's no chest at those coords, true if found */
|
/** Calls the callback for the chest at the specified coords.
|
||||||
|
Returns false if there's no chest at those coords, true if found. */
|
||||||
bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback); // Lua-acessible
|
bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback); // Lua-acessible
|
||||||
|
|
||||||
/** Calls the callback for the dispenser at the specified coords; returns false if there's no dispenser at those coords or callback returns true, returns true if found */
|
/** Calls the callback for the dispenser at the specified coords.
|
||||||
|
Returns false if there's no dispenser at those coords or callback returns true, returns true if found. */
|
||||||
bool DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback & a_Callback); // Lua-accessible
|
bool DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for the dropper at the specified coords; returns false if there's no dropper at those coords or callback returns true, returns true if found */
|
/** Calls the callback for the dropper at the specified coords.
|
||||||
|
Returns false if there's no dropper at those coords or callback returns true, returns true if found. */
|
||||||
bool DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperCallback & a_Callback); // Lua-accessible
|
bool DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for the dropspenser at the specified coords; returns false if there's no dropspenser at those coords or callback returns true, returns true if found */
|
/** Calls the callback for the dropspenser at the specified coords.
|
||||||
|
Returns false if there's no dropspenser at those coords or callback returns true, returns true if found. */
|
||||||
bool DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserCallback & a_Callback); // Lua-accessible
|
bool DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for the furnace at the specified coords; returns false if there's no furnace at those coords or callback returns true, returns true if found */
|
/** Calls the callback for the furnace at the specified coords.
|
||||||
|
Returns false if there's no furnace at those coords or callback returns true, returns true if found. */
|
||||||
bool DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback & a_Callback); // Lua-accessible
|
bool DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for the noteblock at the specified coords; returns false if there's no noteblock at those coords or callback returns true, returns true if found */
|
/** Calls the callback for the noteblock at the specified coords.
|
||||||
|
Returns false if there's no noteblock at those coords or callback returns true, returns true if found. */
|
||||||
bool DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback & a_Callback); // Lua-accessible
|
bool DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for the command block at the specified coords; returns false if there's no command block at those coords or callback returns true, returns true if found */
|
/** Calls the callback for the command block at the specified coords.
|
||||||
|
Returns false if there's no command block at those coords or callback returns true, returns true if found. */
|
||||||
bool DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback & a_Callback); // Lua-accessible
|
bool DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for the mob head block at the specified coords; returns false if there's no mob head block at those coords or callback returns true, returns true if found */
|
/** Calls the callback for the mob head block at the specified coords.
|
||||||
|
Returns false if there's no mob head block at those coords or callback returns true, returns true if found. */
|
||||||
bool DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadCallback & a_Callback); // Lua-accessible
|
bool DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback for the flower pot at the specified coords; returns false if there's no flower pot at those coords or callback returns true, returns true if found */
|
/** Calls the callback for the flower pot at the specified coords.
|
||||||
|
Returns false if there's no flower pot at those coords or callback returns true, returns true if found. */
|
||||||
bool DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlowerPotCallback & a_Callback); // Lua-accessible
|
bool DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlowerPotCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found */
|
/** Retrieves the test on the sign at the specified coords.
|
||||||
|
Returns false if there's no sign at those coords, true if found. */
|
||||||
bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Lua-accessible
|
bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Lua-accessible
|
||||||
|
|
||||||
/** Touches the chunk, causing it to be loaded or generated */
|
/** Touches the chunk, causing it to be loaded or generated */
|
||||||
@ -423,10 +442,10 @@ private:
|
|||||||
bool ForEachEntity(cEntityCallback & a_Callback); // Lua-accessible
|
bool ForEachEntity(cEntityCallback & a_Callback); // Lua-accessible
|
||||||
|
|
||||||
/** Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. Returns true if entity found. */
|
/** Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. Returns true if entity found. */
|
||||||
bool DoWithEntityByID(int a_EntityID, cEntityCallback & a_Callback, bool & a_CallbackReturn); // Lua-accessible
|
bool DoWithEntityByID(UInt32 a_EntityID, cEntityCallback & a_Callback, bool & a_CallbackReturn); // Lua-accessible
|
||||||
|
|
||||||
/** Returns true if there is an entity with the specified ID within this layer's chunks */
|
/** Returns true if there is an entity with the specified ID within this layer's chunks */
|
||||||
bool HasEntity(int a_EntityID);
|
bool HasEntity(UInt32 a_EntityID);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -18,49 +18,50 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cEntity::m_EntityCount = 0;
|
UInt32 cEntity::m_EntityCount = 0;
|
||||||
cCriticalSection cEntity::m_CSCount;
|
cCriticalSection cEntity::m_CSCount;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height)
|
cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height):
|
||||||
: m_UniqueID(0)
|
m_UniqueID(INVALID_ID), // Proper ID will be assigned later in the constructor code
|
||||||
, m_Health(1)
|
m_Health(1),
|
||||||
, m_MaxHealth(1)
|
m_MaxHealth(1),
|
||||||
, m_AttachedTo(nullptr)
|
m_AttachedTo(nullptr),
|
||||||
, m_Attachee(nullptr)
|
m_Attachee(nullptr),
|
||||||
, m_bDirtyHead(true)
|
m_bDirtyHead(true),
|
||||||
, m_bDirtyOrientation(true)
|
m_bDirtyOrientation(true),
|
||||||
, m_bHasSentNoSpeed(true)
|
m_bHasSentNoSpeed(true),
|
||||||
, m_bOnGround(false)
|
m_bOnGround(false),
|
||||||
, m_Gravity(-9.81f)
|
m_Gravity(-9.81f),
|
||||||
, m_LastPos(a_X, a_Y, a_Z)
|
m_LastPos(a_X, a_Y, a_Z),
|
||||||
, m_IsInitialized(false)
|
m_IsInitialized(false),
|
||||||
, m_WorldTravellingFrom(nullptr)
|
m_WorldTravellingFrom(nullptr),
|
||||||
, m_EntityType(a_EntityType)
|
m_EntityType(a_EntityType),
|
||||||
, m_World(nullptr)
|
m_World(nullptr),
|
||||||
, m_IsFireproof(false)
|
m_IsFireproof(false),
|
||||||
, m_TicksSinceLastBurnDamage(0)
|
m_TicksSinceLastBurnDamage(0),
|
||||||
, m_TicksSinceLastLavaDamage(0)
|
m_TicksSinceLastLavaDamage(0),
|
||||||
, m_TicksSinceLastFireDamage(0)
|
m_TicksSinceLastFireDamage(0),
|
||||||
, m_TicksLeftBurning(0)
|
m_TicksLeftBurning(0),
|
||||||
, m_TicksSinceLastVoidDamage(0)
|
m_TicksSinceLastVoidDamage(0),
|
||||||
, m_IsSwimming(false)
|
m_IsSwimming(false),
|
||||||
, m_IsSubmerged(false)
|
m_IsSubmerged(false),
|
||||||
, m_AirLevel(0)
|
m_AirLevel(0),
|
||||||
, m_AirTickTimer(0)
|
m_AirTickTimer(0),
|
||||||
, m_TicksAlive(0)
|
m_TicksAlive(0),
|
||||||
, m_HeadYaw(0.0)
|
m_HeadYaw(0.0),
|
||||||
, m_Rot(0.0, 0.0, 0.0)
|
m_Rot(0.0, 0.0, 0.0),
|
||||||
, m_Pos(a_X, a_Y, a_Z)
|
m_Pos(a_X, a_Y, a_Z),
|
||||||
, m_WaterSpeed(0, 0, 0)
|
m_WaterSpeed(0, 0, 0),
|
||||||
, m_Mass (0.001) // Default 1g
|
m_Mass (0.001), // Default 1g
|
||||||
, m_Width(a_Width)
|
m_Width(a_Width),
|
||||||
, m_Height(a_Height)
|
m_Height(a_Height),
|
||||||
, m_InvulnerableTicks(0)
|
m_InvulnerableTicks(0)
|
||||||
{
|
{
|
||||||
|
// Assign a proper ID:
|
||||||
cCSLock Lock(m_CSCount);
|
cCSLock Lock(m_CSCount);
|
||||||
m_EntityCount++;
|
m_EntityCount++;
|
||||||
m_UniqueID = m_EntityCount;
|
m_UniqueID = m_EntityCount;
|
||||||
|
@ -142,6 +142,10 @@ public:
|
|||||||
|
|
||||||
static const int VOID_BOUNDARY = -46; ///< Y position to begin applying void damage
|
static const int VOID_BOUNDARY = -46; ///< Y position to begin applying void damage
|
||||||
static const int FALL_DAMAGE_HEIGHT = 4; ///< Y difference after which fall damage is applied
|
static const int FALL_DAMAGE_HEIGHT = 4; ///< Y difference after which fall damage is applied
|
||||||
|
|
||||||
|
/** Special ID that is considered an "invalid value", signifying no entity. */
|
||||||
|
static const UInt32 INVALID_ID = 0; // Exported to Lua in ManualBindings.cpp, ToLua doesn't parse initialized constants.
|
||||||
|
|
||||||
|
|
||||||
cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
|
cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
|
||||||
virtual ~cEntity();
|
virtual ~cEntity();
|
||||||
@ -248,7 +252,7 @@ public:
|
|||||||
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways);
|
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways);
|
||||||
void SteerVehicle(float a_Forward, float a_Sideways);
|
void SteerVehicle(float a_Forward, float a_Sideways);
|
||||||
|
|
||||||
inline int GetUniqueID(void) const { return m_UniqueID; }
|
inline UInt32 GetUniqueID(void) const { return m_UniqueID; }
|
||||||
inline bool IsDestroyed(void) const { return !m_IsInitialized; }
|
inline bool IsDestroyed(void) const { return !m_IsInitialized; }
|
||||||
|
|
||||||
/// Schedules the entity for destroying; if a_ShouldBroadcast is set to true, broadcasts the DestroyEntity packet
|
/// Schedules the entity for destroying; if a_ShouldBroadcast is set to true, broadcasts the DestroyEntity packet
|
||||||
@ -464,12 +468,15 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static cCriticalSection m_CSCount;
|
static cCriticalSection m_CSCount;
|
||||||
static int m_EntityCount;
|
static UInt32 m_EntityCount;
|
||||||
|
|
||||||
/** Measured in meter/second (m/s) */
|
/** Measured in meter/second (m/s) */
|
||||||
Vector3d m_Speed;
|
Vector3d m_Speed;
|
||||||
|
|
||||||
int m_UniqueID;
|
/** The ID of the entity that is guaranteed to be unique within a single run of the server.
|
||||||
|
Always nonzero (a zero UniqueID (cEntity::INVALID_ID) is used for error reporting).
|
||||||
|
Note that the UniqueID is not persisted through storage. */
|
||||||
|
UInt32 m_UniqueID;
|
||||||
|
|
||||||
int m_Health;
|
int m_Health;
|
||||||
int m_MaxHealth;
|
int m_MaxHealth;
|
||||||
|
@ -24,7 +24,7 @@ class cMinecartCollisionCallback :
|
|||||||
public cEntityCallback
|
public cEntityCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cMinecartCollisionCallback(Vector3d a_Pos, double a_Height, double a_Width, int a_UniqueID, int a_AttacheeUniqueID) :
|
cMinecartCollisionCallback(Vector3d a_Pos, double a_Height, double a_Width, UInt32 a_UniqueID, UInt32 a_AttacheeUniqueID) :
|
||||||
m_DoesInteserct(false),
|
m_DoesInteserct(false),
|
||||||
m_CollidedEntityPos(0, 0, 0),
|
m_CollidedEntityPos(0, 0, 0),
|
||||||
m_Pos(a_Pos),
|
m_Pos(a_Pos),
|
||||||
@ -77,8 +77,8 @@ protected:
|
|||||||
|
|
||||||
Vector3d m_Pos;
|
Vector3d m_Pos;
|
||||||
double m_Height, m_Width;
|
double m_Height, m_Width;
|
||||||
int m_UniqueID;
|
UInt32 m_UniqueID;
|
||||||
int m_AttacheeUniqueID;
|
UInt32 m_AttacheeUniqueID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -824,7 +824,10 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
|
|||||||
|
|
||||||
bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
|
bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
|
||||||
{
|
{
|
||||||
cMinecartCollisionCallback MinecartCollisionCallback(GetPosition(), GetHeight(), GetWidth(), GetUniqueID(), ((m_Attachee == nullptr) ? -1 : m_Attachee->GetUniqueID()));
|
cMinecartCollisionCallback MinecartCollisionCallback(
|
||||||
|
GetPosition(), GetHeight(), GetWidth(), GetUniqueID(),
|
||||||
|
((m_Attachee == nullptr) ? cEntity::INVALID_ID : m_Attachee->GetUniqueID())
|
||||||
|
);
|
||||||
int ChunkX, ChunkZ;
|
int ChunkX, ChunkZ;
|
||||||
cChunkDef::BlockToChunk(POSX_TOINT, POSZ_TOINT, ChunkX, ChunkZ);
|
cChunkDef::BlockToChunk(POSX_TOINT, POSZ_TOINT, ChunkX, ChunkZ);
|
||||||
m_World->ForEachEntityInChunk(ChunkX, ChunkZ, MinecartCollisionCallback);
|
m_World->ForEachEntityInChunk(ChunkX, ChunkZ, MinecartCollisionCallback);
|
||||||
|
@ -221,7 +221,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a
|
|||||||
super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height),
|
super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height),
|
||||||
m_ProjectileKind(a_Kind),
|
m_ProjectileKind(a_Kind),
|
||||||
m_CreatorData(
|
m_CreatorData(
|
||||||
((a_Creator != nullptr) ? a_Creator->GetUniqueID() : -1),
|
((a_Creator != nullptr) ? a_Creator->GetUniqueID() : cEntity::INVALID_ID),
|
||||||
((a_Creator != nullptr) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : ""),
|
((a_Creator != nullptr) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : ""),
|
||||||
((a_Creator != nullptr) ? a_Creator->GetEquippedWeapon().m_Enchantments : cEnchantments())
|
((a_Creator != nullptr) ? a_Creator->GetEquippedWeapon().m_Enchantments : cEnchantments())
|
||||||
),
|
),
|
||||||
|
@ -69,7 +69,7 @@ public:
|
|||||||
/** Returns the unique ID of the entity who created this projectile
|
/** Returns the unique ID of the entity who created this projectile
|
||||||
May return an ID <0
|
May return an ID <0
|
||||||
*/
|
*/
|
||||||
int GetCreatorUniqueID(void) { return m_CreatorData.m_UniqueID; }
|
UInt32 GetCreatorUniqueID(void) { return m_CreatorData.m_UniqueID; }
|
||||||
|
|
||||||
/** Returns the name of the player that created the projectile
|
/** Returns the name of the player that created the projectile
|
||||||
Will be empty for non-player creators
|
Will be empty for non-player creators
|
||||||
@ -90,18 +90,17 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** A structure that stores the Entity ID and Playername of the projectile's creator
|
/** A structure that stores the Entity ID and Playername of the projectile's creator
|
||||||
Used to migitate invalid pointers caused by the creator being destroyed
|
Used to migitate invalid pointers caused by the creator being destroyed. */
|
||||||
*/
|
|
||||||
struct CreatorData
|
struct CreatorData
|
||||||
{
|
{
|
||||||
CreatorData(int a_UniqueID, const AString & a_Name, const cEnchantments & a_Enchantments) :
|
CreatorData(UInt32 a_UniqueID, const AString & a_Name, const cEnchantments & a_Enchantments) :
|
||||||
m_UniqueID(a_UniqueID),
|
m_UniqueID(a_UniqueID),
|
||||||
m_Name(a_Name),
|
m_Name(a_Name),
|
||||||
m_Enchantments(a_Enchantments)
|
m_Enchantments(a_Enchantments)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const int m_UniqueID;
|
const UInt32 m_UniqueID;
|
||||||
AString m_Name;
|
AString m_Name;
|
||||||
cEnchantments m_Enchantments;
|
cEnchantments m_Enchantments;
|
||||||
};
|
};
|
||||||
@ -110,8 +109,7 @@ protected:
|
|||||||
eKind m_ProjectileKind;
|
eKind m_ProjectileKind;
|
||||||
|
|
||||||
/** The structure for containing the entity ID and name who has created this projectile
|
/** The structure for containing the entity ID and name who has created this projectile
|
||||||
The ID and/or name may be nullptr (e.g. for dispensers/mobs)
|
The ID and/or name may be nullptr (e.g. for dispensers/mobs). */
|
||||||
*/
|
|
||||||
CreatorData m_CreatorData;
|
CreatorData m_CreatorData;
|
||||||
|
|
||||||
/** True if the projectile has hit the ground and is stuck there */
|
/** True if the projectile has hit the ground and is stuck there */
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
Vector3d Pos = a_Player->GetThrowStartPos();
|
Vector3d Pos = a_Player->GetThrowStartPos();
|
||||||
Vector3d Speed = a_Player->GetLookVector() * 7;
|
Vector3d Speed = a_Player->GetLookVector() * 7;
|
||||||
|
|
||||||
if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, cProjectileEntity::pkSplashPotion, a_Player, &a_Player->GetEquippedItem(), &Speed) < 0)
|
if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, cProjectileEntity::pkSplashPotion, a_Player, &a_Player->GetEquippedItem(), &Speed) == cEntity::INVALID_ID)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
eMonsterType MonsterType = ItemDamageToMonsterType(a_Item.m_ItemDamage);
|
eMonsterType MonsterType = ItemDamageToMonsterType(a_Item.m_ItemDamage);
|
||||||
if (
|
if (
|
||||||
(MonsterType != mtInvalidType) && // Valid monster type
|
(MonsterType != mtInvalidType) && // Valid monster type
|
||||||
(a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, MonsterType) >= 0)) // Spawning succeeded
|
(a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, MonsterType) != cEntity::INVALID_ID)) // Spawning succeeded
|
||||||
{
|
{
|
||||||
if (!a_Player->IsGameModeCreative())
|
if (!a_Player->IsGameModeCreative())
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ public:
|
|||||||
cFastRandom Random;
|
cFastRandom Random;
|
||||||
a_World->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY() - a_Player->GetHeight(), a_Player->GetPosZ(), 0.5f, 0.4f / (Random.NextFloat(1.0f) * 0.4f + 0.8f));
|
a_World->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY() - a_Player->GetHeight(), a_Player->GetPosZ(), 0.5f, 0.4f / (Random.NextFloat(1.0f) * 0.4f + 0.8f));
|
||||||
|
|
||||||
if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem(), &Speed) < 0)
|
if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem(), &Speed) == cEntity::INVALID_ID)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem()) < 0)
|
if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem()) == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ cMapManager::cMapManager(cWorld * a_World)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cMapManager::DoWithMap(int a_ID, cMapCallback & a_Callback)
|
bool cMapManager::DoWithMap(UInt32 a_ID, cMapCallback & a_Callback)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CS);
|
cCSLock Lock(m_CS);
|
||||||
cMap * Map = GetMapData(a_ID);
|
cMap * Map = GetMapData(a_ID);
|
||||||
|
@ -32,8 +32,7 @@ public:
|
|||||||
cMapManager(cWorld * a_World);
|
cMapManager(cWorld * a_World);
|
||||||
|
|
||||||
/** Returns the map with the specified ID, nullptr if out of range.
|
/** Returns the map with the specified ID, nullptr if out of range.
|
||||||
WARNING: The returned map object is not thread safe.
|
WARNING: The returned map object is not thread safe. */
|
||||||
*/
|
|
||||||
cMap * GetMapData(unsigned int a_ID);
|
cMap * GetMapData(unsigned int a_ID);
|
||||||
|
|
||||||
/** Creates a new map. Returns nullptr on error */
|
/** Creates a new map. Returns nullptr on error */
|
||||||
@ -41,13 +40,11 @@ public:
|
|||||||
|
|
||||||
/** Calls the callback for the map with the specified ID.
|
/** Calls the callback for the map with the specified ID.
|
||||||
Returns true if the map was found and the callback called, false if map not found.
|
Returns true if the map was found and the callback called, false if map not found.
|
||||||
Callback return value is ignored.
|
Callback return value is ignored. */
|
||||||
*/
|
bool DoWithMap(UInt32 a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp
|
||||||
bool DoWithMap(int a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp
|
|
||||||
|
|
||||||
/** Calls the callback for each map.
|
/** Calls the callback for each map.
|
||||||
Returns true if all maps processed, false if the callback aborted by returning true.
|
Returns true if all maps processed, false if the callback aborted by returning true. */
|
||||||
*/
|
|
||||||
bool ForEachMap(cMapCallback & a_Callback);
|
bool ForEachMap(cMapCallback & a_Callback);
|
||||||
|
|
||||||
size_t GetNumMaps(void) const; // tolua_export
|
size_t GetNumMaps(void) const; // tolua_export
|
||||||
|
@ -248,28 +248,31 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Maps player's EntityID -> current recipe; not a std::map because cCraftingGrid needs proper constructor params
|
/** Maps player's EntityID -> current recipe.
|
||||||
typedef std::list<std::pair<int, cCraftingRecipe> > cRecipeMap;
|
Not a std::map because cCraftingGrid needs proper constructor params. */
|
||||||
|
typedef std::list<std::pair<UInt32, cCraftingRecipe> > cRecipeMap;
|
||||||
|
|
||||||
int m_GridSize;
|
int m_GridSize;
|
||||||
cRecipeMap m_Recipes;
|
cRecipeMap m_Recipes;
|
||||||
|
|
||||||
/// Handles a click in the result slot. Crafts using the current recipe, if possible
|
/** Handles a click in the result slot.
|
||||||
|
Crafts using the current recipe, if possible. */
|
||||||
void ClickedResult(cPlayer & a_Player);
|
void ClickedResult(cPlayer & a_Player);
|
||||||
|
|
||||||
/// Handles a shift-click in the result slot. Crafts using the current recipe until it changes or no more space for result.
|
/** Handles a shift-click in the result slot.
|
||||||
|
Crafts using the current recipe until it changes or no more space for result. */
|
||||||
void ShiftClickedResult(cPlayer & a_Player);
|
void ShiftClickedResult(cPlayer & a_Player);
|
||||||
|
|
||||||
/** Handles a drop-click in the result slot. */
|
/** Handles a drop-click in the result slot. */
|
||||||
void DropClickedResult(cPlayer & a_Player);
|
void DropClickedResult(cPlayer & a_Player);
|
||||||
|
|
||||||
/// Updates the current recipe and result slot based on the ingredients currently in the crafting grid of the specified player
|
/** Updates the current recipe and result slot based on the ingredients currently in the crafting grid of the specified player. */
|
||||||
void UpdateRecipe(cPlayer & a_Player);
|
void UpdateRecipe(cPlayer & a_Player);
|
||||||
|
|
||||||
/// Retrieves the recipe for the specified player from the map, or creates one if not found
|
/** Retrieves the recipe for the specified player from the map, or creates one if not found. */
|
||||||
cCraftingRecipe & GetRecipeForPlayer(cPlayer & a_Player);
|
cCraftingRecipe & GetRecipeForPlayer(cPlayer & a_Player);
|
||||||
|
|
||||||
/// Called after an item has been crafted to handle statistics e.t.c.
|
/** Called after an item has been crafted to handle statistics e.t.c. */
|
||||||
void HandleCraftItem(const cItem & a_Result, cPlayer & a_Player);
|
void HandleCraftItem(const cItem & a_Result, cPlayer & a_Player);
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -1920,7 +1920,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cWorld::SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NIBBLETYPE BlockMeta)
|
UInt32 cWorld::SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NIBBLETYPE BlockMeta)
|
||||||
{
|
{
|
||||||
cFallingBlock * FallingBlock = new cFallingBlock(Vector3i(a_X, a_Y, a_Z), BlockType, BlockMeta);
|
cFallingBlock * FallingBlock = new cFallingBlock(Vector3i(a_X, a_Y, a_Z), BlockType, BlockMeta);
|
||||||
FallingBlock->Initialize(*this);
|
FallingBlock->Initialize(*this);
|
||||||
@ -1931,11 +1931,12 @@ int cWorld::SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NI
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cWorld::SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward)
|
UInt32 cWorld::SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward)
|
||||||
{
|
{
|
||||||
if (a_Reward < 1)
|
if (a_Reward < 1)
|
||||||
{
|
{
|
||||||
return -1;
|
LOGWARNING("%s: Attempting to create an experience orb with non-positive reward!", __FUNCTION__);
|
||||||
|
return cEntity::INVALID_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
cExpOrb * ExpOrb = new cExpOrb(a_X, a_Y, a_Z, a_Reward);
|
cExpOrb * ExpOrb = new cExpOrb(a_X, a_Y, a_Z, a_Reward);
|
||||||
@ -1947,7 +1948,7 @@ int cWorld::SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType, const cItem & a_Content, int a_BlockHeight)
|
UInt32 cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType, const cItem & a_Content, int a_BlockHeight)
|
||||||
{
|
{
|
||||||
cMinecart * Minecart;
|
cMinecart * Minecart;
|
||||||
switch (a_MinecartType)
|
switch (a_MinecartType)
|
||||||
@ -1959,7 +1960,7 @@ int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType
|
|||||||
case E_ITEM_MINECART_WITH_HOPPER: Minecart = new cMinecartWithHopper (a_X, a_Y, a_Z); break;
|
case E_ITEM_MINECART_WITH_HOPPER: Minecart = new cMinecartWithHopper (a_X, a_Y, a_Z); break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
return -1;
|
return cEntity::INVALID_ID;
|
||||||
}
|
}
|
||||||
} // switch (a_MinecartType)
|
} // switch (a_MinecartType)
|
||||||
Minecart->Initialize(*this);
|
Minecart->Initialize(*this);
|
||||||
@ -1970,7 +1971,7 @@ int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTicks, double a_InitialVelocityCoeff)
|
UInt32 cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTicks, double a_InitialVelocityCoeff)
|
||||||
{
|
{
|
||||||
cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTicks);
|
cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTicks);
|
||||||
TNT->Initialize(*this);
|
TNT->Initialize(*this);
|
||||||
@ -1979,6 +1980,7 @@ void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTicks,
|
|||||||
a_InitialVelocityCoeff * 2,
|
a_InitialVelocityCoeff * 2,
|
||||||
a_InitialVelocityCoeff * (GetTickRandomNumber(2) - 1)
|
a_InitialVelocityCoeff * (GetTickRandomNumber(2) - 1)
|
||||||
);
|
);
|
||||||
|
return TNT->GetUniqueID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2069,7 +2071,7 @@ void cWorld::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWorld::BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude)
|
void cWorld::BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude)
|
||||||
{
|
{
|
||||||
m_ChunkMap->BroadcastBlockBreakAnimation(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage, a_Exclude);
|
m_ChunkMap->BroadcastBlockBreakAnimation(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage, a_Exclude);
|
||||||
}
|
}
|
||||||
@ -2906,7 +2908,7 @@ bool cWorld::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cWorld::DoWithEntityByID(int a_UniqueID, cEntityCallback & a_Callback)
|
bool cWorld::DoWithEntityByID(UInt32 a_UniqueID, cEntityCallback & a_Callback)
|
||||||
{
|
{
|
||||||
// First check the entities-to-add:
|
// First check the entities-to-add:
|
||||||
{
|
{
|
||||||
@ -3215,7 +3217,7 @@ void cWorld::AddEntity(cEntity * a_Entity)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cWorld::HasEntity(int a_UniqueID)
|
bool cWorld::HasEntity(UInt32 a_UniqueID)
|
||||||
{
|
{
|
||||||
// Check if the entity is in the queue to be added to the world:
|
// Check if the entity is in the queue to be added to the world:
|
||||||
{
|
{
|
||||||
@ -3332,15 +3334,16 @@ bool cWorld::IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType)
|
UInt32 cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType)
|
||||||
{
|
{
|
||||||
cMonster * Monster = nullptr;
|
cMonster * Monster = nullptr;
|
||||||
|
|
||||||
Monster = cMonster::NewMonsterFromType(a_MonsterType);
|
Monster = cMonster::NewMonsterFromType(a_MonsterType);
|
||||||
if (Monster != nullptr)
|
if (Monster == nullptr)
|
||||||
{
|
{
|
||||||
Monster->SetPosition(a_PosX, a_PosY, a_PosZ);
|
return cEntity::INVALID_ID;
|
||||||
}
|
}
|
||||||
|
Monster->SetPosition(a_PosX, a_PosY, a_PosZ);
|
||||||
|
|
||||||
return SpawnMobFinalize(Monster);
|
return SpawnMobFinalize(Monster);
|
||||||
}
|
}
|
||||||
@ -3348,13 +3351,9 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cWorld::SpawnMobFinalize(cMonster * a_Monster)
|
UInt32 cWorld::SpawnMobFinalize(cMonster * a_Monster)
|
||||||
{
|
{
|
||||||
// Invalid cMonster object. Bail out.
|
ASSERT(a_Monster != nullptr);
|
||||||
if (!a_Monster)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Give the mob full health.
|
// Give the mob full health.
|
||||||
a_Monster->SetHealth(a_Monster->GetMaxHealth());
|
a_Monster->SetHealth(a_Monster->GetMaxHealth());
|
||||||
@ -3364,7 +3363,7 @@ int cWorld::SpawnMobFinalize(cMonster * a_Monster)
|
|||||||
{
|
{
|
||||||
delete a_Monster;
|
delete a_Monster;
|
||||||
a_Monster = nullptr;
|
a_Monster = nullptr;
|
||||||
return -1;
|
return cEntity::INVALID_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the monster into the current world.
|
// Initialize the monster into the current world.
|
||||||
@ -3372,7 +3371,7 @@ int cWorld::SpawnMobFinalize(cMonster * a_Monster)
|
|||||||
{
|
{
|
||||||
delete a_Monster;
|
delete a_Monster;
|
||||||
a_Monster = nullptr;
|
a_Monster = nullptr;
|
||||||
return -1;
|
return cEntity::INVALID_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
cPluginManager::Get()->CallHookSpawnedMonster(*this, *a_Monster);
|
cPluginManager::Get()->CallHookSpawnedMonster(*this, *a_Monster);
|
||||||
@ -3384,18 +3383,18 @@ int cWorld::SpawnMobFinalize(cMonster * a_Monster)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed)
|
UInt32 cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed)
|
||||||
{
|
{
|
||||||
cProjectileEntity * Projectile = cProjectileEntity::Create(a_Kind, a_Creator, a_PosX, a_PosY, a_PosZ, a_Item, a_Speed);
|
cProjectileEntity * Projectile = cProjectileEntity::Create(a_Kind, a_Creator, a_PosX, a_PosY, a_PosZ, a_Item, a_Speed);
|
||||||
if (Projectile == nullptr)
|
if (Projectile == nullptr)
|
||||||
{
|
{
|
||||||
return -1;
|
return cEntity::INVALID_ID;
|
||||||
}
|
}
|
||||||
if (!Projectile->Initialize(*this))
|
if (!Projectile->Initialize(*this))
|
||||||
{
|
{
|
||||||
delete Projectile;
|
delete Projectile;
|
||||||
Projectile = nullptr;
|
Projectile = nullptr;
|
||||||
return -1;
|
return cEntity::INVALID_ID;
|
||||||
}
|
}
|
||||||
return Projectile->GetUniqueID();
|
return Projectile->GetUniqueID();
|
||||||
}
|
}
|
||||||
|
48
src/World.h
48
src/World.h
@ -215,7 +215,7 @@ public:
|
|||||||
// (Please keep these alpha-sorted)
|
// (Please keep these alpha-sorted)
|
||||||
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle);
|
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle);
|
||||||
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export
|
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export
|
||||||
void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude
|
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
@ -335,7 +335,9 @@ public:
|
|||||||
The entity is added lazily - this function only puts it in a queue that is then processed by the Tick thread. */
|
The entity is added lazily - this function only puts it in a queue that is then processed by the Tick thread. */
|
||||||
void AddEntity(cEntity * a_Entity);
|
void AddEntity(cEntity * a_Entity);
|
||||||
|
|
||||||
bool HasEntity(int a_UniqueID);
|
/** Returns true if an entity with the specified UniqueID exists in the world.
|
||||||
|
Note: Only loaded chunks are considered. */
|
||||||
|
bool HasEntity(UInt32 a_UniqueID);
|
||||||
|
|
||||||
/** Calls the callback for each entity in the entire world; returns true if all entities processed, false if the callback aborted by returning true */
|
/** Calls the callback for each entity in the entire world; returns true if all entities processed, false if the callback aborted by returning true */
|
||||||
bool ForEachEntity(cEntityCallback & a_Callback); // Exported in ManualBindings.cpp
|
bool ForEachEntity(cEntityCallback & a_Callback); // Exported in ManualBindings.cpp
|
||||||
@ -348,8 +350,9 @@ public:
|
|||||||
If any chunk in the box is missing, ignores the entities in that chunk silently. */
|
If any chunk in the box is missing, ignores the entities in that chunk silently. */
|
||||||
bool ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_Callback); // Exported in ManualBindings.cpp
|
bool ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_Callback); // Exported in ManualBindings.cpp
|
||||||
|
|
||||||
/** Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. Returns true if entity found and callback returned false. */
|
/** Calls the callback if the entity with the specified ID is found, with the entity object as the callback param.
|
||||||
bool DoWithEntityByID(int a_UniqueID, cEntityCallback & a_Callback); // Exported in ManualBindings.cpp
|
Returns true if entity found and callback returned false. */
|
||||||
|
bool DoWithEntityByID(UInt32 a_UniqueID, cEntityCallback & a_Callback); // Exported in ManualBindings.cpp
|
||||||
|
|
||||||
/** Compares clients of two chunks, calls the callback accordingly */
|
/** Compares clients of two chunks, calls the callback accordingly */
|
||||||
void CompareChunkClients(int a_ChunkX1, int a_ChunkZ1, int a_ChunkX2, int a_ChunkZ2, cClientDiffCallback & a_Callback);
|
void CompareChunkClients(int a_ChunkX1, int a_ChunkZ1, int a_ChunkX2, int a_ChunkZ2, cClientDiffCallback & a_Callback);
|
||||||
@ -476,20 +479,25 @@ public:
|
|||||||
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
|
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
|
||||||
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) override;
|
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) override;
|
||||||
|
|
||||||
/** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified: */
|
/** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified. */
|
||||||
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) override;
|
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) override;
|
||||||
|
|
||||||
/** Spawns an falling block entity at the given position. It returns the UniqueID of the spawned falling block. */
|
/** Spawns an falling block entity at the given position.
|
||||||
int SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NIBBLETYPE BlockMeta);
|
Returns the UniqueID of the spawned falling block, or cEntity::INVALID_ID on failure. */
|
||||||
|
UInt32 SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NIBBLETYPE BlockMeta);
|
||||||
|
|
||||||
/** Spawns an minecart at the given coordinates. */
|
/** Spawns an minecart at the given coordinates.
|
||||||
int SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType, const cItem & a_Content = cItem(), int a_BlockHeight = 1);
|
Returns the UniqueID of the spawned minecart, or cEntity::INVALID_ID on failure. */
|
||||||
|
UInt32 SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType, const cItem & a_Content = cItem(), int a_BlockHeight = 1);
|
||||||
|
|
||||||
/** Spawns an experience orb at the given location with the given reward. It returns the UniqueID of the spawned experience orb. */
|
/** Spawns an experience orb at the given location with the given reward.
|
||||||
virtual int SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) override;
|
Returns the UniqueID of the spawned experience orb, or cEntity::INVALID_ID on failure. */
|
||||||
|
virtual UInt32 SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) override;
|
||||||
|
|
||||||
/** Spawns a new primed TNT entity at the specified block coords and specified fuse duration. Initial velocity is given based on the relative coefficient provided */
|
/** Spawns a new primed TNT entity at the specified block coords and specified fuse duration.
|
||||||
void SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1);
|
Initial velocity is given based on the relative coefficient provided.
|
||||||
|
Returns the UniqueID of the created entity, or cEntity::INVALID_ID on failure. */
|
||||||
|
UInt32 SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1);
|
||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
@ -796,14 +804,14 @@ public:
|
|||||||
|
|
||||||
bool IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
|
bool IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
|
||||||
|
|
||||||
/** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */
|
/** Spawns a mob of the specified type. Returns the mob's UniqueID if recognized and spawned, cEntity::INVALID_ID otherwise */
|
||||||
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) override; // tolua_export
|
virtual UInt32 SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) override; // tolua_export
|
||||||
int SpawnMobFinalize(cMonster* a_Monster);
|
|
||||||
|
UInt32 SpawnMobFinalize(cMonster * a_Monster);
|
||||||
|
|
||||||
/** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise
|
/** Creates a projectile of the specified type. Returns the projectile's UniqueID if successful, cEntity::INVALID_ID otherwise
|
||||||
Item parameter used currently for Fireworks to correctly set entity metadata based on item metadata
|
Item parameter is currently used for Fireworks to correctly set entity metadata based on item metadata. */
|
||||||
*/
|
UInt32 CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed = nullptr); // tolua_export
|
||||||
int CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed = nullptr); // tolua_export
|
|
||||||
|
|
||||||
/** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */
|
/** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */
|
||||||
int GetTickRandomNumber(int a_Range) { return (int)(m_TickRand.randInt(a_Range)); }
|
int GetTickRandomNumber(int a_Range) { return (int)(m_TickRand.randInt(a_Range)); }
|
||||||
|
Loading…
Reference in New Issue
Block a user