Jump to content

Recommended Posts

Posted

So I've noticed that if I try to get Player's delta movement, it returns some values on Client, but on Server, the vector is just a bunch of zeros.

I'm guessing this is because Player movement is mainly handled on Client, but I'd like to ask if there's any way to get Player's movement on Server (for example, if there was a block the Player could pass through only at a certain speed along one axis, or if the block would save Player momentum and then set that Player's momentum again when needed).

  • 2 weeks later...
Posted

Player movement is handled on the client normally. The information is synced to the server, however. If you want to set the player position or data on the server, you basically need to sync the data to the client. You can do this by setting Entity#hurtMarked to true after setting the delta movement.

Posted

I already know how to sync it to the Client from the Server, that's not a problem. But I can't get it to sync from the Client to Server with Entity#hurtMarked, that's the problem. If I try to get the delta movement on Server, the vector looks like this: (0.0, 0.0, 0.0) so saving it and then applying it to the Entity just makes it stop.

Are there any other methods Minecraft uses for syncing to Server?

Posted

Alright, so for a second I thought I had a solution when I remembered the old position Entities use for lerping is public

public final Vec3 getPosition(float p_20319_) {
      double d0 = Mth.lerp((double)p_20319_, this.xo, this.getX());
      double d1 = Mth.lerp((double)p_20319_, this.yo, this.getY());
      double d2 = Mth.lerp((double)p_20319_, this.zo, this.getZ());
      return new Vec3(d0, d1, d2);
   }

and while I was able to get the position on server, I found out the old position is identical to the current position (both on client and server), which means if I subtract it from the current position, I still get 0.0, what's up with that? I how can the game lerp motion if the two positions are the same?

Posted
19 hours ago, Povstalec said:

But I can't get it to sync from the Client to Server with Entity#hurtMarked, that's the problem.

That field syncs it from the server to the client.

19 hours ago, Povstalec said:

If I try to get the delta movement on Server, the vector looks like this: (0.0, 0.0, 0.0) so saving it and then applying it to the Entity just makes it stop.

Makes sense since the delta movement is not necessary for syncing, only the position and rotation.

17 hours ago, Povstalec said:

I how can the game lerp motion if the two positions are the same?

You can't, lerping is not supposed to be done on the server anyways as it is meant for handling smoother animations on the client when rendering to the screen. You should just be using the raw position values if you want to use them.

 

Once again, player movement is handled on the client. The only information synced to the server is those that need to be sent to all players, which in terms of movement can typically be boiled down to (as an oversimplification) position and rotation. If you want other values, you'll need to sync them yourself using a packet. Using Entity#hurtMarked will allow you to sync the values you set on the server back to the client afterward.

Posted (edited)
22 minutes ago, ChampionAsh5357 said:

You can't, lerping is not supposed to be done on the server anyways as it is meant for handling smoother animations on the client when rendering to the screen.

Oh no, I don't want to do any lerping, I know it's just for client (though I can see why it may have sounded like I do, I should have worded it better). I was just commenting on how baffled I am by the fact that the old values are the same as the new values, since I was expecting them to be different (especially in the case of lerping).

22 minutes ago, ChampionAsh5357 said:

You should just be using the raw position values if you want to use them.

That's what I tried to do when I found out the old values and new values are idetical. Then after some more testing, I realized they're identical only on the server.

 

22 minutes ago, ChampionAsh5357 said:

Using Entity#hurtMarked will allow you to sync the values you set on the server back to the client afterward.

In terms of syncing, I've found ClientboundSetEntityMotionPacket that does the job pretty well.

Edited by Povstalec
Posted
5 hours ago, Povstalec said:

In terms of syncing, I've found ClientboundSetEntityMotionPacket that does the job pretty well.

Yep, that's what Entity#hurtMarked calls.

5 hours ago, Povstalec said:

I was just commenting on how baffled I am by the fact that the old values are the same as the new values, since I was expecting them to be different

It's not necessary on the server as it's handled on the client. Delta movement doesn't need to be known on the server since it doesn't affect anything. When the delta movement is applied to the player on server, it is typically by setting the method I mentioned above which adds the movement to the player on the client.

  • 7 months later...
Posted (edited)

I assume that your issue is trying to get the delta movement of the server player and the return result is (0.0, 0.0, 0.0) even though that player is walking around, however, the true delta movement is handled by the client player (or local player) at Minecraft.getInstance().player and you can get the delta movement from this. To get that from another player on the server, you can try using SimpleChannel (read this at Forge Documentation: SimpleImpl). By making the clients with your mod installed send to the server the local player's movement data and making the server send this to other clients, you can get the true delta movement of the players.

Edited by sonnynguyen

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi,  I'm using Forge 47.3.0 for Minecraft 1.20.1 I apologise if this is obvious I am very new to modding for Minecraft. I sucessfully made a mod that launched without errors or crashes (without it doing anything) but in order to add the features I need, I need to add "Custom Portal API [Forge]" as a dependency. However no matter the way I've tried to acheive this, it crashes. I am pretty sure it's not the way I'm putting it in the repositories, the dependencies or the way I'm refrencing it, as I've a hundred diffrent combinations and multiple Maven methods. And on all those diffrent variations I still get this crash: pastebin.com/UhumzZCZ Any tips would be invaluable as I've been loosing my mind over this!
    • Hi, i'm really having problems trying to set the texture to my custom item. I thought i'm doing everything correctly, but all i see is the missing texture block for my item. I am trying this for over a week now and getting really frustrated. The only time i could make the texture work, was when i used an older Forge version (52.0.1) for Minecraft (1.21.4). Was there a fundamental change for textures and models somewhere between versions that i'm missing? I started with Forge 54.1.0 and had this problem, so in my frustration i tried many things: Upgrading to Forge 54.1.1, created multiple new projects, workspaces, redownloaded everything and setting things up multiple times, as it was suggested in an older thread. Therea are no errors in the console logs, but maybe i'm blind, so i pasted the console logs to pastebin anyway: https://pastebin.com/zAM8RiUN The only time i see an error is when i change the models JSON file to an incorrect JSON which makes sense and that suggests to me it is actually reading the JSON file.   I set the github repository to public, i would be so thankful if anyone could take a look and tell me what i did wrong: https://github.com/xLorkin/teleport_pug_forge   As a note: i'm pretty new to modding, this is my first mod ever. But i'm used to programming. I had some up and downs, but through reading the documentation, using google and experimenting, i could solve all other problems. I only started modding for Minecraft because my son is such a big fan and wanted this mod.
    • Please read the FAQ (link in orange bar at top of page), and post logs as described there.
    • Hello fellow Minecrafters! I recently returned to Minecraft and realized I needed a wiki that displays basic information easily and had great user navigation. That’s why I decided to build: MinecraftSearch — a site by a Minecraft fan, for Minecraft fans. Key Features So Far Straight-to-the-Point Info: No extra fluff; just the essentials on items, mobs, recipes, loot and more. Clean & Intuitive Layout: Easy navigation so you spend less time scrolling and more time playing. Optimized Search: Search for anything—items, mobs, blocks—and get results instantly. What I’m Thinking of Adding More data/information: Catch chances for fishing rod, traveling villager trades, biomes info and a lot more. The website is still under development and need a lot more data added. Community Contributions: Potential for user-uploaded tips for items/mobs/blocks in the future. Feature Requests Welcome: Your ideas could shape how the wiki evolves! You can see my roadmap at the About page https://minecraftsearch.com/about I’d love for you to check out MinecraftSearch and see if it helps you find the info you need faster. Feedback is crucial—I want to develop this further based on what the community needs most, so please let me know what you think. Thanks, and happy crafting!
    • Instructions on how to install newer Java can be found in the FAQ
  • Topics

×
×
  • Create New...

Important Information

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