Add world handling (and fall to ground)

- World is now properly parsed and stored from chunk data
- Block changes are also handled and world updated accordingly
- Added ground checking, the player will move down to reach the ground
- Performance tweaking in Protocol18, using lists instead of arrays
- Fix player look not properly skipped causing invalid location after
teleport
This commit is contained in:
ORelio 2015-11-30 15:30:49 +01:00
parent 2e4544fc5a
commit cb00c28b6e
10 changed files with 661 additions and 91 deletions

View file

@ -46,6 +46,72 @@ namespace MinecraftClient.Mapping
Z = z;
}
/// <summary>
/// The X index of the corresponding chunk in the world
/// </summary>
public int ChunkX
{
get
{
return ((int)X) / Chunk.SizeX;
}
}
/// <summary>
/// The Y index of the corresponding chunk in the world
/// </summary>
public int ChunkY
{
get
{
return ((int)Y) / Chunk.SizeY;
}
}
/// <summary>
/// The Z index of the corresponding chunk in the world
/// </summary>
public int ChunkZ
{
get
{
return ((int)Z) / Chunk.SizeY;
}
}
/// <summary>
/// The X index of the corresponding block in the corresponding chunk of the world
/// </summary>
public int ChunkBlockX
{
get
{
return ((int)X) % Chunk.SizeX;
}
}
/// <summary>
/// The Y index of the corresponding block in the corresponding chunk of the world
/// </summary>
public int ChunkBlockY
{
get
{
return ((int)Y) % Chunk.SizeY;
}
}
/// <summary>
/// The Z index of the corresponding block in the corresponding chunk of the world
/// </summary>
public int ChunkBlockZ
{
get
{
return ((int)Z) % Chunk.SizeZ;
}
}
/// <summary>
/// Compare two locations. Locations are equals if the integer part of their coordinates are equals.
/// </summary>
@ -155,5 +221,14 @@ namespace MinecraftClient.Mapping
| (((int)Y) & ~((~0) << 13)) << 13
| (((int)Z) & ~((~0) << 06)) << 00;
}
/// <summary>
/// Convert the location into a string representation
/// </summary>
/// <returns>String representation of the location</returns>
public override string ToString()
{
return String.Format("X:{0} Y:{1} Z:{2}", X, Y, Z);
}
}
}