Make jump height calculation more precise and only show three significant figures (Thanks MrGoober), also always show generate/load options but disabled in multiplayer.

This commit is contained in:
UnknownShadow200 2016-02-27 08:54:37 +11:00
parent 998ffe5eb9
commit 3e05ba60de
9 changed files with 48 additions and 39 deletions

View File

@ -32,7 +32,7 @@ namespace ClassicalSharp {
Options.Set( OptionsKey.CameraClipping, v == "yes" ); } ), Options.Set( OptionsKey.CameraClipping, v == "yes" ); } ),
Make( -140, 0, "Jump height", OnWidgetClick, Make( -140, 0, "Jump height", OnWidgetClick,
g => g.LocalPlayer.JumpHeight.ToString(), g => g.LocalPlayer.JumpHeight.ToString( "F3" ),
(g, v) => g.LocalPlayer.CalculateJumpVelocity( Single.Parse( v ) ) ), (g, v) => g.LocalPlayer.CalculateJumpVelocity( Single.Parse( v ) ) ),
Make( -140, 50, "Double jump", OnWidgetClick, Make( -140, 50, "Double jump", OnWidgetClick,
@ -41,10 +41,10 @@ namespace ClassicalSharp {
Options.Set( OptionsKey.DoubleJump, v == "yes" ); } ), Options.Set( OptionsKey.DoubleJump, v == "yes" ); } ),
// Column 2 // Column 2
Make( 140, -150, "Liquids breakable", OnWidgetClick, Make( 140, -150, "Modifiable liquids", OnWidgetClick,
g => g.LiquidsBreakable ? "yes" : "no", g => g.ModifiableLiquids ? "yes" : "no",
(g, v) => { g.LiquidsBreakable = v == "yes"; (g, v) => { g.ModifiableLiquids = v == "yes";
Options.Set( OptionsKey.LiquidsBreakable, v == "yes" ); } ), Options.Set( OptionsKey.ModifiableLiquids, v == "yes" ); } ),
Make( 140, -100, "Pushback placing", OnWidgetClick, Make( 140, -100, "Pushback placing", OnWidgetClick,
g => g.LocalPlayer.Hacks.PushbackPlacing ? "yes" : "no", g => g.LocalPlayer.Hacks.PushbackPlacing ? "yes" : "no",
@ -109,9 +109,17 @@ namespace ClassicalSharp {
void MakeDescriptions() { void MakeDescriptions() {
descriptions = new string[widgets.Length][]; descriptions = new string[widgets.Length][];
descriptions[2] = new [] {
"&eIf camera clipping is set to true, then the third person",
"&ecameras will limit their zoom distance if they hit a solid block.",
};
descriptions[3] = new [] {
"&eSets how many blocks high you can jump up.",
"&eNote: You jump much higher when holding down the speed key binding.",
};
descriptions[5] = new [] { descriptions[5] = new [] {
"&eIf breaking liquids is set to true, then water/lava", "&eIf modifiable liquids is set to true, then water/lava can",
"&ecan be deleted the same way as any regular block.", "&ebe placed and deleted the same way as any other block.",
}; };
descriptions[6] = new [] { descriptions[6] = new [] {
"&eWhen this is active, placing blocks that intersect your own position", "&eWhen this is active, placing blocks that intersect your own position",

View File

@ -44,11 +44,9 @@ namespace ClassicalSharp {
// Column 2 // Column 2
Make( 140, -150, "Save level", Make( 140, -150, "Save level",
(g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
!game.Network.IsSinglePlayer ? null : Make( 140, -100, "Load level",
Make( 140, -100, "Load level",
(g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ), (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ),
!game.Network.IsSinglePlayer ? null : Make( 140, -50, "Generate level",
Make( 140, -50, "Generate level",
(g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ), (g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ),
Make( 140, 0, "Select texture pack", Make( 140, 0, "Select texture pack",
(g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ), (g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ),
@ -64,40 +62,44 @@ namespace ClassicalSharp {
MakeBack( true, titleFont, MakeBack( true, titleFont,
(g, w) => g.SetNewScreen( null ) ), (g, w) => g.SetNewScreen( null ) ),
}; };
if( !game.Network.IsSinglePlayer ) {
widgets[6].Disabled = true;
widgets[7].Disabled = true;
}
} }
void MakeClassic() { void MakeClassic() {
widgets = new Widget[] { widgets = new Widget[] {
MakeClassic( 0, -100, "Options", MakeClassic( 0, -100, "Options",
(g, w) => g.SetNewScreen( new ClassicOptionsScreen( g ) ) ), (g, w) => g.SetNewScreen( new ClassicOptionsScreen( g ) ) ),
!game.Network.IsSinglePlayer ? null :
MakeClassic( 0, -50, "Generate level", MakeClassic( 0, -50, "Generate level",
(g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ), (g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ),
!game.Network.IsSinglePlayer ? null :
MakeClassic( 0, 0, "Load level", MakeClassic( 0, 0, "Load level",
(g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ), (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ),
MakeClassic( 0, 50, "Save level", MakeClassic( 0, 50, "Save level",
(g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
MakeBack( true, titleFont, MakeBack( true, titleFont,
(g, w) => g.SetNewScreen( null ) ), (g, w) => g.SetNewScreen( null ) ),
game.PureClassicMode ? null : game.PureClassicMode ? null :
MakeClassic( 0, 150, "Nostalgia options", MakeClassic( 0, 150, "Nostalgia options",
(g, w) => g.SetNewScreen( new NostalgiaScreen( g ) ) ), (g, w) => g.SetNewScreen( new NostalgiaScreen( g ) ) ),
}; };
if( !game.Network.IsSinglePlayer ) {
widgets[1].Disabled = true;
widgets[2].Disabled = true;
}
} }
void CheckHacksAllowed( object sender, EventArgs e ) { void CheckHacksAllowed( object sender, EventArgs e ) {
for( int i = 0; i < widgets.Length; i++ ) { if( game.UseClassicOptions ) return;
if( widgets[i] == null ) continue;
widgets[i].Disabled = false; widgets[3].Disabled = !game.LocalPlayer.Hacks.CanAnyHacks; // env settings
} widgets[8].Disabled = !game.LocalPlayer.Hacks.CanAnyHacks; // select texture pack
if( !game.LocalPlayer.Hacks.CanAnyHacks && !game.UseClassicOptions ) {
widgets[3].Disabled = true; // env settings
widgets[8].Disabled = true; // select texture pack
}
} }
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick ) { ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick ) {

View File

@ -232,9 +232,8 @@ namespace ClassicalSharp {
if( jumpHeight >= 512 ) jumpVel = 16.5f; if( jumpHeight >= 512 ) jumpVel = 16.5f;
if( jumpHeight >= 768 ) jumpVel = 22.5f; if( jumpHeight >= 768 ) jumpVel = 22.5f;
while( GetMaxHeight( jumpVel ) <= jumpHeight ) { while( GetMaxHeight( jumpVel ) <= jumpHeight )
jumpVel += 0.01f; jumpVel += 0.001f;
}
} }
static double GetMaxHeight( float u ) { static double GetMaxHeight( float u ) {

View File

@ -19,7 +19,7 @@ namespace ClassicalSharp {
int coordsCount = 0; int coordsCount = 0;
Vector3I* coords = stackalloc Vector3I[4]; Vector3I* coords = stackalloc Vector3I[4];
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
coords[i] = Vector3I.Zero; coords[i] = new Vector3I( int.MinValue );
if( mode == EntityShadow.SnapToBlock ) { if( mode == EntityShadow.SnapToBlock ) {
vb = game.Graphics.texVb; verts = game.Graphics.texVerts; vb = game.Graphics.texVb; verts = game.Graphics.texVerts;

View File

@ -140,7 +140,7 @@ namespace ClassicalSharp {
public bool ClickableChat = false, HideGui = false, ShowFPS = true; public bool ClickableChat = false, HideGui = false, ShowFPS = true;
internal float HotbarScale = 1, ChatScale = 1, InventoryScale = 1; internal float HotbarScale = 1, ChatScale = 1, InventoryScale = 1;
public bool ViewBobbing, ShowBlockInHand; public bool ViewBobbing, ShowBlockInHand;
public bool UseSound, UseMusic, LiquidsBreakable; public bool UseSound, UseMusic, ModifiableLiquids;
public Vector3 CurrentCameraPos; public Vector3 CurrentCameraPos;

View File

@ -142,7 +142,7 @@ namespace ClassicalSharp {
MapBordersRenderer.Init(); MapBordersRenderer.Init();
Picking = new PickedPosRenderer( this ); Picking = new PickedPosRenderer( this );
AudioPlayer = new AudioPlayer( this ); AudioPlayer = new AudioPlayer( this );
LiquidsBreakable = Options.GetBool( OptionsKey.LiquidsBreakable, false ); ModifiableLiquids = Options.GetBool( OptionsKey.ModifiableLiquids, false );
AxisLinesRenderer = new AxisLinesRenderer( this ); AxisLinesRenderer = new AxisLinesRenderer( this );
LoadIcon(); LoadIcon();
@ -494,7 +494,7 @@ namespace ClassicalSharp {
return false; return false;
if( !BlockInfo.IsLiquid[block] ) return true; if( !BlockInfo.IsLiquid[block] ) return true;
return !LiquidsBreakable ? false : return !ModifiableLiquids ? false :
Inventory.CanPlace[block] && Inventory.CanDelete[block]; Inventory.CanPlace[block] && Inventory.CanDelete[block];
} }

View File

@ -349,8 +349,8 @@ namespace ClassicalSharp {
p.CheckHacksConsistency(); p.CheckHacksConsistency();
float jumpHeight = reader.ReadInt16() / 32f; float jumpHeight = reader.ReadInt16() / 32f;
if( jumpHeight < 0 ) jumpHeight = 39/32f; if( jumpHeight < 0 ) p.jumpVel = 0.42f;
p.CalculateJumpVelocity( jumpHeight ); else p.CalculateJumpVelocity( jumpHeight );
p.serverJumpVel = p.jumpVel; p.serverJumpVel = p.jumpVel;
game.Events.RaiseHackPermissionsChanged(); game.Events.RaiseHackPermissionsChanged();
} }

View File

@ -82,7 +82,7 @@ namespace ClassicalSharp {
// Workaround for older D3 servers which wrote one byte too many for HackControl packets. // Workaround for older D3 servers which wrote one byte too many for HackControl packets.
if( opcode == 0xFF && lastOpcode == PacketId.CpeHackControl ) { if( opcode == 0xFF && lastOpcode == PacketId.CpeHackControl ) {
reader.Remove( 1 ); reader.Remove( 1 );
game.LocalPlayer.CalculateJumpVelocity( 39/32f ); // assume default jump height game.LocalPlayer.jumpVel = 0.42f; // assume default jump height
game.LocalPlayer.serverJumpVel = game.LocalPlayer.jumpVel; game.LocalPlayer.serverJumpVel = game.LocalPlayer.jumpVel;
continue; continue;
} }

View File

@ -25,7 +25,7 @@ namespace ClassicalSharp {
public const string HacksEnabled = "hacks-hacksenabled"; public const string HacksEnabled = "hacks-hacksenabled";
public const string FieldOfView = "hacks-fov"; public const string FieldOfView = "hacks-fov";
public const string Speed = "hacks-speedmultiplier"; public const string Speed = "hacks-speedmultiplier";
public const string LiquidsBreakable = "hacks-liquidsbreakable"; public const string ModifiableLiquids = "hacks-liquidsbreakable";
public const string PushbackPlacing = "hacks-pushbackplacing"; public const string PushbackPlacing = "hacks-pushbackplacing";
public const string NoclipSlide = "hacks-noclipslide"; public const string NoclipSlide = "hacks-noclipslide";
public const string CameraClipping = "hacks-cameraclipping"; public const string CameraClipping = "hacks-cameraclipping";