mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
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:
parent
2e4544fc5a
commit
cb00c28b6e
10 changed files with 661 additions and 91 deletions
|
|
@ -31,6 +31,8 @@ namespace MinecraftClient
|
|||
public void BotUnLoad(ChatBot b) { bots.RemoveAll(item => object.ReferenceEquals(item, b)); }
|
||||
public void BotClear() { bots.Clear(); }
|
||||
|
||||
private object locationLock = new object();
|
||||
private World world = new World();
|
||||
private Location location;
|
||||
private int updateTicks = 0;
|
||||
|
||||
|
|
@ -46,6 +48,7 @@ namespace MinecraftClient
|
|||
public string GetUserUUID() { return uuid; }
|
||||
public string GetSessionID() { return sessionid; }
|
||||
public Location GetCurrentLocation() { return location; }
|
||||
public World GetWorld() { return world; }
|
||||
|
||||
TcpClient client;
|
||||
IMinecraftCom handler;
|
||||
|
|
@ -345,11 +348,14 @@ namespace MinecraftClient
|
|||
|
||||
public void UpdateLocation(Location location, bool relative)
|
||||
{
|
||||
if (relative)
|
||||
lock (locationLock)
|
||||
{
|
||||
this.location += location;
|
||||
if (relative)
|
||||
{
|
||||
this.location += location;
|
||||
}
|
||||
else this.location = location;
|
||||
}
|
||||
else this.location = location;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -448,7 +454,14 @@ namespace MinecraftClient
|
|||
{
|
||||
if (updateTicks >= 10)
|
||||
{
|
||||
handler.SendLocationUpdate(location, true); //TODO handle onGround once terrain data is available
|
||||
lock (locationLock)
|
||||
{
|
||||
Location belowMe = location + new Location(0, -1, 0);
|
||||
Block blockBelowMe = world.GetBlock(belowMe);
|
||||
handler.SendLocationUpdate(location, blockBelowMe.Solid);
|
||||
if (!blockBelowMe.Solid)
|
||||
location = belowMe;
|
||||
}
|
||||
updateTicks = 0;
|
||||
}
|
||||
updateTicks++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue