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.21破基岩速度特别慢 #35

Closed
oneIdler opened this issue Jul 10, 2024 · 2 comments
Closed

为什么1.21破基岩速度特别慢 #35

oneIdler opened this issue Jul 10, 2024 · 2 comments

Comments

@oneIdler
Copy link

无法多个基岩同时破,只能等上个破完之后才能破下一个

@bunnyi116
Copy link
Owner

这是因为我发现在1.21切换工具的时候破坏物品并不会使用当前发送的切换工具的数据包,会导活塞没办法秒破从而导致失败,具体原因不详,所以我为了能正常使用,将在执行前,发送切换工具的数据包,然后等待了几个TICK后(确保切换工具生效)才执行,为了保证切换工具的时候不被其他任务切换工具的影响,我将任务设置成一个TICK执行一个任务

@bunnyi116
Copy link
Owner

目前无法解决,属于MC新版本对工具附魔组件代改动导致了无法秒破活塞,所以为了MOD能正常工作,限制一TICK执行一个任务,以确保任务执行前能够切换到对应的工具并生效,所做的改动。

注:我已经模拟MC相关源代码做了测试,已查出是BlockState.calcBlockBreakingDelta中的player.getBlockBreakingSpeed(state)在模组切换物品后,破坏进度并不会使用该物品进行计算,又因服务端也是调用该方法(因为本MOD是客户端模组,可以在服务端使用,但本MOD无法针对服务器的服务端的代码进行修改),所以该问题无法解决,只能从任务处理逻辑上做出调整并限制。


 if (bl && blockState.calcBlockBreakingDelta(this.client.player, this.client.player.getWorld(), pos) >= 1.0F) {
                        this.breakBlock(pos);
                    }
    protected float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
        float f = state.getHardness(world, pos);
        if (f == -1.0F) {
            return 0.0F;
        } else {
            int i = player.canHarvest(state) ? 30 : 100;
            return player.getBlockBreakingSpeed(state) / f / (float)i;
        }
    }

@bunnyi116 bunnyi116 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants