Jump to content

[1.7.10] Detect where player wants to move on server (client - WASD, server - ?)


Elix_x

Recommended Posts

Hello, i have a little question: how can i know where player wants to move on server side?

 

I know that:

-On client i can check for key binds press.

-Server does not have keyboard.

-Client sends packets to server about input. But:

-All calls checking move key press go from MovementInputFromOptions, but this one is called only from EntityPlayerSP. ANd:

-Somehow client sends to server data about movement.

-In worst case i could send packets... But that's for worst case...

 

What i'm trying to do:

-In player update event check where player wants to move and modify motionX,Y,Z according to some side effects (not blocks, not entities, not tiles...).

Just to know where player wants to move!!! I know everything else!!!!!!!!!!!

 

Thanks for help!

If you have any questions - just ask!

Link to comment
Share on other sites

The client detects the key-pressing, and tells the server that it wants to move there.

 

But why do you want this??

1) I know this...

-All calls checking move key press go from MovementInputFromOptions, but this one is called only from EntityPlayerSP.

-Somehow client sends to server data about movement.

2)

What i'm trying to do:

-In player update event check where player wants to move and modify motionX,Y,Z according to some side effects (not blocks, not entities, not tiles...).

Link to comment
Share on other sites

What i'm trying to do:

-In player update event check where player wants to move and modify motionX,Y,Z according to some side effects (not blocks, not entities, not tiles...).

Use the
PlayerTickEvent

, and modify the

motionX/Y/Z

variables in there.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

What i'm trying to do:

-In player update event check where player wants to move and modify motionX,Y,Z according to some side effects (not blocks, not entities, not tiles...).

Use the
PlayerTickEvent

, and modify the

motionX/Y/Z

variables in there.

I'm already doing this...

I just need to know where player wants to move...

 

This makes me sad... Op has to be rewritten...

Link to comment
Share on other sites

Hi

 

You might find this useful

http://greyminecraftcoder.blogspot.com.au/2013/10/user-input.html

a bit out of date; movement is now sent from EntityPlayerSP.onUpdateWalkingPlayer() to update player position, handled on NetHandlerPlayServer.processPlayer

 

looks to me like it just updates the player position directly and doesn't store the 'which direction is player moving' anywhere.

 

-TGG

 

 

Link to comment
Share on other sites

Hi

 

You might find this useful

http://greyminecraftcoder.blogspot.com.au/2013/10/user-input.html

a bit out of date; movement is now sent from EntityPlayerSP.onUpdateWalkingPlayer() to update player position, handled on NetHandlerPlayServer.processPlayer

 

looks to me like it just updates the player position directly and doesn't store the 'which direction is player moving' anywhere.

 

-TGG

Thanks. I already understood that. So i had to do this:

	float fw = entity.moveForward;
	float st = entity.moveStrafing;
	boolean sneaking = entity.isSneaking();

	boolean forward = fw > 0;
	boolean backwards = fw < 0;
	boolean left = st < 0;
	boolean right = st > 0;
	boolean up = false;
	boolean down = sneaking;

 

Oh and also, forge has to create isJumping method in EntityLivingBase. Otherwise we have to use reflection to check if entity is jumping...

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.

Announcements



×
×
  • Create New...

Important Information

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