LogicTechCorp Posted February 18, 2017 Posted February 18, 2017 I have a potion that I would like to freeze the player when they are affected by it. What would be the best way to achieve this? Quote
Leomelonseeds Posted February 18, 2017 Posted February 18, 2017 Try teleporting the player to the same position on update. Quote Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.
LogicTechCorp Posted February 18, 2017 Author Posted February 18, 2017 11 minutes ago, Leomelonseeds said: Try teleporting the player to the same position on update. Thanks, that works. Now, how would I stop the player from using items or placing blocks? Quote
Leomelonseeds Posted February 18, 2017 Posted February 18, 2017 (edited) When the player tries to place a block, delete the block, and give the same block back.(not sure if theres a simpler method for this). I dont know about items... EDIT: Look at playerInteractEvent. Edited February 18, 2017 by Leomelonseeds Quote Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.
Kriptikz Posted February 18, 2017 Posted February 18, 2017 (edited) I just created a spell like this, although I didn't test it in multiplayer yet. I created a player capability with 3 variables: ticksStunned, isStunned, and stunDuration. So when the player is hit by the potion you would set isStunned to true and set the stunDuration. use PlayerTickEvent and make sure ur on phase START, check if the world is remote, if it is check if the player is stunned from the capability. if they are stunned increment ticksStunned. then check if they are stunned && (ticksStunned % stunDuration != 0) and if that is true do KeyBinding.unPressAllKeys(); else set isStunned to false and reset ticksStunned to 0; That stops all keyboard input except the esc key(or whatever pause game key is), open inventory key, and hotbar hotkeys. Then u need another event for the mouse called MouseEvent, this is client side only so no need to check isRemote here. in here just check if the player isStunned and if they are event.setCanceled(true); if they aren't getting stunned for long enough or something like that isn't working right you may need to use packets to sync data from server to client or vice verse, I haven't fully tested this so idk if you can get away without packets here yet. Edited February 18, 2017 by Kriptikz Quote
Leomelonseeds Posted February 18, 2017 Posted February 18, 2017 *clapclapclapclap* Quote Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.
Recommended Posts
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.