Skip to content

Commit

Permalink
Allow tping to coords and setting portal past 1024, fix falling throu…
Browse files Browse the repository at this point in the history
…gh block when tping to coord just above a block
  • Loading branch information
UnknownShadow200 committed May 20, 2017
1 parent 702ef1b commit 8541f96
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 35 deletions.
52 changes: 24 additions & 28 deletions fCraft/Commands/ModerationCommands.cs
Expand Up @@ -1414,10 +1414,10 @@ static void UnfreezeHandler(Player player, CommandReader cmd)
Vector3I P = player.World.map.HighestFreeSpace(zone.Bounds.XCentre, Vector3I P = player.World.map.HighestFreeSpace(zone.Bounds.XCentre,
zone.Bounds.YCentre, zone.Bounds.ZCentre); zone.Bounds.YCentre, zone.Bounds.ZCentre);
Position zPos = new Position(P.X * 32 + 16, P.Y * 32 + 16, P.Z * 32 + (51 + 1)); Position zPos = new Position(P.X * 32 + 16, P.Y * 32 + 16, P.Z * 32 + (51 + 1));
if (player.World != null) { if (player.World != null) {
player.LastWorld = player.World; player.LastWorld = player.World;
player.LastPosition = player.Position; player.LastPosition = player.Position;
} }
player.TeleportTo((zPos)); player.TeleportTo((zPos));
player.Message("Teleporting you to zone " + zone.ClassyName); player.Message("Teleporting you to zone " + zone.ClassyName);
return; return;
Expand All @@ -1430,10 +1430,10 @@ static void UnfreezeHandler(Player player, CommandReader cmd)
int z = (player.Position.Z - 51) / 32; int z = (player.Position.Z - 51) / 32;
Vector3I P = player.WorldMap.HighestFreeSpace(x, y, z); Vector3I P = player.WorldMap.HighestFreeSpace(x, y, z);


if (player.World != null) { if (player.World != null) {
player.LastWorld = player.World; player.LastWorld = player.World;
player.LastPosition = player.Position; player.LastPosition = player.Position;
} }
player.TeleportTo(new Position { player.TeleportTo(new Position {
X = (P.X * 32 + 16), X = (P.X * 32 + 16),
Y = (P.Y * 32 + 16), Y = (P.Y * 32 + 16),
Expand Down Expand Up @@ -1465,22 +1465,18 @@ static void UnfreezeHandler(Player player, CommandReader cmd)
} }
} }
} }
if (x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024) {
player.Message("Coordinates are outside the valid range!"); if (player.World != null) {

player.LastWorld = player.World;
} else { player.LastPosition = player.Position;
if (player.World != null) {
player.LastWorld = player.World;
player.LastPosition = player.Position;
}
player.TeleportTo(new Position {
X = (x*32 + 16),
Y = (y*32 + 16),
Z = (z*32 + 48),
R = (byte) rot,
L = (byte) lot
});
} }
player.TeleportTo(new Position {
X = (x*32 + 16),
Y = (y*32 + 16),
Z = (z*32 + 52),
R = (byte) rot,
L = (byte) lot
});
} else { } else {
CdTeleport.PrintUsage(player); CdTeleport.PrintUsage(player);
} }
Expand Down Expand Up @@ -1514,11 +1510,11 @@ static void UnfreezeHandler(Player player, CommandReader cmd)
return; return;
} }


if (targetWorld == player.World) { if (targetWorld == player.World) {
if (player.World != null) { if (player.World != null) {
player.LastWorld = player.World; player.LastWorld = player.World;
player.LastPosition = player.Position; player.LastPosition = player.Position;
} }
player.TeleportTo(target.Position); player.TeleportTo(target.Position);


} else { } else {
Expand Down
8 changes: 1 addition & 7 deletions fCraft/Commands/WorldCommands.cs
Expand Up @@ -3678,13 +3678,7 @@ static void WorldClearHandler(Player player, CommandReader cmd)
lot = player.Position.L; lot = player.Position.L;
} }
} }

player.PortalTPPos = new Position(x * 32, y * 32, z * 32, (byte)rot, (byte)lot);
if (x < 0 || x >= 1024 || y < 0 || y >= 1024 || z < 0 || z >= 1024) {
player.Message("Coordinates are outside the valid range!");
return;
} else {
player.PortalTPPos = new Position(x * 32, y * 32, z * 32, (byte)rot, (byte)lot);
}
} else { } else {
player.PortalTPPos = tpWorld.map == null ? new Position(0, 0, 0) : tpWorld.map.Spawn; player.PortalTPPos = tpWorld.map == null ? new Position(0, 0, 0) : tpWorld.map.Spawn;
} }
Expand Down

0 comments on commit 8541f96

Please sign in to comment.