fix dimension travel throu teleport

This commit is contained in:
sylvessa 2026-03-28 23:44:00 -05:00
parent 599d504f55
commit ebb7b2abfd
3 changed files with 20 additions and 3 deletions

View file

@ -49,7 +49,8 @@ public class Entity
/// <returns><c>true</c> if the teleport was successful.</returns>
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;
}

View file

@ -44,7 +44,8 @@ public class Player : HumanEntity, OfflinePlayer, CommandSender
/// <inheritdoc/>
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;
}

View file

@ -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);