mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-21 17:23:56 +01:00
replace handleUpdateAttributes assert with checks
This commit is contained in:
1 parent
2e4ace6ff0
commit
0e9ca900cc
1 file changed
+9
-11
@@ -2759,13 +2759,14 @@ void ClientConnection::handleEntityEvent(shared_ptr<EntityEventPacket> packet)
|
||||
|
||||
shared_ptr<Entity> ClientConnection::getEntity(int entityId)
|
||||
{
|
||||
//if (entityId == minecraft->player->entityId)
|
||||
if(entityId == minecraft->localplayers[m_userIndex]->entityId)
|
||||
if (minecraft == nullptr || m_userIndex < 0 || m_userIndex >= XUSER_MAX_COUNT) return nullptr;
|
||||
|
||||
shared_ptr<Player> localPlayer = minecraft->localplayers[m_userIndex];
|
||||
if (localPlayer != nullptr && entityId == localPlayer->entityId)
|
||||
{
|
||||
//return minecraft->player;
|
||||
return minecraft->localplayers[m_userIndex];
|
||||
return localPlayer;
|
||||
}
|
||||
return level->getEntity(entityId);
|
||||
return level != nullptr ? level->getEntity(entityId) : nullptr;
|
||||
}
|
||||
|
||||
void ClientConnection::handleSetHealth(shared_ptr<SetHealthPacket> packet)
|
||||
@@ -4315,13 +4316,10 @@ void ClientConnection::handleUpdateAttributes(shared_ptr<UpdateAttributesPacket>
|
||||
shared_ptr<Entity> entity = getEntity(packet->getEntityId());
|
||||
if (entity == nullptr) return;
|
||||
|
||||
if ( !entity->instanceof(eTYPE_LIVINGENTITY) )
|
||||
{
|
||||
// Entity is not a living entity!
|
||||
assert(0);
|
||||
}
|
||||
shared_ptr<LivingEntity> living = dynamic_pointer_cast<LivingEntity>(entity);
|
||||
if (living == nullptr) return;
|
||||
|
||||
BaseAttributeMap *attributes = (dynamic_pointer_cast<LivingEntity>(entity))->getAttributes();
|
||||
BaseAttributeMap *attributes = living->getAttributes();
|
||||
unordered_set<UpdateAttributesPacket::AttributeSnapshot *> attributeSnapshots = packet->getValues();
|
||||
for ( UpdateAttributesPacket::AttributeSnapshot *attribute : attributeSnapshots )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user