mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +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>
|
/// <returns><c>true</c> if the teleport was successful.</returns>
|
||||||
public virtual bool teleport(Location location)
|
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);
|
SetLocation(location);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ public class Player : HumanEntity, OfflinePlayer, CommandSender
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool teleport(Location location)
|
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);
|
SetLocation(location);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,22 @@ void __cdecl NativeTeleportEntity(int entityId, int dimId, double x, double y, d
|
||||||
auto player = FindPlayer(entityId);
|
auto player = FindPlayer(entityId);
|
||||||
if (player && player->connection)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
ServerLevel *level = GetLevel(dimId);
|
ServerLevel *level = GetLevel(dimId);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue