mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 17:47:12 -04:00
Add proper respawning.
This commit is contained in:
parent
a91dd49963
commit
0dc008b11e
@ -252,7 +252,21 @@ namespace ClassicalSharp {
|
||||
|
||||
internal void HandleKeyDown( Key key ) {
|
||||
if( key == game.Keys[KeyMapping.Respawn] && canRespawn ) {
|
||||
LocationUpdate update = LocationUpdate.MakePos( SpawnPoint, false );
|
||||
Vector3I p = Vector3I.Floor( SpawnPoint );
|
||||
if( game.Map.IsValidPos( p ) ) {
|
||||
// Spawn player at highest valid position.
|
||||
for( int y = p.Y; y <= game.Map.Height; y++ ) {
|
||||
byte block1 = GetPhysicsBlockId( p.X, y, p.Z );
|
||||
byte block2 = GetPhysicsBlockId( p.X, y + 1, p.Z );
|
||||
if( info.CollideType[block1] != BlockCollideType.Solid &&
|
||||
info.CollideType[block2] != BlockCollideType.Solid ) {
|
||||
p.Y = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Vector3 spawn = (Vector3)p + new Vector3( 0.5f, 0.01f, 0.5f );
|
||||
LocationUpdate update = LocationUpdate.MakePos( spawn, false );
|
||||
SetLocation( update, false );
|
||||
} else if( key == game.Keys[KeyMapping.SetSpawn] && canRespawn ) {
|
||||
SpawnPoint = Position;
|
||||
|
Loading…
x
Reference in New Issue
Block a user