英文:
How to run varirables on client only
问题
我正在尝试修改《Minecraft》中的一个名为Psychedelicraft的模组,版本是1.7.10,但在客户端/服务器端方面遇到了一些问题。
我应该如何使这些变量保持私有?如何确保它仅在客户端上运行?
英文:
I am trying to modify a mod in Minecraft called Psychedelicraft on 1.7.10 and i have some problems with client/server side.
How can I keep these variables private. How can I keep it running only on client?
答案1
得分: 0
除了客户端和服务器注释(如果我记得正确的话是@ClientOnly
和@ServerOnly
)之外,您需要牢记的是,所有内容都在客户端和服务器上运行。但是,您需要管理好使这两者保持彼此更新。
因此,如果您只希望客户端知道某些数据,就不要将它发送到服务器。换句话说,不要将其添加到任何NBT数据或序列化中。这样做的缺点是,当游戏重新启动时,服务器将无法使客户端保持最新状态。
英文:
You need to keep in mind that outside of the client and server annotations (@ClientOnly
and @ServerOnly
if I remember correctly), everything runs on both the client and the server. However, you need to manage keeping the two up to date with each other.
So if you only want the client to know some data, just don't send it to the server. In other words don't add it to any nbt data or serialization. The downside to this is that when the game is restarted, the server won't be able to get the client back up to date.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论