AcademyCraft

AcademyCraft

1M Downloads

Send gui sync event to only that client

WeAthFoLD opened this issue ยท 6 comments

commented
commented

Already fixed for matrix and node, keep reminded of this.

commented

Maybe need a enhancement for Annotation Registry? But it seems difficult unless touching the basic design of remote call.

commented

I think there is a small improvement to be made. Maybe we can take advantage of @Targetannotaion(or add a @Sender anno) in server side, and inject that instance automatically for the server. Otherwise we will always have to call sync(Minecraft.getMinecraft().thePlayer), which may cause side issues.
OOps, maybe looking up the sender from a global singleton is also fine?

NetworkCallEnv.getSender();
commented

I misunderstood the issue.

Calling Minecraft.getMinecraft().thePlayer will cause side issues? You should mark the caller function SideOnly. It's always prohibited to call server functions from server.

Besides, you can try Future, which is hopefully properly synchronized to the sender...

commented

Well, let's add some "current message information" to each thread. You can add it in NetworkCallManager. But note that this can make logic there to be side-dependent. Make sure you don't (especially for the logic after IMessageHandler receiving the message), if you'd like to change it.

In fact, my consideration was that, if you need the player (sender), you do something with this player instance on the server, while in these cases, it's OK to pass a Player argument (as it's done on the client), and if you want to send back some messages, Future might be a good choice.

In your example, I think we can have a Future that can synchronize multiple arguments back. It should be a minor change.

commented

Anyways the annoying problem currently is that we have to explicitly send the sender to server if we want it to know the sender every time:

    @RegNetworkCall(side = Side.SERVER, thisStorage = StorageOption.Option.INSTANCE)
    private void query(@Instance EntityPlayer player) {
        if(player != null)
            syncBack(player, currentRecipe, workProgress, tank.getFluidAmount());
    }

and must be called by:

query(Minecraft.getMinecraft().thePlayer);

If there is a way outside the parameters to get sending environment info that would be of great help.