Fix client playing sounds from custom blocks that are liquid or walkthrough collision type, but do not intersect the player's collision box.

This commit is contained in:
UnknownShadow200 2016-04-24 18:16:52 +10:00
parent 94171a52e7
commit 998480f940
2 changed files with 8 additions and 6 deletions

View File

@ -52,7 +52,6 @@ namespace ClassicalSharp {
bool underline = args.Font.Style == FontStyle.Underline;
if( args.UseShadow ) {
int offset = ShadowOffset( args.Font.Size );
Console.WriteLine( "OFFSET:" + offset + "," + args.Font.Size );
DrawPart( dst, ref args, x + offset, y + offset, true );
if( underline ) DrawUnderline( dst, x + offset, 0, ref args, true );
}

View File

@ -45,8 +45,8 @@ namespace ClassicalSharp.Entities {
bool anyNonAir = false;
SoundType sndType = SoundType.None;
void GetSound() {
Vector3 pos = p.nextPos, size = p.CollisionSize;
BoundingBox bounds = new BoundingBox( pos - size / 2, pos + size / 2 );
Vector3 pos = p.nextPos;
BoundingBox bounds = p.CollisionBounds;
sndType = SoundType.None;
anyNonAir = false;
@ -55,15 +55,18 @@ namespace ClassicalSharp.Entities {
if( sndType != SoundType.None ) return;
// then check block standing on
byte blockUnder = (byte)p.BlockUnderFeet;
pos.Y -= 0.01f;
Vector3I feetPos = Vector3I.Floor( pos );
byte blockUnder = game.World.SafeGetBlock( feetPos );
float maxY = feetPos.Y + game.BlockInfo.MaxBB[blockUnder].Y;
SoundType typeUnder = game.BlockInfo.StepSounds[blockUnder];
CollideType collideType = game.BlockInfo.Collide[blockUnder];
if( collideType == CollideType.Solid && typeUnder != SoundType.None ) {
if( maxY >= pos.Y && collideType == CollideType.Solid && typeUnder != SoundType.None ) {
anyNonAir = true; sndType = typeUnder; return;
}
// then check all solid blocks at feet
pos.Y -= 0.01f;
bounds.Max.Y = bounds.Min.Y = pos.Y;
p.TouchesAny( bounds, checkSoundSolid );
}