Jump to content

[1.19] Creating new Packet


Zanckor

Recommended Posts

1 minute ago, Zanckor said:

So, i need to call this custom packet on ServerTickEvent, but this dont will lag player?

you can regenderate your Ki on server and client, if the Ki is fully regenderate on server send a Packet to the client which makes sure the values are the same
but this means you have to check whenever the client whats to call a action if the Ki value does match with the server on

and yeah you should avoid sending Packets each tick

Link to comment
Share on other sites

Wait a second xD, so, i need to put my regen code on server side, and then sync it from server to client, arent?

But, I still dont know how to put this code on server side, i mean, if i put it on ServerTickEvent i cant put (Player player = e.getPlayer), so, how server know to which player is this info

Link to comment
Share on other sites

30 minutes ago, Zanckor said:

But, I still dont know how to put this code on server side, i mean, if i put it on ServerTickEvent i cant put (Player player = e.getPlayer), so, how server know to which player is this info

check if the player of the Event is an instance of ServerPlayer

Link to comment
Share on other sites

Okay, so, i should do something like, if(player instanceof ServerPlayer){ RegenCode } and, if(player instanceof Player) { RegenCode }, but when, on server side, Current Ki is full, 0, or whatever i want, send a packet to check if both values are the same, and if not change client value

 

Edit: Okay, i realized that its better just make it server side, and whenever i need to use it, like, before attacking with ki, send a packet to sync it

Edited by Zanckor
Link to comment
Share on other sites

1 hour ago, Zanckor said:

Okay, so, i should do something like, if(player instanceof ServerPlayer){ RegenCode } and, if(player instanceof Player) { RegenCode }, but when, on server side, Current Ki is full, 0, or whatever i want, send a packet to check if both values are the same, and if not change client value

Edit: Okay, i realized that its better just make it server side, and whenever i need to use it, like, before attacking with ki, send a packet to sync it

logic like this should always be done on server and only sync it to the client if it is necessary

Link to comment
Share on other sites

  • 2 weeks later...

you sending the Packet from client to sever, this means you can not do this in your handle method

Player player = (Player) Minecraft.getInstance().getCameraEntity();

you should use the player from the Context (Context#getSender)

why did you return a boolean from the handle method?

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.