Posted June 30, 20214 yr So I'm creating a mod that adds a bunch of new tool- and weapon types. One of them should make the player dash forward when they charged it. I was able to use some of the bow's code to make the charging work but neither do I know how to get the Horizontal Direction that the player's facing as a 3dVector, nor do I know how to accelerate a LivingEntity in a given direction. So how can I make a player dash in the horizontal direction they're facing? Edited June 30, 20214 yr by FenrisFox86
June 30, 20214 yr 1 hour ago, FenrisFox86 said: I was able to use some of the bow's code to make the charging work but neither do I know how to get the Horizontal Direction that the player's facing as a 3dVector, nor do I know how to accelerate a LivingEntity in a given direction. you can get it via Entity#getViewVector, use as the float parameter 1 else the value will be lerp with the current view vector, the last view vector and the parameter you given 1 hour ago, FenrisFox86 said: So how can I make a player dash in the horizontal direction they're facing? not sure but try to scale the vector
June 30, 20214 yr Author Solved: I made the stupid mistake to handle movement server-side first. That's why the movement never worked. The method Entity#getLookVector returns the correct vector and I simply had to pass it to the Entity#setMotion method. Edited June 30, 20214 yr by FenrisFox86
June 30, 20214 yr you can handle it on server-side just set after handling (Server)PlayerEntity#hurtMarked to true this will update the player and also the movement
July 1, 20214 yr Author Just something important for people trying to do a similar thing: normalize the vector and then multiply it by a factor you need. Otherways the vector's going to be as long as the player's distance to the block they're facing so the dash won't have a consistent length. Vector3d vector = player.getLookVec().normalize().mul(factor, factor, factor); player.setMotion(vector);
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.