Jump to content

Recommended Posts

Posted
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

Posted

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

Posted
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

Posted (edited)

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
Posted
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

Posted
30 minutes ago, Luis_ST said:

should work, you can test it via running the runServer gradle task

So, why should i send packets if it works now?

 

Posted
1 hour ago, Zanckor said:

So, why should i send packets if it works now?

you now do it fully server side you don't need any Packets,
unless you need the Ki value on the client

  • Thanks 1
  • 2 weeks later...
Posted

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
Posted
9 minutes ago, Luis_ST said:

why did you return a boolean from the handle method?

I've seen it on another packet, so i thougth it should be a boolean method, but can it be public void handle?

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.

Announcements



×
×
  • Create New...

Important Information

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