August 23, 20223 yr You can change a player's speed using Attributes.MOVEMENT_SPEED either directly or using a MobEffect like MobEffects.MOVEMENT_SLOWDOWN A different way is to look at WebBlock (cobwebs). There are probably other ways you can do it. I don't think any of these affect spectator mode players? They have noPhysics set to true. A probably glitchy way would be to do something in PlayerTickEvent that remembers where you want them and teleports them back to that location if they move. Edited August 23, 20223 yr by warjort Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
August 23, 20223 yr Author 4 minutes ago, warjort said: A probably glitchy way would be to do something in PlayerTickEvent that remembers where you want them and teleports them back to that location if they move. i tried this: @SubscribeEvent public static void playerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); player.getAttribute(Attributes.MAX_HEALTH).setBaseValue(playerhealth - 2); if (playerhealth == 2) { ((ServerPlayer) player).setGameMode(GameType.SPECTATOR); Vec3 playerPos = player.position(); teleportPlayer (player, playerPos); } } static void teleportPlayer(Player player, Vec3 position) { while (playerhealth == 0) { player.setpos(position); } } but it just crashed me...without crashing me. basically nothing worked anymore from what i know, because i was stuck in spectator and commands didn't work anymore
August 23, 20223 yr while (playerhealth == 0) { player.setpos(position); } You know what an infinite loop is? Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
August 23, 20223 yr Author an infinite loop is a loop that keeps looping until that condition is met, right?
August 23, 20223 yr Do you think player.setPos() ever changes the playerHeath value? This is also not the correct way to teleport an entity anyway. I also don't see what setting a player's position to its current position achieves, beyond redundant work? And just doing it at respawn isn't going to affect the player after that. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
September 15, 20223 yr Pretty sure you can just use a mixin on PlayerEntity and override the "isImmobile" method
September 15, 20223 yr Mixin is the last thing you should use, it's in no way recommend and officially not supported on this Forum. In general it's better to create a PR to Forge to add a Hook or a Event for this that to use Mixin.
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.