Fix bug with right clicking attempting to place blocks outside boundaries of the map.

This commit is contained in:
UnknownShadow200 2015-05-18 18:56:04 +10:00
parent 6970982ee8
commit a223762e02

View File

@ -143,9 +143,10 @@ namespace ClassicalSharp {
} }
} else if( right ) { } else if( right ) {
Vector3I pos = SelectedPos.TranslatedPos; Vector3I pos = SelectedPos.TranslatedPos;
if( !Map.IsValidPos( pos ) ) return;
Block block = HeldBlock; Block block = HeldBlock;
byte oldBlock = Map.IsValidPos( pos ) ? Map.GetBlock( pos ) : (byte)0; if( CanReplace( Map.GetBlock( pos ) ) && CanPlace[(int)block] ) {
if( CanReplace( oldBlock ) && CanPlace[(int)block] ) {
Network.SendSetBlock( pos.X, pos.Y, pos.Z, (byte)block ); Network.SendSetBlock( pos.X, pos.Y, pos.Z, (byte)block );
UpdateBlock( pos.X, pos.Y, pos.Z, (byte)block ); UpdateBlock( pos.X, pos.Y, pos.Z, (byte)block );
} }