Jump to content

Recommended Posts

Posted (edited)

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 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.

Posted
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

Posted
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.

Posted

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.

  • 4 weeks later...
Posted

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.

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.