mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Fix picking up 'walk through' speed modifiers from blocks below you, even though you should only pick up from those intersecting you.
This commit is contained in:
parent
dacd6e4f44
commit
cbe7b2c840
@ -406,24 +406,31 @@ namespace ClassicalSharp {
|
||||
|
||||
float LowestSpeedModifier() {
|
||||
BoundingBox bounds = CollisionBounds;
|
||||
bounds.Min.Y -= 0.1f; // block standing on
|
||||
useLiquidGravity = false;
|
||||
float baseModifier = HighestModifier( bounds, false );
|
||||
bounds.Min.Y -= 0.1f; // also check block standing on
|
||||
float solidModifier = HighestModifier( bounds, true );
|
||||
return Math.Max( baseModifier, solidModifier );
|
||||
}
|
||||
|
||||
float HighestModifier( BoundingBox bounds, bool checkSolid ) {
|
||||
Vector3I bbMin = Vector3I.Floor( bounds.Min );
|
||||
Vector3I bbMax = Vector3I.Floor( bounds.Max );
|
||||
float modifier = float.PositiveInfinity;
|
||||
useLiquidGravity = false;
|
||||
|
||||
for( int x = bbMin.X; x <= bbMax.X; x++ ) {
|
||||
for( int y = bbMin.Y; y <= bbMax.Y; y++ ) {
|
||||
for( int z = bbMin.Z; z <= bbMax.Z; z++ ) {
|
||||
byte block = game.Map.SafeGetBlock( x, y, z );
|
||||
if( block == 0 ) continue;
|
||||
for( int y = bbMin.Y; y <= bbMax.Y; y++ )
|
||||
for( int z = bbMin.Z; z <= bbMax.Z; z++ )
|
||||
for( int x = bbMin.X; x <= bbMax.X; x++ )
|
||||
{
|
||||
byte block = game.Map.SafeGetBlock( x, y, z );
|
||||
if( block == 0 ) continue;
|
||||
BlockCollideType type = info.CollideType[block];
|
||||
if( type == BlockCollideType.Solid && !checkSolid )
|
||||
continue;
|
||||
|
||||
modifier = Math.Min( modifier, info.SpeedMultiplier[block] );
|
||||
if( block >= BlockInfo.CpeBlocksCount &&
|
||||
info.CollideType[block] == BlockCollideType.SwimThrough )
|
||||
useLiquidGravity = true;
|
||||
}
|
||||
}
|
||||
modifier = Math.Min( modifier, info.SpeedMultiplier[block] );
|
||||
if( block >= BlockInfo.CpeBlocksCount && type == BlockCollideType.SwimThrough )
|
||||
useLiquidGravity = true;
|
||||
}
|
||||
return modifier == float.PositiveInfinity ? 1 : modifier;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user