1- pub mod entity;
21pub mod processed;
32mod raw;
4- use std:: { collections:: HashMap , fs, ops :: Deref , path:: PathBuf , sync:: Arc , time:: Instant } ;
3+ use std:: { collections:: HashMap , fs, path:: PathBuf , sync:: Arc , time:: Instant } ;
54
6- use azalea_block:: { BlockState , BlockTrait } ;
5+ use azalea_block:: BlockState ;
76use log:: * ;
87use raw:: {
98 block_state:: { BlockRenderState , Variant } ,
@@ -18,7 +17,7 @@ use self::{
1817 } ,
1918 raw:: atlas:: SpriteAtlas ,
2019} ;
21- use crate :: processed:: atlas:: TextureEntry ;
20+ use crate :: processed:: { atlas:: TextureEntry , entity_model :: Model } ;
2221
2322pub struct Assets {
2423 path : PathBuf ,
@@ -30,7 +29,7 @@ pub struct Assets {
3029
3130 pub block_textures : HashMap < String , TextureEntry > ,
3231
33- pub entity_models : HashMap < String , entity :: ModelPart > ,
32+ pub entity_models : HashMap < String , Model > ,
3433}
3534
3635impl Assets {
@@ -213,7 +212,7 @@ pub fn load_assets(path: impl Into<PathBuf>, max_tex: u32) -> Assets {
213212 . filter ( |case| {
214213 case. when
215214 . as_ref ( )
216- . map_or ( true , |cond| cond. matches ( dyn_block. deref ( ) ) )
215+ . map_or ( true , |cond| cond. matches ( dyn_block) )
217216 } )
218217 . filter_map ( |case| match & case. apply {
219218 Variant :: Single ( desc) => Some ( desc) ,
@@ -236,12 +235,17 @@ pub fn load_assets(path: impl Into<PathBuf>, max_tex: u32) -> Assets {
236235 info ! ( "Mapped blockstates to models in {:?}" , start. elapsed( ) ) ;
237236
238237 let entity_models_path = path. join ( "entity_models.json" ) ;
239- let entity_models : HashMap < String , entity :: ModelPart > = serde_json:: from_str (
238+ let raw_entity_models : HashMap < String , raw :: entity_model :: ModelPart > = serde_json:: from_str (
240239 & fs:: read_to_string ( & entity_models_path)
241240 . unwrap_or_else ( |_| panic ! ( "missing {}" , entity_models_path. display( ) ) ) ,
242241 )
243242 . expect ( "invalid entity_models.json" ) ;
244243
244+ let entity_models = raw_entity_models
245+ . into_iter ( )
246+ . map ( |( name, raw) | ( name, Model :: from_raw ( raw) ) )
247+ . collect ( ) ;
248+
245249 let start = Instant :: now ( ) ;
246250
247251 let blocks_atlas_path = path. join ( "atlases/blocks.json" ) ;
@@ -317,7 +321,3 @@ fn load_colormap(textures_root: &PathBuf, relative_path: &str) -> Option<image::
317321 }
318322 }
319323}
320-
321- fn strip_namespace ( model_name : & str ) -> & str {
322- model_name. strip_prefix ( "minecraft:" ) . unwrap_or ( model_name)
323- }
0 commit comments