@@ -67,12 +67,6 @@ public void setDisplayedItem(EntityMetadata<ItemStack, ?> entityMetadata) {
6767
6868 String type = session .getItemMappings ().getMapping (stack .getId ()).getJavaItem ().javaIdentifier ();
6969
70-
71- CustomModelData modelData = null ;
72- DataComponents components = stack .getDataComponentsPatch ();
73-
74- if (components != null ) modelData = components .get (DataComponentTypes .CUSTOM_MODEL_DATA );
75-
7670 for (FileConfiguration mappingsConfig : GeyserDisplayEntity .getExtension ().getConfigManager ().getConfigMappingsCache ().values ()) {
7771 for (Object mappingKey : mappingsConfig .getRootNode ().childrenMap ().keySet ()) {
7872 String mappingString = mappingKey .toString ();
@@ -81,19 +75,13 @@ public void setDisplayedItem(EntityMetadata<ItemStack, ?> entityMetadata) {
8175 if (mappingConfig == null ) continue ;
8276 if (!mappingConfig .getString ("type" ).equals (type )) continue ;
8377
84- if (mappingConfig .getInt ("model-data" ) == -1 ) {
85- config = mappingConfig .getConfigurationSection ("displayentityoptions" );
86- setOffset (config .getDouble ("y-offset" ));
87- if (config .getBoolean ("vanilla-scale" )) applyScale ();
78+ if (GeyserDisplayEntity .getExtension ().getConfigManager ().getConfig ().getBoolean ("general.use-legacy-models" )) {
79+ applyLegacyModelData (stack , mappingConfig );
8880 break ;
8981 }
9082
91- if (modelData != null && Math .abs (mappingConfig .getInt ("model-data" ) - modelData .floats ().get (0 )) < 0.5 ) {
92- config = mappingConfig .getConfigurationSection ("displayentityoptions" );
93- setOffset (config .getDouble ("y-offset" ));
94- if (config .getBoolean ("vanilla-scale" )) applyScale ();
95- break ;
96- }
83+ applyModernItemModels (item , mappingConfig );
84+ break ;
9785 }
9886 }
9987
@@ -120,6 +108,43 @@ public void setDisplayedItem(EntityMetadata<ItemStack, ?> entityMetadata) {
120108 updateMainHand (session );
121109 }
122110
111+ private void applyLegacyModelData (ItemStack item , FileConfiguration mappingConfig ) {
112+ CustomModelData modelData = null ;
113+ DataComponents components = item .getDataComponentsPatch ();
114+
115+ if (components != null ) modelData = components .get (DataComponentTypes .CUSTOM_MODEL_DATA );
116+
117+ if (mappingConfig .getInt ("model-data" ) == -1 ) {
118+ entityApplyDisplayConfig (mappingConfig );
119+ return ;
120+ }
121+
122+ if (modelData == null ) return ;
123+
124+ if (Math .abs (mappingConfig .getInt ("model-data" ) - modelData .floats ().get (0 )) < 0.5 ) {
125+ entityApplyDisplayConfig (mappingConfig );
126+ }
127+ }
128+
129+ private void applyModernItemModels (ItemData itemData , FileConfiguration mappingConfig ) {
130+ String itemBedrockIdentifier = itemData .getDefinition ().getIdentifier ().replace ("geyser_custom:" , "" );
131+
132+ if (mappingConfig .getString ("item-identifier" ).equals ("none" )) {
133+ entityApplyDisplayConfig (mappingConfig );
134+ return ;
135+ }
136+
137+ if (mappingConfig .getString ("item-identifier" ).equalsIgnoreCase (itemBedrockIdentifier )) {
138+ entityApplyDisplayConfig (mappingConfig );
139+ }
140+ }
141+
142+ private void entityApplyDisplayConfig (FileConfiguration mappingConfig ) {
143+ config = mappingConfig .getConfigurationSection ("displayentityoptions" );
144+ setOffset (config .getDouble ("y-offset" ));
145+ if (config .getBoolean ("vanilla-scale" )) applyScale ();
146+ }
147+
123148 @ Override
124149 protected void applyScale () {
125150 if (needHide ) {
0 commit comments