switch two players in places

Started by drum on

Topic category: Help with MCreator software

Active 5 months ago
Joined Oct 2024
Points:
49

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 12
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

Active 1 hour ago
Joined Dec 2014
Points:
1067

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 642
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..)

Active 5 months ago
Joined Oct 2024
Points:
49

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 12
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"

Active 1 hour ago
Joined Dec 2014
Points:
1067

User statistics:

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

use this

Active 5 months ago
Joined Oct 2024
Points:
49

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 12
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...

 

Active 1 hour ago
Joined Dec 2014
Points:
1067

User statistics:

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

Send a screenshot of your procedure

Active 5 months ago
Joined Oct 2024
Points:
49

User statistics:

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

Active 5 months ago
Joined Oct 2024
Points:
49

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 12
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.

Active 1 hour ago
Joined Dec 2014
Points:
1067

User statistics:

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

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

Active 5 months ago
Joined Oct 2024
Points:
49

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 12
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