@@ -1266,7 +1266,7 @@ static Dictionary<string, string> MakeHelpSections(string scope, string name) {
12661266 "&SCreates a new custom block, using all the data of the given existing " + scope + " custom block. " } ,
12671267 { "edit" , "&H" + name + " edit [id] [option] {args}&N" +
12681268 "&SEdits already defined blocks so you don't have to re-add them to change something. " +
1269- "Options: Name, Solidity, Speed, AllId, TopId, SideID, BottomID, Light, Sound, FullBright, Shape, Draw, FogDensity, (FogHex or FogR, FogG, FogB), FallBack" } ,
1269+ "Options: Name, Solidity, Speed, AllId, TopId, SideID, BottomID, Light, Sound, FullBright, Shape, Draw, FogDensity, (FogHex or FogR, FogG, FogB), FallBack, Order " } ,
12701270 { "reload" , "&H" + name + " reload&N" +
12711271 "&SReloads all " + scope + " custom blocks from file. " } ,
12721272 { "info" , "&H" + name + " info [id]&N" +
@@ -1911,7 +1911,10 @@ static void CustomBlockEditHandler(Player p, CommandReader cmd, bool global, Blo
19111911 }
19121912 p . Message ( "&bChanged fallback block of &a{0}&b from &a{1}&b to &a{2}" , def . Name , def . FallBack , newBlock . ToString ( ) ) ;
19131913 def . FallBack = ( byte ) newBlock ;
1914- hasChanged = true ;
1914+
1915+ DisplayEditMessage ( p , def , global ) ;
1916+ UpdateFallback ( ) ;
1917+ return ;
19151918 }
19161919 break ;
19171920 case "min" :
@@ -1961,28 +1964,55 @@ static void CustomBlockEditHandler(Player p, CommandReader cmd, bool global, Blo
19611964 def . Shape = value ;
19621965 }
19631966 break ;
1967+ case "order" :
1968+ byte order = 0 ;
1969+ if ( byte . TryParse ( args , out order ) && order > 0 ) {
1970+ def . InventoryOrder = order ;
1971+ DisplayEditMessage ( p , def , global ) ;
1972+ UpdateOrder ( p . World , def , global ) ;
1973+ BlockDefinition . Save ( global , p . World ) ;
1974+ }
1975+ return ;
19641976 default :
19651977 p . Message ( "Usage: &H" + name + " [type/value] {args}" ) ;
19661978 return ;
19671979 }
1968- if ( ! hasChanged ) return ;
19691980
1970- if ( global ) {
1971- Server . Message ( "{0} &Sedited a {3} custom block &a{1} &Swith ID &a{2}" ,
1972- p . ClassyName , def . Name , def . BlockID , scope ) ;
1981+ if ( ! hasChanged ) return ;
1982+ DisplayEditMessage ( p , def , global ) ;
1983+ BlockDefinition . Add ( def , defs , p . World ) ;
1984+ }
1985+
1986+ static void DisplayEditMessage ( Player p , BlockDefinition def , bool global ) {
1987+ if ( global ) {
1988+ Server . Message ( "{0} &Sedited a global custom block &a{1} &Swith ID &a{2}" ,
1989+ p . ClassyName , def . Name , def . BlockID ) ;
19731990 } else {
1974- p . World . Players . Message ( "{0} &Sedited a {3} custom block &a{1} &Swith ID &a{2}" ,
1975- p . ClassyName , def . Name , def . BlockID , scope ) ;
1991+ p . World . Players . Message ( "{0} &Sedited a level custom block &a{1} &Swith ID &a{2}" ,
1992+ p . ClassyName , def . Name , def . BlockID ) ;
19761993 }
1977- BlockDefinition . Add ( def , defs , p . World ) ;
1994+ }
1995+
1996+ static void UpdateOrder ( World world , BlockDefinition def , bool global ) {
1997+ if ( def . InventoryOrder == - 1 ) return ;
1998+ byte id = def . BlockID , order = ( byte ) def . InventoryOrder ;
19781999
1979- foreach ( Player pl in Server . Players ) {
1980- if ( ! p . Supports ( CpeExt . BlockDefinitions ) &&
1981- ( option . CaselessEquals ( "block" ) || option . CaselessEquals ( "fallback" ) ) ) {
1982- p . JoinWorld ( p . World , WorldChangeReason . Rejoin , p . Position ) ;
1983- }
2000+ foreach ( Player player in Server . Players ) {
2001+ if ( ! global && player . World != world ) continue ;
2002+ if ( global && player . World . BlockDefs [ id ] != BlockDefinition . GlobalDefs [ id ] ) continue ;
2003+
2004+ if ( ! player . Supports ( CpeExt . InventoryOrder ) ) continue ;
2005+ player . Send ( Packet . SetInventoryOrder ( id , order ) ) ;
19842006 }
19852007 }
2008+
2009+ static void UpdateFallback ( ) {
2010+ foreach ( Player player in Server . Players ) {
2011+ if ( ! player . Supports ( CpeExt . BlockDefinitions ) ) {
2012+ player . JoinWorld ( player . World , WorldChangeReason . Rejoin , player . Position ) ;
2013+ }
2014+ }
2015+ }
19862016
19872017 static byte EditCoord ( Player p , string coord , string name ,
19882018 string args , byte origValue , ref bool hasChanged ) {
0 commit comments