如何仅在客户端上运行变量

huangapple go评论76阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年4月9日 08:25:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/61112089.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定