switch two players in places

Started by drum on

Topic category: Help with MCreator software

Last seen on 23:24, 17. Oct 2024
Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
switch two players in places

I want, but I can't implement the functionality of the projectile, which should change their places when hit in essence. Help me implement this

Last seen on 22:08, 17. Oct 2024
Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well, you'd have to, Save…
Thu, 10/17/2024 - 21:37

Well, you'd have to,

  1. Save both the player's positions
  2. Teleport player one to player two's position
  3. Teleport player two to player one's position

(Assuming you're making a custom projectile using the Projectile mod element..)

Last seen on 22:06, 17. Oct 2024
Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
package net.mcreator…
Thu, 10/17/2024 - 21:51
package net.mcreator.maniacweapons.procedures;

/* imports omitted */

public class SwapPlayersProcedure {
	public static void execute(LevelAccessor world, DamageSource damagesource, Entity entity) {
		if (damagesource == null || entity == null)
			return;
		ManiacweaponsModVariables.MapVariables.get(world).playerXTarget = entity.getX();
		ManiacweaponsModVariables.MapVariables.get(world).syncData(world);
		ManiacweaponsModVariables.MapVariables.get(world).playerYTarget = entity.getY();
		ManiacweaponsModVariables.MapVariables.get(world).syncData(world);
		ManiacweaponsModVariables.MapVariables.get(world).playerZTarget = entity.getZ();
		ManiacweaponsModVariables.MapVariables.get(world).syncData(world);
		ManiacweaponsModVariables.MapVariables.get(world).playerX = (damagesource.getDirectEntity()).getZ();
		ManiacweaponsModVariables.MapVariables.get(world).syncData(world);
		ManiacweaponsModVariables.MapVariables.get(world).playerY = (damagesource.getDirectEntity()).getY();
		ManiacweaponsModVariables.MapVariables.get(world).syncData(world);
		ManiacweaponsModVariables.MapVariables.get(world).playerZ = (damagesource.getDirectEntity()).getX();
		ManiacweaponsModVariables.MapVariables.get(world).syncData(world);
		{
			Entity _ent = entity;
			_ent.teleportTo(ManiacweaponsModVariables.MapVariables.get(world).playerX, ManiacweaponsModVariables.MapVariables.get(world).playerY, ManiacweaponsModVariables.MapVariables.get(world).playerZ);
			if (_ent instanceof ServerPlayer _serverPlayer)
				_serverPlayer.connection.teleport(ManiacweaponsModVariables.MapVariables.get(world).playerX, ManiacweaponsModVariables.MapVariables.get(world).playerY, ManiacweaponsModVariables.MapVariables.get(world).playerZ, _ent.getYRot(),
						_ent.getXRot());
		}
		{
			Entity _ent = entity;
			_ent.teleportTo(ManiacweaponsModVariables.MapVariables.get(world).playerXTarget, ManiacweaponsModVariables.MapVariables.get(world).playerYTarget, ManiacweaponsModVariables.MapVariables.get(world).playerZTarget);
			if (_ent instanceof ServerPlayer _serverPlayer)
				_serverPlayer.connection.teleport(ManiacweaponsModVariables.MapVariables.get(world).playerXTarget, ManiacweaponsModVariables.MapVariables.get(world).playerYTarget, ManiacweaponsModVariables.MapVariables.get(world).playerZTarget,
						_ent.getYRot(), _ent.getXRot());
		}
	}
}

this code i cant bind with trigger "when projectile hits player"

Last seen on 22:08, 17. Oct 2024
Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
use this
Thu, 10/17/2024 - 21:57

use this

Last seen on 22:06, 17. Oct 2024
Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
maybe I don't understand…
Thu, 10/17/2024 - 22:00

maybe I don't understand something...but he writes to me that there are not enough dependencies, but if I remove blocks with variable changes, it starts to connect...

 

Last seen on 22:08, 17. Oct 2024
Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Send a screenshot of your…
Thu, 10/17/2024 - 22:02

Send a screenshot of your procedure

Last seen on 22:45, 17. Oct 2024
Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(No subject)
Thu, 10/17/2024 - 22:11

Last seen on 22:45, 17. Oct 2024
Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
and where can I find these…
Thu, 10/17/2024 - 22:22

and where can I find these blocks? just looking through all the tabs, I didn't find them.

Last seen on 22:45, 17. Oct 2024
Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you have to type "entity", …
Thu, 10/17/2024 - 22:24

you have to type "entity", "sourceentity", etc. yourself into the "entity dependency" block

Last seen on 23:24, 17. Oct 2024
Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've tried a lot of…
Thu, 10/17/2024 - 23:24

I've tried a lot of teleportation options and this is the only one close to what I want. In it, I teleport to the mob, but he doesn't.  If I specify the coordinates differently, then me and the mobs will just teleport up a couple of blocks and no more

this code that is shown above works as I described in the last sentence