mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -04:00
interaction manager: don't crash when attacking invalid (or despawned) entity
This commit is contained in:
parent
f58b06026c
commit
9b6c462b75
@ -111,9 +111,10 @@ class InteractInteractionHandler(
|
||||
}
|
||||
|
||||
fun interactEntityAt(target: EntityTarget, hand: Hands): InteractionResults {
|
||||
val entityId = connection.world.entities.getId(target.entity) ?: return InteractionResults.PASS
|
||||
// used in armor stands
|
||||
val player = connection.player
|
||||
connection.sendPacket(EntityInteractPositionC2SP(connection, target.entity, Vec3(target.position), hand, player.isSneaking))
|
||||
connection.sendPacket(EntityInteractPositionC2SP(entityId, Vec3(target.position), hand, player.isSneaking))
|
||||
|
||||
if (player.gamemode == Gamemodes.SPECTATOR) {
|
||||
return InteractionResults.PASS
|
||||
@ -133,7 +134,7 @@ class InteractInteractionHandler(
|
||||
// ToDo: return hit.entity.interact(hand) (e.g. equipping saddle)
|
||||
return InteractionResults.PASS
|
||||
} finally {
|
||||
connection.sendPacket(EntityEmptyInteractC2SP(connection, target.entity, hand, player.isSneaking))
|
||||
connection.world.entities.getId(target.entity)?.let { connection.sendPacket(EntityEmptyInteractC2SP(it, hand, player.isSneaking)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user