Jump to content

[SOLVED] [1.11.2] Any way to "Stun" the player


Alanzote

Recommended Posts

I've been looking on a way to "stun" the player. I created this tile entity that teleports players around, however, it takes a while to "cast" in order to teleport, is there any way to keep the player from moving during this "cast"?

 

EDIT: It takes a while to transport the player because of the nice sound it has xD

 

Thanks,

Alanzote.

Link to comment
Share on other sites

You could set EntityPlayer#motionX, EntityPlayer#motionY and EntityPlayer#motionZ to zero every tick of the tile entity. Beware that this needs to be done on the client.

I got to keep 1 variable synced in the client and in the server, I forgot how to do that :/

 

Edit: Networking messages?

Link to comment
Share on other sites

You need to tell the player's client that they're not allowed to move.  The entity motionX/Y/Z values don't actually do anything on the server with regards to the player.

 

Couple ways to potentially handle it:

1) intercept/cancel the input during the keypress event

2) prevent the motion the key input causes (I believe that this would be the entity motionX/Y/Z values)

3) This wouldn't require custom packets at all: hit the player with X seconds of Slowness 7.

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.

Link to comment
Share on other sites

Because you are doing this in a tile entity you can also make a server side countdown for the cast and when the player first arrives at the tile entity (before the cast) and after the cast completed, you change a boolean and call notifyBlockUpdate() (I think that is what it is called) to sync the changed boolean to the client.

Link to comment
Share on other sites

Slowness 7 worked, but it adds an effect in the screen, which, kind of removes the seen particle effects that the tileentity spawns.

The notifyBlockUpdate() function does not exist, there is a notify() and notifyAll() function, but I don't think I understand what those do.

Link to comment
Share on other sites

The methods notify() and notifyAll() are from java.lang.Object.class. The method needs parameters I mentioned has parameters.

 

And because they're from the Object class, they will totally do what you need them to.

(Hint: no they won't because vanilla hasn't overridden them to do anything)

 

If you don't want the FOV change then you'll have to use methods 1 or 2 that I suggested.  You'll need to use packets.

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.

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.

Announcements



×
×
  • Create New...

Important Information

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