Add block material database

Taken from Bukkit's Material class, with credits.
Allows to know types and properties of blocks.
+ Use database for "is solid" checks
+ Add "can harm players" method
+ Faster movements, falling seems natural now
+ Shorter error message when ping failed
This commit is contained in:
ORelio 2015-12-09 23:04:00 +01:00
parent 5d8d42e3d1
commit 49702e30b8
6 changed files with 367 additions and 30 deletions

View file

@ -34,7 +34,6 @@ namespace MinecraftClient
private object locationLock = new object();
private World world = new World();
private Location location;
private int updateTicks = 0;
private string host;
private int port;
@ -452,23 +451,18 @@ namespace MinecraftClient
if (Settings.TerrainAndMovements)
{
if (updateTicks >= 10)
lock (locationLock)
{
lock (locationLock)
{
Location onFoots = new Location(location.X, Math.Floor(location.Y), location.Z);
Location belowFoots = location + new Location(0, -1, 0);
Block blockOnFoots = world.GetBlock(onFoots);
Block blockBelowFoots = world.GetBlock(belowFoots);
handler.SendLocationUpdate(location, blockBelowFoots.Solid);
if (!blockBelowFoots.Solid)
location = belowFoots;
else if (!blockOnFoots.Solid)
location = onFoots;
}
updateTicks = 0;
Location onFoots = new Location(location.X, Math.Floor(location.Y), location.Z);
Location belowFoots = location + new Location(0, -1, 0);
Block blockOnFoots = world.GetBlock(onFoots);
Block blockBelowFoots = world.GetBlock(belowFoots);
handler.SendLocationUpdate(location, blockBelowFoots.Type.IsSolid());
if (!blockBelowFoots.Type.IsSolid())
location = belowFoots;
else if (!blockOnFoots.Type.IsSolid())
location = onFoots;
}
updateTicks++;
}
}