local player = require("player") local keys = require("keys") registerKeyEvent(function(key, action) if (action == "Press") and key == keys.MOUSE_BUTTON_1 then if player.inventory.isAnyScreenOpened() then return end local ray = player.raycast(4.5) if ray and ray.type == "entity" then local last_slot = player.input.getSelectedSlot() player.input.setSelectedSlot(0) player.input.syncSelectedSlot() if player.input.attackEntity() then player.input.setSelectedSlot(last_slot) player.input.syncSelectedSlot() return false else player.input.setSelectedSlot(last_slot) player.input.syncSelectedSlot() end end end end)