@@ -1369,15 +1369,11 @@ static void CustomBlockAddHandler(Player p, CommandReader cmd, bool global, Bloc
13691369 }
13701370
13711371 static void CustomBlockInfoHandler ( Player p , CommandReader cmd , bool global , BlockDefinition [ ] defs ) {
1372- string input = cmd . Next ( ) ?? "n/a" ;
13731372 string scope = global ? "global" : "level" ;
13741373 string name = global ? "/gb" : "/lb" ;
13751374
13761375 Block id ;
1377- if ( ! Map . GetBlockByName ( p . World , input , false , out id ) || id < Map . MaxCustomBlockType ) {
1378- p . Message ( "No blocks by that name or id!" ) ;
1379- return ;
1380- }
1376+ if ( ! cmd . NextBlock ( p , false , out id ) ) return ;
13811377
13821378 BlockDefinition def = GetCustomBlock ( global , defs , ( byte ) id ) ;
13831379 if ( def == null ) {
@@ -1429,14 +1425,11 @@ static void CustomBlockListHandler(Player p, CommandReader cmd, bool global, Blo
14291425 }
14301426
14311427 static void CustomBlockRemoveHandler ( Player p , CommandReader cmd , bool global , BlockDefinition [ ] defs ) {
1432- string input = cmd . Next ( ) ?? "n/a" ;
14331428 Block blockID ;
14341429 string scope = global ? "global" : "level" ;
14351430 string name = global ? "/gb" : "/lb" ;
1436- if ( ! Map . GetBlockByName ( p . World , input , false , out blockID ) || blockID < Map . MaxCustomBlockType ) {
1437- p . Message ( "No blocks by that Name/ID!" ) ;
1438- return ;
1439- }
1431+ if ( ! cmd . NextBlock ( p , false , out blockID ) ) return ;
1432+
14401433 BlockDefinition def = GetCustomBlock ( global , defs , ( byte ) blockID ) ;
14411434 if ( def == null ) {
14421435 p . Message ( "There is no {0} custom block with that name/id." , scope ) ;
@@ -1664,22 +1657,20 @@ static void CustomBlockDefineHandler(Player p, string args, bool global, BlockDe
16641657 }
16651658
16661659 static void CustomBlockDuplicateHandler ( Player p , CommandReader cmd , bool global , BlockDefinition [ ] defs ) {
1667- string input1 = cmd . Next ( ) ?? "n/a" , input2 = cmd . Next ( ) ?? "n/a" ;
1668- Block srcBlock = Block . None ;
1669- byte dstBlock = ( byte ) Block . None ;
1660+ Block srcBlock , dstBlock ;
16701661 string scope = global ? "global" : "level" ;
16711662 string name = global ? "/gb" : "/lb" ;
16721663
1673- if ( ! Map . GetBlockByName ( p . World , input1 , false , out srcBlock ) || srcBlock <= Map . MaxCustomBlockType ) {
1674- p . Message ( "There is no {1} custom block with the id or name: &a{0}" , input1 , scope ) ;
1675- p . Message ( "Use \" &h{1} list&S\" to see a list of {0} custom blocks." , scope , name ) ;
1676- return ;
1677- }
1678- if ( ! Byte . TryParse ( input2 , out dstBlock ) || dstBlock <= ( byte ) Map . MaxCustomBlockType ) {
1679- p . Message ( "Destination must be a numerical id and greater than 65." ) ; return ;
1664+ if ( ! cmd . NextBlock ( p , false , out srcBlock ) ) return ;
1665+ if ( ! cmd . NextBlock ( p , false , out dstBlock ) ) return ;
1666+ if ( dstBlock == Block . Air || dstBlock == Block . None ) {
1667+ p . Message ( "Destination block cannot have 0 or 255 ID." ) ; return ;
16801668 }
16811669
16821670 BlockDefinition srcDef = GetCustomBlock ( global , defs , ( byte ) srcBlock ) ;
1671+ if ( srcDef == null && srcBlock <= Map . MaxCustomBlockType )
1672+ srcDef = DefaultSet . MakeCustomBlock ( srcBlock ) ;
1673+
16831674 if ( srcDef == null ) {
16841675 p . Message ( "There is no {1} custom block with the id: &a{0}" , ( byte ) srcBlock , scope ) ;
16851676 p . Message ( "Use \" &H{1} list&S\" to see a list of {0} custom blocks." , scope , name ) ;
@@ -1706,16 +1697,13 @@ static void CustomBlockDuplicateHandler(Player p, CommandReader cmd, bool global
17061697 }
17071698
17081699 static void CustomBlockEditHandler ( Player p , CommandReader cmd , bool global , BlockDefinition [ ] defs ) {
1709- string input = cmd . Next ( ) ?? "n/a" ;
17101700 Block blockID ;
1711- if ( ! Map . GetBlockByName ( p . World , input , false , out blockID ) || blockID < Map . MaxCustomBlockType ) {
1712- p . Message ( "No blocks by that Name/ID!" ) ;
1713- return ;
1714- }
1715-
1716- BlockDefinition def = GetCustomBlock ( global , defs , ( byte ) blockID ) ;
17171701 string scope = global ? "global" : "level" ;
17181702 string name = global ? "/gb" : "/lb" ;
1703+
1704+ if ( ! cmd . NextBlock ( p , false , out blockID ) ) return ;
1705+
1706+ BlockDefinition def = GetCustomBlock ( global , defs , ( byte ) blockID ) ;
17191707 if ( def == null ) {
17201708 p . Message ( "There is no {0} custom block with that Name/ID" , scope ) ; return ;
17211709 }
@@ -2017,8 +2005,8 @@ static bool CheckBlockId(Player p, CommandReader cmd, out int blockId) {
20172005 p . Message ( "Provided block id is not a number." ) ;
20182006 return false ;
20192007 }
2020- if ( blockId <= 65 || blockId >= 255 ) {
2021- p . Message ( "Block id must be between 65 -254" ) ;
2008+ if ( blockId == 0 || blockId >= 255 ) {
2009+ p . Message ( "Block id must be between 1 -254" ) ;
20222010 return false ;
20232011 }
20242012 return true ;
0 commit comments