mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Fix Y offseting being incorrect for self teleportation packets, remove ugly hack in Entity.Physics and fixes #78.
This commit is contained in:
parent
60b87b7a6f
commit
12da9e5d7a
@ -742,6 +742,7 @@ namespace ClassicalSharp {
|
|||||||
void ReadAbsoluteLocation( byte playerId, bool interpolate ) {
|
void ReadAbsoluteLocation( byte playerId, bool interpolate ) {
|
||||||
float x = reader.ReadInt16() / 32f;
|
float x = reader.ReadInt16() / 32f;
|
||||||
float y = ( reader.ReadInt16() - 51 ) / 32f; // We have to do this.
|
float y = ( reader.ReadInt16() - 51 ) / 32f; // We have to do this.
|
||||||
|
if( playerId == 255 ) y += 22/32f;
|
||||||
float z = reader.ReadInt16() / 32f;
|
float z = reader.ReadInt16() / 32f;
|
||||||
float yaw = (float)Utils.PackedToDegrees( reader.ReadUInt8() );
|
float yaw = (float)Utils.PackedToDegrees( reader.ReadUInt8() );
|
||||||
float pitch = (float)Utils.PackedToDegrees( reader.ReadUInt8() );
|
float pitch = (float)Utils.PackedToDegrees( reader.ReadUInt8() );
|
||||||
|
@ -120,18 +120,15 @@ namespace ClassicalSharp {
|
|||||||
if( tx > 1 || ty > 1 || tz > 1 )
|
if( tx > 1 || ty > 1 || tz > 1 )
|
||||||
Utils.LogWarning( "t > 1 in physics calculation.. this shouldn't have happened." );
|
Utils.LogWarning( "t > 1 in physics calculation.. this shouldn't have happened." );
|
||||||
BoundingBox finalBB = entityBB.Offset( Velocity * new Vector3( tx, ty, tz ) );
|
BoundingBox finalBB = entityBB.Offset( Velocity * new Vector3( tx, ty, tz ) );
|
||||||
float pushUpOffset = (blockBB.Max.Y - blockBB.Min.Y) * 0.25f;
|
|
||||||
|
|
||||||
// Find which axis we collide with.
|
if( finalBB.Min.Y >= blockBB.Max.Y ) {
|
||||||
if( finalBB.Min.Y >= blockBB.Min.Y + pushUpOffset ) {
|
|
||||||
Position.Y = blockBB.Max.Y + Adjustment;
|
Position.Y = blockBB.Max.Y + Adjustment;
|
||||||
onGround = true;
|
onGround = true;
|
||||||
ClipY( ref size, ref entityBB, ref entityExtentBB );
|
ClipY( ref size, ref entityBB, ref entityExtentBB );
|
||||||
} else if( finalBB.Max.Y <= blockBB.Min.Y ) {
|
} else if( finalBB.Max.Y <= blockBB.Min.Y ) {
|
||||||
Position.Y = blockBB.Min.Y - size.Y - Adjustment;
|
Position.Y = blockBB.Min.Y - size.Y - Adjustment;
|
||||||
ClipY( ref size, ref entityBB, ref entityExtentBB );
|
ClipY( ref size, ref entityBB, ref entityExtentBB );
|
||||||
} else {
|
} else if( finalBB.Min.X >= blockBB.Max.X ) {
|
||||||
if( finalBB.Min.X >= blockBB.Max.X ) {
|
|
||||||
if( !wasOn || !DidSlide( ref blockBB, ref size, ref finalBB, ref entityBB, ref entityExtentBB ) ) {
|
if( !wasOn || !DidSlide( ref blockBB, ref size, ref finalBB, ref entityBB, ref entityExtentBB ) ) {
|
||||||
Position.X = blockBB.Max.X + size.X / 2 + Adjustment;
|
Position.X = blockBB.Max.X + size.X / 2 + Adjustment;
|
||||||
ClipX( ref size, ref entityBB, ref entityExtentBB );
|
ClipX( ref size, ref entityBB, ref entityExtentBB );
|
||||||
@ -154,7 +151,6 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool DidSlide( ref BoundingBox blockBB, ref Vector3 size, ref BoundingBox finalBB,
|
bool DidSlide( ref BoundingBox blockBB, ref Vector3 size, ref BoundingBox finalBB,
|
||||||
ref BoundingBox entityBB, ref BoundingBox entityExtentBB ) {
|
ref BoundingBox entityBB, ref BoundingBox entityExtentBB ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user