@@ -1249,31 +1249,34 @@ internal void SendNewEntities(World world) {
1249
1249
}
1250
1250
}
1251
1251
1252
- internal void SendBlockPermissions ( ) {
1253
- Block max = supportsCustomBlocks ? Map . MaxCustomBlockType : Map . MaxLegalBlockType ;
1254
- bool build = World . Buildable , delete = World . Deletable ;
1255
- for ( Block block = Block . Stone ; block <= max ; block ++ ) {
1256
- Send ( Packet . MakeSetBlockPermission ( block , build , delete ) ) ;
1252
+ bool CheckPlacePerm ( Block block ) {
1253
+ switch ( block ) {
1254
+ case Block . Air : return World . Deletable ;
1255
+ case Block . Grass : return Can ( Permission . PlaceGrass ) ;
1256
+ case Block . Admincrete : return Can ( Permission . PlaceAdmincrete ) ;
1257
+ case Block . Water :
1258
+ case Block . StillWater : return Can ( Permission . PlaceWater ) ;
1259
+ case Block . Lava :
1260
+ case Block . StillLava : return Can ( Permission . PlaceLava ) ;
1257
1261
}
1262
+ return true ;
1263
+ }
1264
+
1265
+ bool CheckDeletePerm ( Block block ) {
1266
+ return block != Block . Admincrete || Can ( Permission . DeleteAdmincrete ) ;
1267
+ }
1268
+
1269
+ internal void SendBlockPermissions ( ) {
1270
+ int max = supportsCustomBlocks ? ( int ) Map . MaxCustomBlockType : ( int ) Map . MaxLegalBlockType ;
1271
+ if ( supportsBlockDefs ) max = byte . MaxValue ;
1258
1272
1259
- Send ( Packet . MakeSetBlockPermission ( Block . Admincrete ,
1260
- build && Can ( Permission . PlaceAdmincrete ) , delete && Can ( Permission . PlaceAdmincrete ) ) ) ;
1261
- Send ( Packet . MakeSetBlockPermission (
1262
- Block . Water , build && Can ( Permission . PlaceWater ) , delete ) ) ;
1263
- Send ( Packet . MakeSetBlockPermission (
1264
- Block . StillWater , build && Can ( Permission . PlaceWater ) , delete ) ) ;
1265
- Send ( Packet . MakeSetBlockPermission (
1266
- Block . Lava , build && Can ( Permission . PlaceLava ) , delete ) ) ;
1267
- Send ( Packet . MakeSetBlockPermission (
1268
- Block . StillLava , build && Can ( Permission . PlaceLava ) , delete ) ) ;
1269
- Send ( Packet . MakeSetBlockPermission (
1270
- Block . Grass , build && Can ( Permission . PlaceGrass ) , delete ) ) ;
1271
-
1272
- if ( ! supportsBlockDefs ) return ;
1273
- BlockDefinition [ ] defs = World . BlockDefs ;
1274
- for ( int i = ( int ) Block . Air + 1 ; i < defs . Length ; i ++ ) {
1275
- if ( defs [ i ] == null ) continue ;
1276
- Send ( Packet . MakeSetBlockPermission ( ( Block ) i , build , delete ) ) ;
1273
+ for ( int i = ( int ) Block . Air ; i <= max ; i ++ ) {
1274
+ Block block = ( Block ) i ;
1275
+ bool build = World . Buildable && CheckPlacePerm ( block ) ;
1276
+ bool delete = World . Deletable && CheckDeletePerm ( block ) ;
1277
+
1278
+ if ( i > ( int ) Map . MaxCustomBlockType && World . BlockDefs [ i ] == null ) continue ;
1279
+ Send ( Packet . MakeSetBlockPermission ( block , build , delete ) ) ;
1277
1280
}
1278
1281
}
1279
1282
0 commit comments