Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.18.2] PlayerInteractEvent 双重触发问题 #843

Open
i493052739 opened this issue Dec 24, 2023 · 2 comments
Open

[1.18.2] PlayerInteractEvent 双重触发问题 #843

i493052739 opened this issue Dec 24, 2023 · 2 comments
Labels
question Further information is requested

Comments

@i493052739
Copy link

i493052739 commented Dec 24, 2023

运行环境

Minecraft版本(1.12.2/1.16.5/1.18.2): 1.18.2
构建版本(从/version指令获取): bc64e1f
相关模组/插件: 如下案例

    @EventHandler
    public void onInteract(PlayerInteractEvent e) {
        String u = UUID.randomUUID().toString();
        Player p = e.getPlayer();
        ItemStack i = e.getItem();
        EquipmentSlot h = e.getHand();
        Block cb = e.getClickedBlock();
        p.sendMessage(u + " hash: " + e.hashCode());
        p.sendMessage(u + " material: " + e.getMaterial().name());
        p.sendMessage(u + " hasBlock: " + e.hasBlock());
        p.sendMessage(u + " hasItem: " + e.hasItem());
        p.sendMessage(u + " itemType: " + (i == null ? null : i.getType().name()));
        p.sendMessage(u + " action: " + e.getAction().name());
        p.sendMessage(u + " blockFace: " + e.getBlockFace().name());
        p.sendMessage(u + " hand: "+ (h == null ? null : h.name()));
        p.sendMessage(u + " clickedBlock: "+ (cb == null ? null : cb.getType().name() + " " + cb.getX() + " " + cb.getY() + " " + cb.getZ()));
    }

描述这个BUG

互动空气时,PlayerInteractEvent 正常触发一次

0ad4c5ab47bb5721d7edfb3f3c5190e

互动方块时,PlayerInteractEvent 异常触发两次

e6f9b2669e05c98a4ed647a3f7d9406

导致的问题

PlayerInteractEvent 相关的 handlers 及逻辑被二次触发

@Luohuayu
Copy link
Owner

Luohuayu commented Jan 8, 2024

正常逻辑

@Kotori0629
Copy link
Collaborator

这个再观察一下吧 我印象里这个逻辑是没问题的

@Kotori0629 Kotori0629 added the question Further information is requested label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants