Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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!

  • Author

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...).

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/

  • Author

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

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

 

 

  • Author

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.