diff --git a/bridge/lib/mineflayer/lib/bedrockPlugins/entities.mts b/bridge/lib/mineflayer/lib/bedrockPlugins/entities.mts index 0b3933a..f097e9e 100644 --- a/bridge/lib/mineflayer/lib/bedrockPlugins/entities.mts +++ b/bridge/lib/mineflayer/lib/bedrockPlugins/entities.mts @@ -523,6 +523,16 @@ export default function inject(bot: BedrockBot) { } function itemUseOnEntity(target: any, type: number) { const typeStr = ['attack', 'interact'][type]; + // Provide empty item if hand is empty to avoid serialization crash + const heldItem = bot.heldItem || { + network_id: 0, + count: 0, + metadata: 0, + has_stack_id: false, + stack_id: 0, + block_runtime_id: 0, + extra: { has_nbt: false, can_place_on: [], can_destroy: [] }, + }; const transaction = { transaction: { legacy: { @@ -534,10 +544,9 @@ export default function inject(bot: BedrockBot) { entity_runtime_id: target.id, action_type: typeStr, hotbar_slot: bot.quickBarSlot, - held_item: bot.heldItem, + held_item: heldItem, player_pos: bot.entity.position, click_pos: { - // in case with interact its pos on hitbox of entity that is being interacted with x: 0, y: 0, z: 0,