mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-23 20:57:12 -04:00
Better indentation
This commit is contained in:
parent
fd879b0b00
commit
d837e52724
@ -147,13 +147,14 @@ namespace ClassicalSharp.Gui {
|
|||||||
void SetFetchStatus( int progress ) {
|
void SetFetchStatus( int progress ) {
|
||||||
lastDownload.Clear();
|
lastDownload.Clear();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if( progress == -2 )
|
if( progress == -2 ) {
|
||||||
lastDownload.Append( ref index, "&eRetrieving texture pack.." );
|
lastDownload.Append( ref index, "&eRetrieving texture pack.." );
|
||||||
else if( progress == -1 )
|
} else if( progress == -1 ) {
|
||||||
lastDownload.Append( ref index, "&eDownloading texture pack" );
|
lastDownload.Append( ref index, "&eDownloading texture pack" );
|
||||||
else if( progress >= 0 && progress <= 100 )
|
} else if( progress >= 0 && progress <= 100 ) {
|
||||||
lastDownload.Append( ref index, "&eDownloading texture pack (&7" )
|
lastDownload.Append( ref index, "&eDownloading texture pack (&7" )
|
||||||
.AppendNum( ref index, progress ).Append( ref index, "&e%)" );
|
.AppendNum( ref index, progress ).Append( ref index, "&e%)" );
|
||||||
|
}
|
||||||
status.SetText( 1, lastDownload.ToString() );
|
status.SetText( 1, lastDownload.ToString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,10 +41,11 @@ namespace ClassicalSharp.Gui {
|
|||||||
if( button == MouseButton.Left && mouseX >= TableX - scrollbarWidth && mouseX < TableX ) {
|
if( button == MouseButton.Left && mouseX >= TableX - scrollbarWidth && mouseX < TableX ) {
|
||||||
ScrollbarClick( mouseY );
|
ScrollbarClick( mouseY );
|
||||||
} else if( button == MouseButton.Left ) {
|
} else if( button == MouseButton.Left ) {
|
||||||
if( selIndex != -1 )
|
if( selIndex != -1 ) {
|
||||||
game.Inventory.HeldBlock = blocksTable[selIndex];
|
game.Inventory.HeldBlock = blocksTable[selIndex];
|
||||||
else if( Contains( TableX, TableY, TableWidth, TableHeight, mouseX, mouseY ) )
|
} else if( Contains( TableX, TableY, TableWidth, TableHeight, mouseX, mouseY ) ) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool hotbar = game.IsKeyDown( Key.AltLeft ) || game.IsKeyDown( Key.AltRight );
|
bool hotbar = game.IsKeyDown( Key.AltLeft ) || game.IsKeyDown( Key.AltRight );
|
||||||
if( !hotbar )
|
if( !hotbar )
|
||||||
|
@ -162,8 +162,7 @@ namespace ClassicalSharp.Gui {
|
|||||||
count += 2;
|
count += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( lastEnd < line.Length )
|
if( lastEnd < line.Length ) count++;
|
||||||
count++;
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +57,11 @@ namespace ClassicalSharp.Audio {
|
|||||||
chunk.BytesUsed = snd.Data.Length;
|
chunk.BytesUsed = snd.Data.Length;
|
||||||
chunk.Data = snd.Data;
|
chunk.Data = snd.Data;
|
||||||
|
|
||||||
if( snd.Channels == 1 )
|
if( snd.Channels == 1 ) {
|
||||||
PlayCurrentSound( monoOutputs );
|
PlayCurrentSound( monoOutputs );
|
||||||
else if( snd.Channels == 2 )
|
} else if( snd.Channels == 2 ) {
|
||||||
PlayCurrentSound( stereoOutputs );
|
PlayCurrentSound( stereoOutputs );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IAudioOutput firstSoundOut;
|
IAudioOutput firstSoundOut;
|
||||||
|
@ -76,7 +76,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public const string Names = "Air Stone Grass Dirt Cobblestone Wood Sapling Bedrock Water StillWater Lava" +
|
public const string Names = "Air Stone Grass Dirt Cobblestone Wood Sapling Bedrock Water StillWater Lava" +
|
||||||
" StillLava Sand Gravel GoldOre IronOre CoalOre Log Leaves Sponge Glass Red Orange Yellow Lime Green" +
|
" StillLava Sand Gravel GoldOre IronOre CoalOre Log Leaves Sponge Glass Red Orange Yellow Lime Green" +
|
||||||
" Teal Aqua Cyan Blue Indigo Violet Magenta Pink Black Gray White Dandelion Rose BrownMushroom RedMushroom" +
|
" Teal Aqua Cyan Blue Indigo Violet Magenta Pink Black Gray White Dandelion Rose BrownMushroom RedMushroom" +
|
||||||
" Gold Iron DoubleSlab Slab Brick TNT Bookshelf MossyRocks Obsidian CobblestoneSlab Rope Sandstone" +
|
" Gold Iron DoubleSlab Slab Brick TNT Bookshelf MossyRocks Obsidian CobblestoneSlab Rope Sandstone" +
|
||||||
" Snow Fire LightPink ForestGreen Brown DeepBlue Turquoise Ice CeramicTile Magma Pillar Crate StoneBrick";
|
" Snow Fire LightPink ForestGreen Brown DeepBlue Turquoise Ice CeramicTile Magma Pillar Crate StoneBrick";
|
||||||
}
|
}
|
||||||
|
@ -118,34 +118,36 @@ namespace ClassicalSharp.Entities {
|
|||||||
|
|
||||||
// if we have hit the bottom of a block, we need to change the axis we test first.
|
// if we have hit the bottom of a block, we need to change the axis we test first.
|
||||||
if( !hitYMin ) {
|
if( !hitYMin ) {
|
||||||
if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y )
|
if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y ) {
|
||||||
ClipYMax( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
|
ClipYMax( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
|
||||||
else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y )
|
} else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y ) {
|
||||||
ClipYMin( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
|
ClipYMin( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
|
||||||
else if( finalBB.Min.X + Adjustment >= blockBB.Max.X )
|
} else if( finalBB.Min.X + Adjustment >= blockBB.Max.X ) {
|
||||||
ClipXMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
ClipXMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
||||||
else if( finalBB.Max.X - Adjustment <= blockBB.Min.X )
|
} else if( finalBB.Max.X - Adjustment <= blockBB.Min.X ) {
|
||||||
ClipXMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
ClipXMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
||||||
else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z )
|
} else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z ) {
|
||||||
ClipZMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
ClipZMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
||||||
else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z )
|
} else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z ) {
|
||||||
ClipZMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
ClipZMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if flying or falling, test the horizontal axes first.
|
// if flying or falling, test the horizontal axes first.
|
||||||
if( finalBB.Min.X + Adjustment >= blockBB.Max.X )
|
if( finalBB.Min.X + Adjustment >= blockBB.Max.X ) {
|
||||||
ClipXMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
ClipXMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
||||||
else if( finalBB.Max.X - Adjustment <= blockBB.Min.X )
|
} else if( finalBB.Max.X - Adjustment <= blockBB.Min.X ) {
|
||||||
ClipXMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
ClipXMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
||||||
else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z )
|
} else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z ) {
|
||||||
ClipZMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
ClipZMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
||||||
else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z )
|
} else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z ) {
|
||||||
ClipZMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
ClipZMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
|
||||||
else if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y )
|
} else if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y ) {
|
||||||
ClipYMax( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
|
ClipYMax( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
|
||||||
else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y )
|
} else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y ) {
|
||||||
ClipYMin( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
|
ClipYMin( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,10 +111,11 @@ namespace ClassicalSharp.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ParseFlag( Action<bool> action, string joined, string flag ) {
|
static void ParseFlag( Action<bool> action, string joined, string flag ) {
|
||||||
if( joined.Contains( "+" + flag ) )
|
if( joined.Contains( "+" + flag ) ) {
|
||||||
action( true );
|
action( true );
|
||||||
else if( joined.Contains( "-" + flag ) )
|
} else if( joined.Contains( "-" + flag ) ) {
|
||||||
action( false );
|
action( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Sets the user type of this user. This is used to control permissions for grass,
|
/// <summary> Sets the user type of this user. This is used to control permissions for grass,
|
||||||
|
@ -106,8 +106,9 @@ namespace ClassicalSharp.Entities {
|
|||||||
/// <summary> Disables any hacks if their respective CanHackX value is set to false. </summary>
|
/// <summary> Disables any hacks if their respective CanHackX value is set to false. </summary>
|
||||||
public void CheckHacksConsistency() {
|
public void CheckHacksConsistency() {
|
||||||
Hacks.CheckHacksConsistency();
|
Hacks.CheckHacksConsistency();
|
||||||
if( !Hacks.CanJumpHigher )
|
if( !Hacks.CanJumpHigher ) {
|
||||||
physics.jumpVel = physics.serverJumpVel;
|
physics.jumpVel = physics.serverJumpVel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Vector3 lastPos, nextPos;
|
internal Vector3 lastPos, nextPos;
|
||||||
|
@ -5,7 +5,7 @@ namespace ClassicalSharp.Events {
|
|||||||
|
|
||||||
/// <summary> Contains events related to the spawning/despawning of entities,
|
/// <summary> Contains events related to the spawning/despawning of entities,
|
||||||
/// and the creation/removal of tab list entries. </summary>
|
/// and the creation/removal of tab list entries. </summary>
|
||||||
public sealed class EntityEvents : OtherEvents {
|
public sealed class EntityEvents : EventsBase {
|
||||||
|
|
||||||
IdEventArgs idArgs = new IdEventArgs();
|
IdEventArgs idArgs = new IdEventArgs();
|
||||||
|
|
||||||
|
@ -3,7 +3,20 @@ using System;
|
|||||||
|
|
||||||
namespace ClassicalSharp.Events {
|
namespace ClassicalSharp.Events {
|
||||||
|
|
||||||
public class OtherEvents {
|
public abstract class EventsBase {
|
||||||
|
|
||||||
|
protected void Raise( EventHandler handler ) {
|
||||||
|
if( handler == null ) return;
|
||||||
|
handler( this, EventArgs.Empty );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Raise<T>( EventHandler<T> handler, T args ) where T : EventArgs {
|
||||||
|
if( handler == null ) return;
|
||||||
|
handler( this, args );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OtherEvents : EventsBase {
|
||||||
|
|
||||||
/// <summary> Raised when the terrain atlas ("terrain.png") is changed. </summary>
|
/// <summary> Raised when the terrain atlas ("terrain.png") is changed. </summary>
|
||||||
public event EventHandler TerrainAtlasChanged;
|
public event EventHandler TerrainAtlasChanged;
|
||||||
@ -61,15 +74,6 @@ namespace ClassicalSharp.Events {
|
|||||||
ChatEventArgs chatArgs = new ChatEventArgs();
|
ChatEventArgs chatArgs = new ChatEventArgs();
|
||||||
TextureEventArgs texArgs = new TextureEventArgs();
|
TextureEventArgs texArgs = new TextureEventArgs();
|
||||||
ColourCodeEventArgs colArgs = new ColourCodeEventArgs();
|
ColourCodeEventArgs colArgs = new ColourCodeEventArgs();
|
||||||
protected void Raise( EventHandler handler ) {
|
|
||||||
if( handler != null )
|
|
||||||
handler( this, EventArgs.Empty );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void Raise<T>( EventHandler<T> handler, T args ) where T : EventArgs {
|
|
||||||
if( handler != null )
|
|
||||||
handler( this, args );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ChatEventArgs : EventArgs {
|
public sealed class ChatEventArgs : EventArgs {
|
||||||
|
@ -3,7 +3,7 @@ using System;
|
|||||||
|
|
||||||
namespace ClassicalSharp.Events {
|
namespace ClassicalSharp.Events {
|
||||||
|
|
||||||
public class UserEvents {
|
public class UserEvents : EventsBase {
|
||||||
|
|
||||||
/// <summary> Raised when the user changes a block in the world. </summary>
|
/// <summary> Raised when the user changes a block in the world. </summary>
|
||||||
public event EventHandler<BlockChangedEventArgs> BlockChanged;
|
public event EventHandler<BlockChangedEventArgs> BlockChanged;
|
||||||
@ -13,15 +13,6 @@ namespace ClassicalSharp.Events {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockChangedEventArgs blockArgs = new BlockChangedEventArgs();
|
BlockChangedEventArgs blockArgs = new BlockChangedEventArgs();
|
||||||
protected void Raise( EventHandler handler ) {
|
|
||||||
if( handler != null )
|
|
||||||
handler( this, EventArgs.Empty );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void Raise<T>( EventHandler<T> handler, T args ) where T : EventArgs {
|
|
||||||
if( handler != null )
|
|
||||||
handler( this, args );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class BlockChangedEventArgs : EventArgs {
|
public sealed class BlockChangedEventArgs : EventArgs {
|
||||||
|
@ -3,7 +3,7 @@ using System;
|
|||||||
|
|
||||||
namespace ClassicalSharp.Events {
|
namespace ClassicalSharp.Events {
|
||||||
|
|
||||||
public class WorldEvents : OtherEvents {
|
public class WorldEvents : EventsBase {
|
||||||
|
|
||||||
/// <summary> Raised when the player joins and begins loading a new world. </summary>
|
/// <summary> Raised when the player joins and begins loading a new world. </summary>
|
||||||
public event EventHandler OnNewMap;
|
public event EventHandler OnNewMap;
|
||||||
|
@ -61,12 +61,13 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextureChanged( object sender, TextureEventArgs e ) {
|
void TextureChanged( object sender, TextureEventArgs e ) {
|
||||||
if( e.Name == "gui.png" )
|
if( e.Name == "gui.png" ) {
|
||||||
game.UpdateTexture( ref GuiTex, e.Name, e.Data, false );
|
game.UpdateTexture( ref GuiTex, e.Name, e.Data, false );
|
||||||
else if( e.Name == "gui_classic.png" )
|
} else if( e.Name == "gui_classic.png" ) {
|
||||||
game.UpdateTexture( ref GuiClassicTex, e.Name, e.Data, false );
|
game.UpdateTexture( ref GuiClassicTex, e.Name, e.Data, false );
|
||||||
else if( e.Name == "icons.png" )
|
} else if( e.Name == "icons.png" ) {
|
||||||
game.UpdateTexture( ref IconsTex, e.Name, e.Data, false );
|
game.UpdateTexture( ref IconsTex, e.Name, e.Data, false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,10 +183,11 @@ namespace ClassicalSharp {
|
|||||||
bool more;
|
bool more;
|
||||||
if( !Hotkeys.IsHotkey( key, game.Keyboard, out text, out more ) ) return;
|
if( !Hotkeys.IsHotkey( key, game.Keyboard, out text, out more ) ) return;
|
||||||
|
|
||||||
if( !more )
|
if( !more ) {
|
||||||
game.Network.SendChat( text, false );
|
game.Network.SendChat( text, false );
|
||||||
else if( game.Gui.activeScreen == null )
|
} else if( game.Gui.activeScreen == null ) {
|
||||||
game.Gui.hudScreen.OpenTextInputBar( text );
|
game.Gui.hudScreen.OpenTextInputBar( text );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseButtonEventArgs simArgs = new MouseButtonEventArgs();
|
MouseButtonEventArgs simArgs = new MouseButtonEventArgs();
|
||||||
|
@ -109,18 +109,19 @@ namespace ClassicalSharp {
|
|||||||
Vector3 oldP = game.LocalPlayer.Position;
|
Vector3 oldP = game.LocalPlayer.Position;
|
||||||
|
|
||||||
// Offset position by the closest face
|
// Offset position by the closest face
|
||||||
if( selected.BlockFace == CpeBlockFace.XMax )
|
if( selected.BlockFace == CpeBlockFace.XMax ) {
|
||||||
newP.X = blockBB.Max.X + 0.5f;
|
newP.X = blockBB.Max.X + 0.5f;
|
||||||
else if( selected.BlockFace == CpeBlockFace.ZMax )
|
} else if( selected.BlockFace == CpeBlockFace.ZMax ) {
|
||||||
newP.Z = blockBB.Max.Z + 0.5f;
|
newP.Z = blockBB.Max.Z + 0.5f;
|
||||||
else if( selected.BlockFace == CpeBlockFace.XMin )
|
} else if( selected.BlockFace == CpeBlockFace.XMin ) {
|
||||||
newP.X = blockBB.Min.X - 0.5f;
|
newP.X = blockBB.Min.X - 0.5f;
|
||||||
else if( selected.BlockFace == CpeBlockFace.ZMin )
|
} else if( selected.BlockFace == CpeBlockFace.ZMin ) {
|
||||||
newP.Z = blockBB.Min.Z - 0.5f;
|
newP.Z = blockBB.Min.Z - 0.5f;
|
||||||
else if( selected.BlockFace == CpeBlockFace.YMax )
|
} else if( selected.BlockFace == CpeBlockFace.YMax ) {
|
||||||
newP.Y = blockBB.Min.Y + 1 + Entity.Adjustment;
|
newP.Y = blockBB.Min.Y + 1 + Entity.Adjustment;
|
||||||
else if( selected.BlockFace == CpeBlockFace.YMin )
|
} else if( selected.BlockFace == CpeBlockFace.YMin ) {
|
||||||
newP.Y = blockBB.Min.Y - game.LocalPlayer.Size.Y - Entity.Adjustment;
|
newP.Y = blockBB.Min.Y - game.LocalPlayer.Size.Y - Entity.Adjustment;
|
||||||
|
}
|
||||||
|
|
||||||
Vector3I newLoc = Vector3I.Floor( newP );
|
Vector3I newLoc = Vector3I.Floor( newP );
|
||||||
bool validPos = newLoc.X >= 0 && newLoc.Y >= 0 && newLoc.Z >= 0 &&
|
bool validPos = newLoc.X >= 0 && newLoc.Y >= 0 && newLoc.Z >= 0 &&
|
||||||
|
@ -37,18 +37,17 @@ namespace ClassicalSharp.Generator {
|
|||||||
stack.Push( startIndex );
|
stack.Push( startIndex );
|
||||||
while( stack.Size > 0 ) {
|
while( stack.Size > 0 ) {
|
||||||
int index = stack.Pop();
|
int index = stack.Pop();
|
||||||
if( blocks[index] == 0 ) {
|
if( blocks[index] != 0 ) continue;
|
||||||
blocks[index] = block;
|
blocks[index] = block;
|
||||||
|
|
||||||
int x = index % width;
|
int x = index % width;
|
||||||
int y = index / oneY;
|
int y = index / oneY;
|
||||||
int z = (index / width) % length;
|
int z = (index / width) % length;
|
||||||
if( x > 0 ) stack.Push( index - 1 );
|
if( x > 0 ) stack.Push( index - 1 );
|
||||||
if( x < width - 1 ) stack.Push( index + 1 );
|
if( x < width - 1 ) stack.Push( index + 1 );
|
||||||
if( z > 0 ) stack.Push( index - width );
|
if( z > 0 ) stack.Push( index - width );
|
||||||
if( z < length - 1 ) stack.Push( index + width );
|
if( z < length - 1 ) stack.Push( index + width );
|
||||||
if( y > 0 ) stack.Push( index - oneY );
|
if( y > 0 ) stack.Push( index - oneY );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +61,8 @@ namespace ClassicalSharp.Map {
|
|||||||
int bx = i & 0xF, by = (i >> 8) & 0xF, bz = (i >> 4) & 0xF;
|
int bx = i & 0xF, by = (i >> 8) & 0xF, bz = (i >> 4) & 0xF;
|
||||||
int index = baseIndex + (by * length + bz) * width + bx;
|
int index = baseIndex + (by * length + bz) * width + bx;
|
||||||
|
|
||||||
if( blocks[index] == customTile )
|
if( blocks[index] != customTile ) continue;
|
||||||
blocks[index] = chunk[i];
|
blocks[index] = chunk[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,7 @@ namespace ClassicalSharp.Network {
|
|||||||
internal void HandleLevelDataChunk() {
|
internal void HandleLevelDataChunk() {
|
||||||
// Workaround for some servers that send LevelDataChunk before LevelInit
|
// Workaround for some servers that send LevelDataChunk before LevelInit
|
||||||
// due to their async packet sending behaviour.
|
// due to their async packet sending behaviour.
|
||||||
if( gzipStream == null )
|
if( gzipStream == null ) HandleLevelInit();
|
||||||
HandleLevelInit();
|
|
||||||
int usedLength = reader.ReadInt16();
|
int usedLength = reader.ReadInt16();
|
||||||
gzippedMap.Position = 0;
|
gzippedMap.Position = 0;
|
||||||
gzippedMap.Offset = reader.index;
|
gzippedMap.Offset = reader.index;
|
||||||
@ -152,8 +151,9 @@ namespace ClassicalSharp.Network {
|
|||||||
task.Interval = 1.0 / 20;
|
task.Interval = 1.0 / 20;
|
||||||
game.Gui.SetNewScreen( null );
|
game.Gui.SetNewScreen( null );
|
||||||
game.Gui.activeScreen = prevScreen;
|
game.Gui.activeScreen = prevScreen;
|
||||||
if( prevScreen != null && prevCursorVisible != game.CursorVisible )
|
if( prevScreen != null && prevCursorVisible != game.CursorVisible ) {
|
||||||
game.CursorVisible = prevCursorVisible;
|
game.CursorVisible = prevCursorVisible;
|
||||||
|
}
|
||||||
prevScreen = null;
|
prevScreen = null;
|
||||||
|
|
||||||
int mapWidth = reader.ReadInt16();
|
int mapWidth = reader.ReadInt16();
|
||||||
|
@ -67,8 +67,9 @@ namespace ClassicalSharp.Network {
|
|||||||
|
|
||||||
public override void Tick( ScheduledTask task ) {
|
public override void Tick( ScheduledTask task ) {
|
||||||
if( Disconnected ) return;
|
if( Disconnected ) return;
|
||||||
if( (DateTime.UtcNow - lastPacket).TotalSeconds >= 30 )
|
if( (DateTime.UtcNow - lastPacket).TotalSeconds >= 30 ) {
|
||||||
CheckDisconnection( task.Interval );
|
CheckDisconnection( task.Interval );
|
||||||
|
}
|
||||||
if( Disconnected ) return;
|
if( Disconnected ) return;
|
||||||
|
|
||||||
LocalPlayer player = game.LocalPlayer;
|
LocalPlayer player = game.LocalPlayer;
|
||||||
@ -209,10 +210,12 @@ namespace ClassicalSharp.Network {
|
|||||||
void BlockChanged( object sender, BlockChangedEventArgs e ) {
|
void BlockChanged( object sender, BlockChangedEventArgs e ) {
|
||||||
Vector3I p = e.Coords;
|
Vector3I p = e.Coords;
|
||||||
byte block = game.Inventory.HeldBlock;
|
byte block = game.Inventory.HeldBlock;
|
||||||
if( e.Block == 0 )
|
|
||||||
|
if( e.Block == 0 ) {
|
||||||
SendSetBlock( p.X, p.Y, p.Z, false, block );
|
SendSetBlock( p.X, p.Y, p.Z, false, block );
|
||||||
else
|
} else {
|
||||||
SendSetBlock( p.X, p.Y, p.Z, true, e.Block );
|
SendSetBlock( p.X, p.Y, p.Z, true, e.Block );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnNewMap( object sender, EventArgs e ) {
|
void OnNewMap( object sender, EventArgs e ) {
|
||||||
|
@ -57,7 +57,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
game.WorldEvents.OnNewMap -= OnNewMap;
|
game.WorldEvents.OnNewMap -= OnNewMap;
|
||||||
game.WorldEvents.OnNewMapLoaded -= OnNewMapLoaded;
|
game.WorldEvents.OnNewMapLoaded -= OnNewMapLoaded;
|
||||||
game.WorldEvents.EnvVariableChanged -= EnvVariableChanged;
|
game.WorldEvents.EnvVariableChanged -= EnvVariableChanged;
|
||||||
game.WorldEvents.BlockDefinitionChanged -= BlockDefinitionChanged;
|
game.Events.BlockDefinitionChanged -= BlockDefinitionChanged;
|
||||||
game.Events.ViewDistanceChanged -= ViewDistanceChanged;
|
game.Events.ViewDistanceChanged -= ViewDistanceChanged;
|
||||||
game.Events.ProjectionChanged -= ProjectionChanged;
|
game.Events.ProjectionChanged -= ProjectionChanged;
|
||||||
builder.Dispose();
|
builder.Dispose();
|
||||||
@ -388,7 +388,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
} else {
|
} else {
|
||||||
if( info.NormalParts != null )
|
if( info.NormalParts != null )
|
||||||
IncrementUsed( info.NormalParts );
|
IncrementUsed( info.NormalParts );
|
||||||
if (info.TranslucentParts != null )
|
if ( info.TranslucentParts != null )
|
||||||
IncrementUsed( info.TranslucentParts );
|
IncrementUsed( info.TranslucentParts );
|
||||||
}
|
}
|
||||||
chunkUpdates++;
|
chunkUpdates++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user