Jump to content

Recommended Posts

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)

Posted

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.

Posted
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?

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.