Jump to content

[1.12.2][SOLVED] Preventing players from moving


Sunser

Recommended Posts

Hi everyone,

 

I'm trying to prevent unlogged players to do anything. My next challenge is to prevent players from moving, but I can't find anything that satisfies me.
 

I've been looking into EntityPlayerMP class hierachy and I've found the SPacketPlayerPosLook class, which is sent when a player wants to move.

I wonder if there is a way to stop it. I've been looking from a triggered Event when a packet is sent but I did not find.

 

I've also took a look at the doc and tried to understand how things work but I did not find yet a way to achieve it.

I wonder if an override of the

IMessageHandler::onMessage(SomeIMessage req, MessageContext ctx)

method would make it.

Any suggestions ? Thanks for your time.

Edited by Sunser
Link to comment
Share on other sites

Take a look at what the slowness effect does

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

2 hours ago, V0idWa1k3r said:

The player movement happens entirely on the client, it just periodically sends packets to the server notifying it of the new position. So your options are either reset the player's position each tick on the server or cancel the input on the client.

I was afraid I have to do this.

2 hours ago, Cadiboo said:

Take a look at what the slowness effect does

Someone already recommanded it in another post. I'll take a look.

 

Thank you both. I will update the post's status as soon as I get something functional.

Link to comment
Share on other sites

I've tried adding a huge Slowness effect to some players. This works great but they can still move by jumping.

So I've been looking for the other idea but I did not find a way to make it being called every tick.

I've been thinking about the onUpdate() method but I haven't found how to link my method and that.

Any suggestions ? Thanks for your time.

Link to comment
Share on other sites

1 hour ago, Sunser said:

but I did not find a way to make it being called every tick.

I've been thinking about the onUpdate() method but I haven't found how to link my method and that.

Any suggestions ? Thanks for your time.

Use the PlayerTickEvent.

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.

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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