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

[建议]希望取消掉SlimefunItemStack的clone覆写 #988

Open
m1919810 opened this issue Dec 28, 2024 · 2 comments
Open

[建议]希望取消掉SlimefunItemStack的clone覆写 #988

m1919810 opened this issue Dec 28, 2024 · 2 comments
Labels
🐞 Bug 抓虫子

Comments

@m1919810
Copy link

问题描述

1.21paper的诸如"附属界面打不开,无法cast sfitem to citem"的问题均出自此
实际为 paper1.21运行时ItemStack.class被修改导致
其中 new ItemStack(ItemStack item)会令this.craftDelegate=item.clone()
而ItemStack.clone方法为return this.craftDelegate.clone()<-默认是citem
故只要不覆写clone就可以避免出现任何问题

至于附属中出现的问题,是因为他们尝试对sfitem进行new ItemStack获得干净物品,但实际上恰恰相反的调用了sfitem.clone,存入了不干净的物品,导致paper直接读取craftDelegate成员并强转时出错

问题复现率

必现

复现步骤

服务端类型

Paper

Minecraft 版本

1.21.x

Slimefun 版本

Slimefun 2024.09

其他插件信息

No response

补充信息

No response

@m1919810 m1919810 added the 🐞 Bug 抓虫子 label Dec 28, 2024
@m1919810
Copy link
Author

刚才看了一下 不能直接super.clone()
我建议这样
4
以兼容1.21+和1.21以下

@StarWishsama
Copy link
Member

make a pr

m1919810 added a commit to m1919810/Slimefun-vModified that referenced this issue Dec 29, 2024
m1919810 added a commit to m1919810/Slimefun-vModified that referenced this issue Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug 抓虫子
Projects
None yet
Development

No branches or pull requests

2 participants