mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Try to find cause of crash found in comments in #61.
This commit is contained in:
parent
2e502ee8bb
commit
46a09255cc
@ -42,7 +42,7 @@ namespace ClassicalSharp {
|
||||
Height = blockSize;
|
||||
|
||||
for( int i = 0; i < barTextures.Length; i++ ) {
|
||||
barTextures[i] = MakeTexture( x, y, game.BlocksHotbar[i] );
|
||||
barTextures[i] = MakeTexture( x, y, game.Hotbar[i] );
|
||||
x += blockSize;
|
||||
}
|
||||
}
|
||||
|
@ -64,10 +64,10 @@ namespace ClassicalSharp {
|
||||
if( activeScreen == null || !activeScreen.HandlesMouseScroll( e.Delta ) ) {
|
||||
if( Camera.MouseZoom( e ) || !CanChangeHeldBlock ) return;
|
||||
|
||||
int diff = -e.Delta % BlocksHotbar.Length;
|
||||
int diff = -e.Delta % Hotbar.Length;
|
||||
int newIndex = HeldBlockIndex + diff;
|
||||
if( newIndex < 0 ) newIndex += BlocksHotbar.Length;
|
||||
if( newIndex >= BlocksHotbar.Length ) newIndex -= BlocksHotbar.Length;
|
||||
if( newIndex < 0 ) newIndex += Hotbar.Length;
|
||||
if( newIndex >= Hotbar.Length ) newIndex -= Hotbar.Length;
|
||||
HeldBlockIndex = newIndex;
|
||||
}
|
||||
}
|
||||
|
@ -51,8 +51,7 @@ namespace ClassicalSharp {
|
||||
|
||||
int hotbarIndex = 0;
|
||||
public bool CanChangeHeldBlock = true;
|
||||
public Block[] BlocksHotbar = new Block[] { Block.Stone, Block.Cobblestone,
|
||||
Block.Brick, Block.Dirt, Block.WoodenPlanks, Block.Wood, Block.Leaves, Block.Glass, Block.Slab };
|
||||
public Block[] Hotbar = new Block[9];
|
||||
|
||||
public int HeldBlockIndex {
|
||||
get { return hotbarIndex; }
|
||||
@ -67,20 +66,20 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public Block HeldBlock {
|
||||
get { return BlocksHotbar[hotbarIndex]; }
|
||||
get { return Hotbar[hotbarIndex]; }
|
||||
set {
|
||||
if( !CanChangeHeldBlock ) {
|
||||
AddChat( "&e/client: &cThe server has forbidden you from changing your held block." );
|
||||
return;
|
||||
}
|
||||
for( int i = 0; i < BlocksHotbar.Length; i++ ) {
|
||||
if( BlocksHotbar[i] == value ) {
|
||||
for( int i = 0; i < Hotbar.Length; i++ ) {
|
||||
if( Hotbar[i] == value ) {
|
||||
hotbarIndex = i;
|
||||
RaiseHeldBlockChanged();
|
||||
return;
|
||||
}
|
||||
}
|
||||
BlocksHotbar[hotbarIndex] = value;
|
||||
Hotbar[hotbarIndex] = value;
|
||||
RaiseHeldBlockChanged();
|
||||
}
|
||||
}
|
||||
@ -113,12 +112,14 @@ namespace ClassicalSharp {
|
||||
Raise( TerrainAtlasChanged );
|
||||
}
|
||||
|
||||
void PrintGraphicsInfo() {
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Graphics.PrintApiSpecificInfo();
|
||||
Utils.Log( "Max 2D texture dimensions: " + Graphics.MaxTextureDimensions );
|
||||
Utils.Log( "== End of graphics info ==" );
|
||||
Console.ResetColor();
|
||||
public Game() : base() {
|
||||
// We can't use enum array initaliser because this causes problems when building with mono
|
||||
// and running on default .NET (https://bugzilla.xamarin.com/show_bug.cgi?id=572)
|
||||
Hotbar[0] = Block.Stone; Hotbar[1] = Block.Cobblestone;
|
||||
Hotbar[2] = Block.Brick; Hotbar[3] = Block.Dirt;
|
||||
Hotbar[4] = Block.WoodenPlanks; Hotbar[5] = Block.Wood;
|
||||
Hotbar[6] = Block.Leaves; Hotbar[7] = Block.Glass;
|
||||
Hotbar[8] = Block.Slab;
|
||||
}
|
||||
|
||||
protected override void OnLoad( EventArgs e ) {
|
||||
@ -131,7 +132,7 @@ namespace ClassicalSharp {
|
||||
ModelCache = new ModelCache( this );
|
||||
ModelCache.InitCache();
|
||||
AsyncDownloader = new AsyncDownloader( skinServer );
|
||||
PrintGraphicsInfo();
|
||||
Graphics.PrintGraphicsInfo();
|
||||
Bitmap terrainBmp = new Bitmap( "terrain.png" );
|
||||
TerrainAtlas1D = new TerrainAtlas1D( Graphics );
|
||||
TerrainAtlas = new TerrainAtlas2D( Graphics );
|
||||
|
@ -157,6 +157,14 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
|
||||
public abstract void PrintApiSpecificInfo();
|
||||
|
||||
public void PrintGraphicsInfo() {
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
PrintApiSpecificInfo();
|
||||
Utils.Log( "Max 2D texture dimensions: " + MaxTextureDimensions );
|
||||
Utils.Log( "== End of graphics info ==" );
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
public abstract void BeginFrame( Game game );
|
||||
|
||||
public abstract void EndFrame( Game game );
|
||||
|
Loading…
x
Reference in New Issue
Block a user