Fix custom liquids for BlockDefinitions.

This commit is contained in:
UnknownShadow200 2015-09-23 13:18:13 +10:00
parent b195699620
commit 901f3e359f
2 changed files with 17 additions and 11 deletions

View File

@ -107,6 +107,7 @@ namespace ClassicalSharp {
} }
} }
bool useLiquidGravity = false; // used by BlockDefinitions.
void UpdateVelocityYState() { void UpdateVelocityYState() {
if( flying || noClip ) { if( flying || noClip ) {
Velocity.Y = 0; // eliminate the effect of gravity Velocity.Y = 0; // eliminate the effect of gravity
@ -124,6 +125,8 @@ namespace ClassicalSharp {
if( jumping ) { if( jumping ) {
if( TouchesAnyWater() || TouchesAnyLava() ) { if( TouchesAnyWater() || TouchesAnyLava() ) {
Velocity.Y += speeding ? 0.08f : 0.04f; Velocity.Y += speeding ? 0.08f : 0.04f;
} else if( useLiquidGravity ) {
Velocity.Y += speeding ? 0.08f : 0.04f;
} else if( TouchesAnyRope() ) { } else if( TouchesAnyRope() ) {
Velocity.Y += speeding ? 0.15f : 0.10f; Velocity.Y += speeding ? 0.15f : 0.10f;
} else if( onGround ) { } else if( onGround ) {
@ -141,7 +144,8 @@ namespace ClassicalSharp {
void PhysicsTick( float xMoving, float zMoving ) { void PhysicsTick( float xMoving, float zMoving ) {
float multiply = flying ? ( speeding ? 90 : 15 ) : ( speeding ? 10 : 1 ); float multiply = flying ? ( speeding ? 90 : 15 ) : ( speeding ? 10 : 1 );
multiply *= LowestSpeedModifier(); float modifier = LowestSpeedModifier();
multiply *= modifier;
if( TouchesAnyWater() && !flying && !noClip ) { if( TouchesAnyWater() && !flying && !noClip ) {
Move( xMoving, zMoving, 0.02f * multiply, waterDrag, liquidGrav, 1 ); Move( xMoving, zMoving, 0.02f * multiply, waterDrag, liquidGrav, 1 );
@ -151,8 +155,9 @@ namespace ClassicalSharp {
Move( xMoving, zMoving, 0.02f * 1.7f, ropeDrag, ropeGrav, 1 ); Move( xMoving, zMoving, 0.02f * 1.7f, ropeDrag, ropeGrav, 1 );
} else { } else {
float factor = !flying && onGround ? 0.1f : 0.02f; float factor = !flying && onGround ? 0.1f : 0.02f;
float yMul = Math.Max( 1, multiply / 5f ); float yMul = modifier * Math.Max( 1, multiply / 5f );
Move( xMoving, zMoving, factor * multiply, normalDrag, normalGrav, yMul ); float gravity = useLiquidGravity ? liquidGrav : normalGrav;
Move( xMoving, zMoving, factor * multiply, normalDrag, gravity, yMul );
if( BlockUnderFeet == Block.Ice ) { if( BlockUnderFeet == Block.Ice ) {
Utils.Clamp( ref Velocity.X, -0.25f, 0.25f ); Utils.Clamp( ref Velocity.X, -0.25f, 0.25f );
@ -282,6 +287,7 @@ namespace ClassicalSharp {
Vector3I bbMin = Vector3I.Floor( bounds.Min ); Vector3I bbMin = Vector3I.Floor( bounds.Min );
Vector3I bbMax = Vector3I.Floor( bounds.Max ); Vector3I bbMax = Vector3I.Floor( bounds.Max );
float modifier = float.PositiveInfinity; float modifier = float.PositiveInfinity;
useLiquidGravity = false;
for( int x = bbMin.X; x <= bbMax.X; x++ ) { for( int x = bbMin.X; x <= bbMax.X; x++ ) {
for( int y = bbMin.Y; y <= bbMax.Y; y++ ) { for( int y = bbMin.Y; y <= bbMax.Y; y++ ) {
@ -289,7 +295,10 @@ namespace ClassicalSharp {
if( !map.IsValidPos( x, y, z ) ) continue; if( !map.IsValidPos( x, y, z ) ) continue;
byte block = map.GetBlock( x, y, z ); byte block = map.GetBlock( x, y, z );
if( block == 0 ) continue; if( block == 0 ) continue;
modifier = Math.Min( modifier, info.SpeedMultiplier[block] ); modifier = Math.Min( modifier, info.SpeedMultiplier[block] );
if( info.CollideType[block] == BlockCollideType.SwimThrough )
useLiquidGravity = true;
} }
} }
} }

View File

@ -73,14 +73,11 @@ namespace Launcher {
var sw = System.Diagnostics.Stopwatch.StartNew(); var sw = System.Diagnostics.Stopwatch.StartNew();
var response = GetHtml( publicServersUri, minecraftNetUri ); var response = GetHtml( publicServersUri, minecraftNetUri );
List<ServerListEntry> servers = new List<ServerListEntry>(); List<ServerListEntry> servers = new List<ServerListEntry>();
int index = -1; bool foundStart = false;
int mode = 0; int mode = 0;
string hash = null; string hash = null, name = null, players = null;
string name = null; string maxPlayers = null, uptime = null;
string players = null;
string maxPlayers = null;
string uptime = null;
foreach( string line in response ) { foreach( string line in response ) {
if( line.StartsWith( " <a href", ordinal ) ) { if( line.StartsWith( " <a href", ordinal ) ) {
@ -92,10 +89,10 @@ namespace Launcher {
int nameEnd = line.IndexOf( '<', nameStart ); int nameEnd = line.IndexOf( '<', nameStart );
name = line.Substring( nameStart, nameEnd - nameStart ); name = line.Substring( nameStart, nameEnd - nameStart );
name = WebUtility.HtmlDecode( name ); name = WebUtility.HtmlDecode( name );
index++; foundStart = true;
mode = 0; mode = 0;
} }
if( index < 0 ) continue; if( !foundStart ) continue;
// NOTE: >16 checks that the line actually has a value. // NOTE: >16 checks that the line actually has a value.
// this check is necessary, as the page does have lines with just " <td>" // this check is necessary, as the page does have lines with just " <td>"