mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-06 22:11:02 +00:00
fix dimension travel throu teleport
This commit is contained in:
parent
599d504f55
commit
ebb7b2abfd
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue