Add sponges to singleplayer.

This commit is contained in:
UnknownShadow200 2015-10-29 21:03:12 +11:00
parent c2bd4c7971
commit 8f5f869ab5
3 changed files with 35 additions and 4 deletions

View file

@ -74,7 +74,7 @@ namespace ClassicalSharp.Singleplayer {
public void OnBlockPlaced( int x, int y, int z, byte block ) {
if( !Enabled ) return;
int index = ( y * length + z ) * width + x;
int index = (y * length + z) * width + x;
if( block == (byte)Block.Lava ) {
Lava.Enqueue( defLavaTick | (uint)index );
} else if( block == (byte)Block.Water ) {
@ -85,6 +85,8 @@ namespace ClassicalSharp.Singleplayer {
Explode( 4, x, y, z );
} else if( block == (byte)Block.Sapling ) {
GrowTree( x, y, z );
} else if( block == (byte)Block.Sponge ) {
PlaceSponge( x, y, z );
}
}
@ -244,6 +246,7 @@ namespace ClassicalSharp.Singleplayer {
if( block == (byte)Block.Lava || block == (byte)Block.StillLava ) {
game.UpdateBlock( x, y, z, (byte)Block.Stone );
} else if( info.CollideType[block] == BlockCollideType.WalkThrough ) {
if( CheckIfSponge( x, y, z ) ) return;
Water.Enqueue( defWaterTick | (uint)posIndex );
game.UpdateBlock( x, y, z, (byte)Block.Water );
}
@ -431,5 +434,32 @@ namespace ClassicalSharp.Singleplayer {
}
#endregion
#region Sponge
void PlaceSponge( int x, int y, int z ) {
for( int yy = y - 2; yy <= y + 2; yy++ ) {
for( int zz = z - 2; zz <= z + 2; zz++ ) {
for( int xx = x - 2; xx <= x + 2; xx++ ) {
byte block = map.SafeGetBlock( xx, yy, zz );
if( block == (byte)Block.Water || block == (byte)Block.StillWater )
map.SetBlock( xx, yy, zz, (byte)Block.Air );
}
}
}
}
bool CheckIfSponge( int x, int y, int z ) {
for( int yy = y - 2; yy <= y + 2; yy++ ) {
for( int zz = z - 2; zz <= z + 2; zz++ ) {
for( int xx = x - 2; xx <= x + 2; xx++ ) {
byte block = map.SafeGetBlock( xx, yy, zz );
if( block == (byte)Block.Sponge ) return true;
}
}
}
return false;
}
#endregion
}
}

View file

@ -125,7 +125,7 @@ namespace Launcher2 {
platformDrawer.Draw( Window.WindowInfo, Framebuffer );
}
internal FastColour clearColour = new FastColour( 30, 30, 30 );
internal FastColour clearColour = new FastColour( 101, 79, 119 );
public void MakeBackground() {
if( Framebuffer != null )
Framebuffer.Dispose();

View file

@ -536,8 +536,9 @@ namespace OpenTK.Platform.Windows
icon = value;
if (window.WindowHandle != IntPtr.Zero)
{
Icon small = new Icon( value, 16, 16 );
API.SendMessage(window.WindowHandle, WindowMessage.SETICON, (IntPtr)0, icon == null ? IntPtr.Zero : small.Handle);
//Icon small = new Icon( value, 16, 16 );
//GC.KeepAlive( small );
API.SendMessage(window.WindowHandle, WindowMessage.SETICON, (IntPtr)0, icon == null ? IntPtr.Zero : value.Handle);
API.SendMessage(window.WindowHandle, WindowMessage.SETICON, (IntPtr)1, icon == null ? IntPtr.Zero : value.Handle);
}
}