mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Fix fall death and drowing (again)
This commit is contained in:
parent
472f4b5359
commit
bdec66cabe
@ -191,8 +191,7 @@ namespace MCGalaxy {
|
||||
internal bool showedWelcome;
|
||||
|
||||
//Movement
|
||||
public int oldIndex = -1, lastWalkthrough = -1, oldFallY = 10000;
|
||||
public int fallCount = 0;
|
||||
internal int oldIndex = -1, lastWalkthrough = -1, startFallY = -1, lastFallY = -1;
|
||||
public DateTime drownTime = DateTime.MaxValue;
|
||||
|
||||
//Games
|
||||
|
@ -343,6 +343,7 @@ namespace MCGalaxy {
|
||||
PlayerPhysics.Fall(this, bb);
|
||||
PlayerPhysics.Drown(this, bb);
|
||||
}
|
||||
lastFallY = bb.Min.Y;
|
||||
|
||||
PlayerPhysics.Walkthrough(this, bb);
|
||||
oldIndex = index;
|
||||
|
@ -66,22 +66,22 @@ namespace MCGalaxy.Blocks.Physics {
|
||||
{
|
||||
ExtBlock block = GetSurvivalBlock(p, x, min.Y, z);
|
||||
byte collide = p.level.CollideType(block);
|
||||
allGas = allGas && collide == CollideType.WalkThrough;
|
||||
|
||||
allGas = allGas && collide == CollideType.WalkThrough;
|
||||
if (!CollideType.IsSolid(collide)) continue;
|
||||
if (p.fallCount > p.level.Config.FallHeight)
|
||||
|
||||
int fallHeight = (p.startFallY - bb.Min.Y) / 32;
|
||||
if (fallHeight > p.level.Config.FallHeight)
|
||||
p.HandleDeath(ExtBlock.Air, null, false, true);
|
||||
|
||||
p.fallCount = 0;
|
||||
p.drownTime = DateTime.MaxValue;
|
||||
if (fallHeight > 0) p.drownTime = DateTime.MaxValue;
|
||||
p.startFallY = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!allGas) return;
|
||||
if (min.Y < p.oldFallY) p.fallCount++;
|
||||
else if (min.Y > p.oldFallY) p.fallCount = 0; // e.g. flying up
|
||||
if (bb.Min.Y > p.lastFallY) p.startFallY = -1; // flying up resets fall height
|
||||
|
||||
p.oldFallY = min.Y;
|
||||
p.startFallY = Math.Max(bb.Min.Y, p.startFallY);
|
||||
p.drownTime = DateTime.MaxValue;
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ namespace MCGalaxy.Blocks.Physics {
|
||||
case Block.StillWater:
|
||||
case Block.Lava:
|
||||
case Block.StillLava:
|
||||
p.fallCount = 0;
|
||||
p.startFallY = -1;
|
||||
DateTime now = DateTime.UtcNow;
|
||||
// level drown is in 10ths of a second
|
||||
if (p.drownTime == DateTime.MaxValue)
|
||||
@ -112,7 +112,7 @@ namespace MCGalaxy.Blocks.Physics {
|
||||
break;
|
||||
default:
|
||||
bool isGas = p.level.CollideType(bHead) == CollideType.WalkThrough;
|
||||
if (!isGas) p.fallCount = 0;
|
||||
if (!isGas) p.startFallY = -1;
|
||||
p.drownTime = DateTime.MaxValue;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user