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

Fix #317, #324, notify #309 #325

Closed
wants to merge 2 commits into from
Closed

Conversation

Lumine1909
Copy link
Contributor

这是一个很离谱的原因 来自于Mojang的抽象代码 也是我今天自己仔细看才找到的
所有的"假人不像真人"的问题都来自于这个

问题解析:
在之前的版本中, ServerBot#tick的调用链如下:
->ServerBot#tick
->ServerPlayer#tick
->ServerBot#doTick

注意: ServerPlayer#tick 不包括 super.tick,也就是 Player#tick 不是在这里调用的
Player#tick 来自于 ServerPlayer#tick ,也就是 ServerGamePacketListenerImpl#tick 产生的,而假人根本不会调用这个方法
而 doTick 没有调用 super 的内容,也不会调用到 Player#tick
这就导致了所有玩家相关的内容都没有被调用,自然也不像真人

修复后的调用链:
->ServerBot#tick
->ServerPlayer#tick
->ServerBot#doTick
->ServerPlayer#doTick
->Player#tick

已测试的食用和睡觉都正常工作,区块加载需要进一步测试

@s-yh-china s-yh-china self-requested a review August 26, 2024 10:06
@@ -2050,7 +2050,7 @@ index 0000000000000000000000000000000000000000..462d58ad184ebe6bd6f161bff1481745
+ this.hurtTime -= 1;
+ }
+
+ baseTick();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

刻意为之,部分tick中的内容是要被忽略的

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要修复的正确方案应该是把需要的逻辑移动到baseTick

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果放到baseTick相当于把Player, LivingEntity的tick全部重写一遍,有点极端了(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要么你更极端一点为假人写一个它自己的tick方法。

@s-yh-china
Copy link
Member

我决定更极端一点,直接重写假人的tick
先关了

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

Successfully merging this pull request may close these issues.

3 participants