diff --git a/Minecraft.Server.FourKit/Entity/Entity.cs b/Minecraft.Server.FourKit/Entity/Entity.cs
index 95f52d697..d6b60a8f2 100644
--- a/Minecraft.Server.FourKit/Entity/Entity.cs
+++ b/Minecraft.Server.FourKit/Entity/Entity.cs
@@ -49,7 +49,8 @@ public class Entity
/// true if the teleport was successful.
public virtual bool teleport(Location location)
{
- NativeBridge.TeleportEntity?.Invoke(getEntityId(), _dimensionId, location.getX(), location.getY(), location.getZ());
+ int targetDimId = location.LocationWorld?.getDimensionId() ?? _dimensionId;
+ NativeBridge.TeleportEntity?.Invoke(getEntityId(), targetDimId, location.getX(), location.getY(), location.getZ());
SetLocation(location);
return true;
}
diff --git a/Minecraft.Server.FourKit/Entity/Player.cs b/Minecraft.Server.FourKit/Entity/Player.cs
index e46930485..85adac143 100644
--- a/Minecraft.Server.FourKit/Entity/Player.cs
+++ b/Minecraft.Server.FourKit/Entity/Player.cs
@@ -44,7 +44,8 @@ public class Player : HumanEntity, OfflinePlayer, CommandSender
///
public override bool teleport(Location location)
{
- NativeBridge.TeleportPlayer?.Invoke(getEntityId(), location.X, location.Y, location.Z);
+ int targetDimId = location.LocationWorld?.getDimensionId() ?? getLocation().LocationWorld?.getDimensionId() ?? 0;
+ NativeBridge.TeleportEntity?.Invoke(getEntityId(), targetDimId, location.X, location.Y, location.Z);
SetLocation(location);
return true;
}
diff --git a/Minecraft.Server/FourKitNatives.cpp b/Minecraft.Server/FourKitNatives.cpp
index 56eaf5cac..4f5c3af02 100644
--- a/Minecraft.Server/FourKitNatives.cpp
+++ b/Minecraft.Server/FourKitNatives.cpp
@@ -260,7 +260,22 @@ void __cdecl NativeTeleportEntity(int entityId, int dimId, double x, double y, d
auto player = FindPlayer(entityId);
if (player && player->connection)
{
- player->connection->teleport(x, y, z, player->yRot, player->xRot);
+ double outX = x, outY = y, outZ = z;
+ bool cancelled = FirePlayerTeleport(entityId,
+ player->x, player->y, player->z, player->dimension,
+ x, y, z, dimId,
+ 2 /* PLUGIN */,
+ &outX, &outY, &outZ
+ );
+
+ if (!cancelled)
+ {
+ if (dimId != player->dimension)
+ {
+ MinecraftServer::getInstance()->getPlayers()->toggleDimension(player, dimId);
+ }
+ player->connection->teleport(outX, outY, outZ, player->yRot, player->xRot);
+ }
return;
}
ServerLevel *level = GetLevel(dimId);