@@ -35,6 +35,7 @@ public static class World
3535 { "jungle_stairs" , new [ ] { "planks_jungle" } } ,
3636 { "spruce_stairs" , new [ ] { "planks_spruce" } } ,
3737 { "dark_oak_stairs" , new [ ] { "planks_big_oak" } } ,
38+ { "birch_stairs" , new [ ] { "planks_birch" } } ,
3839 { "stone_brick_stairs" , new [ ] { "stonebrick" } } ,
3940 { "polished_andesite_stairs" , new [ ] { "stone_andesite_smooth" } } ,
4041 { "polished_diorite_stairs" , new [ ] { "stone_diorite_smooth" } } ,
@@ -177,15 +178,15 @@ public static class World
177178 int logType = data & 0b_0011 ;
178179 switch ( logType ) {
179180 case 0 :
180- return new [ ] { "log_oak_top" } ;
181+ return new [ ] { "log_oak" , " log_oak_top" } ;
181182 case 1 :
182- return new [ ] { "log_spruce_top" } ;
183+ return new [ ] { "log_spruce" , " log_spruce_top" } ;
183184 case 2 :
184- return new [ ] { "log_birch_top" } ;
185+ return new [ ] { "log_birch" , " log_birch_top" } ;
185186 case 3 :
186- return new [ ] { "log_jungle_top" } ;
187+ return new [ ] { "log_jungle" , " log_jungle_top" } ;
187188 default :
188- return new [ ] { "log_oak_top" } ;
189+ return new [ ] { "log_oak" , " log_oak_top" } ;
189190 }
190191 }
191192 } ,
@@ -695,6 +696,19 @@ public static class World
695696 }
696697 } // oak
697698 } ,
699+ { "birch_door" , ( int data ) =>
700+ {
701+ int upper_block_bit = ( data & 0b_1000 ) >> 3 ;
702+ switch ( upper_block_bit ) {
703+ case 0 :
704+ return new [ ] { "door_birch_lower" } ;
705+ case 1 :
706+ return new [ ] { "door_birch_upper" } ;
707+ default :
708+ return new [ ] { "door_birch_lower" } ;
709+ }
710+ } // oak
711+ } ,
698712
699713
700714 { "" , ( int data ) =>
@@ -775,12 +789,13 @@ public static class World
775789 { "snow_layer" , 15 } ,
776790 { "powered_repeater" , 16 } ,
777791 { "unpowered_repeater" , 16 } ,
792+ { "vine" , 19 } ,
778793 } ;
779794
780795
781796 public delegate void RenderBlock ( Vector3 pos , Vector3i cp /*chunk pos, pre multiplied*/ , int [ ] tex , int data , ref List < Vertex > vertices , ref List < uint > triangles ) ;
782797
783- // TODO stair other corner
798+ // TODO stair other corner, Data meaning from: https://minecraft.fandom.com/wiki/Block_states
784799 public static Dictionary < int , RenderBlock > blockRenderers = new Dictionary < int , RenderBlock > ( )
785800 {
786801 { 0 , ( Vector3 pos , Vector3i cp , int [ ] tex , int data , ref List < Vertex > vertices , ref List < uint > triangles ) => // full
@@ -1360,6 +1375,57 @@ public static class World
13601375 }
13611376 }
13621377 } ,
1378+ { 17 , ( Vector3 pos , Vector3i cp , int [ ] texA , int data , ref List < Vertex > vertices , ref List < uint > triangles ) => // log
1379+ {
1380+ Vector3 offset = new Vector3 ( - 0.5f , - 0.5f , - 0.5f ) ;
1381+
1382+ uint texSide = ( uint ) texA [ 0 ] ;
1383+ uint texTopBottom = ( uint ) texA [ 1 ] ;
1384+
1385+ int dir = ( data & 0b_1100 ) >> 2 ; // 0 - y, 1 - x, 2 - z
1386+ Matrix3 mat = Matrix3 . Identity ;
1387+
1388+ if ( dir == 1 ) {
1389+ mat = Matrix3 . CreateRotationZ ( 1.5708f ) ; // 90 degrees
1390+ } else if ( dir == 2 ) {
1391+ mat = Matrix3 . CreateRotationX ( 1.5708f ) ; // 90 degrees
1392+ }
1393+
1394+ for ( int p = 0 ; p < 6 ; p ++ ) {
1395+ uint firstVertIndex = ( uint ) vertices . Count ;
1396+ if ( p == 2 || p == 3 ) { // top/bottom
1397+ vertices . Add ( new Vertex ( pos + VoxelData . voxelVerts [ VoxelData . voxelTris [ p , 0 ] ] + offset , VoxelData . voxelUvs [ 0 ] , texTopBottom ) ) ;
1398+ vertices . Add ( new Vertex ( pos + VoxelData . voxelVerts [ VoxelData . voxelTris [ p , 1 ] ] + offset , VoxelData . voxelUvs [ 1 ] , texTopBottom ) ) ;
1399+ vertices . Add ( new Vertex ( pos + VoxelData . voxelVerts [ VoxelData . voxelTris [ p , 2 ] ] + offset , VoxelData . voxelUvs [ 2 ] , texTopBottom ) ) ;
1400+ vertices . Add ( new Vertex ( pos + VoxelData . voxelVerts [ VoxelData . voxelTris [ p , 3 ] ] + offset , VoxelData . voxelUvs [ 3 ] , texTopBottom ) ) ;
1401+ } else {
1402+ vertices . Add ( new Vertex ( pos + VoxelData . voxelVerts [ VoxelData . voxelTris [ p , 0 ] ] + offset , VoxelData . voxelUvs [ 0 ] , texSide ) ) ;
1403+ vertices . Add ( new Vertex ( pos + VoxelData . voxelVerts [ VoxelData . voxelTris [ p , 1 ] ] + offset , VoxelData . voxelUvs [ 1 ] , texSide ) ) ;
1404+ vertices . Add ( new Vertex ( pos + VoxelData . voxelVerts [ VoxelData . voxelTris [ p , 2 ] ] + offset , VoxelData . voxelUvs [ 2 ] , texSide ) ) ;
1405+ vertices . Add ( new Vertex ( pos + VoxelData . voxelVerts [ VoxelData . voxelTris [ p , 3 ] ] + offset , VoxelData . voxelUvs [ 3 ] , texSide ) ) ;
1406+ }
1407+ triangles . Add ( firstVertIndex ) ;
1408+ triangles . Add ( firstVertIndex + 1 ) ;
1409+ triangles . Add ( firstVertIndex + 2 ) ;
1410+ triangles . Add ( firstVertIndex + 2 ) ;
1411+ triangles . Add ( firstVertIndex + 1 ) ;
1412+ triangles . Add ( firstVertIndex + 3 ) ;
1413+ }
1414+ }
1415+ } ,
1416+ { 18 , ( Vector3 pos , Vector3i cp , int [ ] texA , int data , ref List < Vertex > vertices , ref List < uint > triangles ) => // log stripped
1417+ {
1418+ blockRenderers [ 17 ] ( pos , cp , texA , data << 2 /*here axis is 0b0011, for normal logs it's 0b1100 so we need to shift it*/ ,
1419+ ref vertices , ref triangles ) ;
1420+ }
1421+ } ,
1422+ { 19 , ( Vector3 pos , Vector3i cp , int [ ] tex , int data , ref List < Vertex > vertices , ref List < uint > triangles ) => // vine
1423+ {
1424+ Vector3 offset = new Vector3 ( 0f , 0f , 0f ) ;
1425+ Vector3 size = new Vector3 ( 1f , 1f , 1f ) ;
1426+ CubeTex ( tex [ 0 ] , pos + offset , size , ref vertices , ref triangles ) ;
1427+ }
1428+ } ,
13631429 } ;
13641430
13651431 private static BuildPlate plate ;
@@ -1556,6 +1622,10 @@ public static void Init()
15561622 string blockName = blockNames [ subchunk ] [ plate . sub_chunks [ subchunk ] . blocks [ block ] ] ;
15571623 if ( blockRenderersLookUp . ContainsKey ( blockName ) )
15581624 renderers [ block ] = blockRenderersLookUp [ blockName ] ;
1625+ else if ( blockName . Contains ( "stripped" ) ) // stripped log
1626+ renderers [ block ] = 18 ;
1627+ else if ( blockName . Contains ( "log" ) )
1628+ renderers [ block ] = 17 ;
15591629 else if ( blockName . Contains ( "pressure_plate" ) )
15601630 renderers [ block ] = 14 ;
15611631 else if ( blockName . Contains ( "gate" ) )
@@ -1580,7 +1650,11 @@ public static void Init()
15801650
15811651 Palette [ ] palette = new Palette [ plate . sub_chunks [ subchunk ] . block_palette . Count - 1 ] ;
15821652 for ( int i = 0 ; i < palette . Length ; i ++ ) {
1583- palette [ i ] = new Palette ( plate . sub_chunks [ subchunk ] . block_palette [ i + 1 ] . name , plate . sub_chunks [ subchunk ] . block_palette [ i ] . data , textures [ i + 1 ] ) ;
1653+ int [ ] _tex = textures [ i ] . Cloned ( ) ;
1654+ for ( int j = 0 ; j < _tex . Length ; j ++ ) {
1655+ _tex [ j ] = _tex [ j ] + 1 ;
1656+ }
1657+ palette [ i ] = new Palette ( plate . sub_chunks [ subchunk ] . block_palette [ i + 1 ] . name , plate . sub_chunks [ subchunk ] . block_palette [ i ] . data , _tex ) ;
15841658 Console . WriteLine ( $ "[{ i } ] Block: { palette [ i ] . name } , Data: { palette [ i ] . data } , Texture: { palette [ i ] . textures [ 0 ] } ") ;
15851659 }
15861660
0 commit comments