Physics: fix trains colliding into each other causing one to disappear permanently (Thanks TheChellMaster), also fix drowning (Thanks JPlaysClassic)

This commit is contained in:
UnknownShadow200 2017-01-06 22:13:19 +11:00
parent 18f71f8c23
commit 80c3628ee2
2 changed files with 14 additions and 11 deletions

View File

@ -29,24 +29,25 @@ namespace MCGalaxy.Blocks.Physics {
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
for (int cx = -dirX; cx != 2 * dirX; cx += dirX)
for (int cy = -dirY; cy != 2 * dirY; cy += dirY)
for (int cz = -dirZ; cz != 2 * dirZ; cz += dirZ)
for (int dx = -dirX; dx != 2 * dirX; dx += dirX)
for (int dy = -dirY; dy != 2 * dirY; dy += dirY)
for (int dz = -dirZ; dz != 2 * dirZ; dz += dirZ)
{
byte tileBelow = lvl.GetTile((ushort)(x + cx),(ushort)(y + cy - 1), (ushort)(z + cz));
byte tile = lvl.GetTile((ushort)(x + cx), (ushort)(y + cy), (ushort)(z + cz));
byte tileBelow = lvl.GetTile((ushort)(x + dx),(ushort)(y + dy - 1), (ushort)(z + dz));
byte tile = lvl.GetTile((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz));
bool isRails = false;
if (tileBelow != Block.custom_block) {
isRails = Block.Props[tileBelow].IsRails;
} else {
byte extBelow = lvl.GetExtTile((ushort)(x + cx), (ushort)(y + cy - 1), (ushort)(z + cz));
byte extBelow = lvl.GetExtTile((ushort)(x + dx), (ushort)(y + dy - 1), (ushort)(z + dz));
isRails = lvl.CustomBlockProps[extBelow].IsRails;
}
if (isRails && (tile == Block.air || tile == Block.water)) {
lvl.AddUpdate(lvl.PosToInt((ushort)(x + cx),
(ushort)(y + cy), (ushort)(z + cz)), Block.train);
if (isRails && (tile == Block.air || tile == Block.water)
&& !lvl.listUpdateExists.Get(x + dx, y + dy, z + dz)) {
lvl.AddUpdate(lvl.PosToInt((ushort)(x + dx),
(ushort)(y + dy), (ushort)(z + dz)), Block.train);
lvl.AddUpdate(C.b, Block.air);
byte newBlock = tileBelow == Block.op_air ? Block.glass : Block.obsidian;

View File

@ -353,7 +353,7 @@ namespace MCGalaxy {
}
internal void CheckSurvival(ushort x, ushort y, ushort z) {
byte bFeet = GetSurvivalBlock(x, (ushort)(y - 2), z);
byte bFeet = GetSurvivalBlock(x, (ushort)(y - 1), z);
byte bHead = GetSurvivalBlock(x, y, z);
if (level.PosToInt(x, y, z) != oldIndex || y != oldFallY) {
byte conv = Block.Convert(bFeet);
@ -382,7 +382,9 @@ namespace MCGalaxy {
case Block.lavastill:
fallCount = 0;
drownCount++;
if (drownCount > level.drown * (100/3)) {
// level drown is in 10ths of a second, and there are 100 ticks/second
if (drownCount > level.drown * 10) {
HandleDeath(Block.water, 0);
drownCount = 0;
}