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.

Featured Replies

Posted

Hi, I'm working on a mod to give players wings.

This is my code to add velocity(have not added in any checks(aka is player wearing wings) to code yet.)

@Override public IMessage onMessage(PacketWingStateChange message, MessageContext ctx) {
		    // This is the player the packet was sent to the server from
		    EntityPlayerMP serverPlayer = ctx.getServerHandler().player;
		    // Execute the action on the main server thread by adding it as a scheduled task
		    //WingsPacketHandler.INSTANCE.sendTo(new PacketWingStateChange(FlightState.NULL), serverPlayer);
		    float yaw = serverPlayer.rotationYaw;
		    float pitch = serverPlayer.rotationPitch;
		    float f = 1.0F;
		    double motionX = (double)(-MathHelper.sin(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(pitch / 180.0F * (float)Math.PI) * f);
		    double motionZ = (double)(MathHelper.cos(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(pitch / 180.0F * (float)Math.PI) * f);
		    double motionY = (double)(-MathHelper.sin((pitch) / 180.0F * (float)Math.PI) * f);
		    System.out.println("pitch:" + pitch);
		    System.out.println("yaw:" + yaw);
		    System.out.println("motX:" + motionX + " motY:" + motionY + " motZ:" + motionZ);
		    serverPlayer.getServerWorld().addScheduledTask(() -> {
		    	serverPlayer.addVelocity(motionX, motionY, motionZ);
		    });
		    // No response packet
		    return null;
		  }

Packets work - here's a log sample:

Quote

...

[09:37:35] [Netty Server IO #1/INFO]: [STDOUT]: pitch:27.900019
[09:37:35] [Netty Server IO #1/INFO]: [STDOUT]: yaw:239.40019
[09:37:35] [Netty Server IO #1/INFO]: [STDOUT]: motX:0.7606768012046814 motY:-0.46792641282081604 motZ:-0.4499063193798065

...

Player does not move at all.

This code is supposed to be used when player is 'flapping' thier wings, it should add velocity in the direction the're looking.

Thanks for the help! :)

Note: all the comments are from the docs(copy and paste :P)

You're reaching across threads here.

 

See the warning: http://mcforge.readthedocs.io/en/latest/networking/simpleimpl/

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author
2 hours ago, Draco18s said:

You're reaching across threads here.

 

See the warning: http://mcforge.readthedocs.io/en/latest/networking/simpleimpl/

But

2 hours ago, GiantNuker said:

serverPlayer.getServerWorld().addScheduledTask(() -> {
    serverPlayer.addVelocity(motionX, motionY, motionZ);
});

I'm not changing anything on the Packet thread. It was reading the information right though.

  • Author
2 minutes ago, diesieben07 said:
  • You are still reading yaw and pitch on the network thread.
  • Players do not have motion on the server. The client just sends a new position every tick.

so - set velocity on the client?

  • Author
6 minutes ago, diesieben07 said:

Yes, player movement is completely client-side, the server only validates that the player is not doing something stupid.

Thanks!!!!:D

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.