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.

I want to make my player boost forwards, back, left or right relative to where they're facing, is there anyway I can do this?

Featured Replies

Posted

1.15.2

As the title states ^

Any help would be greatly appreciated, this is my first mod!

 

I currently have it set to a keypress, here's my code:

public class DodgeEvent {
	@SubscribeEvent
    public void onKeyInput(KeyInputEvent event)
    {
        if (Keybinds.dodge.isPressed())
        {
        	PlayerEntity player = Minecraft.getInstance().player;
        	/*
        		
        		Things I'm messing around with:
        	
        	float rotation = player.cameraYaw;
        	Vec3d look = player.getLookVec();
        	System.out.println(rotation + "and" + look.x + "" + look.y);
        	player.addVelocity(look.x, 0, look.y);
        	*/
        }
    }

}

I have a feeling it has something to do with player.moveForward and player.moveStrafe although I can't find any recent documentation on this.

 

Thank you in advance for your help! I'm completely lost!

Edited by ultra_reemun
Grammar

55 minutes ago, ultra_reemun said:

Any help would be greatly appreciated, this is my first mod!

This is a little more complicated than what you have tried. When the key is pressed down you will need to send a packet to the server. The packet will say hey this player has pressed this button. The server will verify any other conditions then proceed with the appropriate response. In your case it will change the velocity of the player.

Now Minecraft uses xVel, yVel, and zVel so you likely need to use trig depending on exactly what you want to do.

 

PlayerEntity::moveForward and PlayerEntity::moveStrafe are from what I can tell multipliers on the actual motion values. And any change you do to them will be imperceptible because they are changed immediately before the entity moves.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • Author
8 hours ago, Animefan8888 said:

This is a little more complicated than what you have tried. When the key is pressed down you will need to send a packet to the server. The packet will say hey this player has pressed this button. The server will verify any other conditions then proceed with the appropriate response. In your case it will change the velocity of the player.

Now Minecraft uses xVel, yVel, and zVel so you likely need to use trig depending on exactly what you want to do.

 

PlayerEntity::moveForward and PlayerEntity::moveStrafe are from what I can tell multipliers on the actual motion values. And any change you do to them will be imperceptible because they are changed immediately before the entity moves.

Thank you! That's really helped.

 

I've managed to use the code from a snowball to get me started, although I'm still not too experienced in sending packets so I'll look into that now.

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.