@@ -33,6 +33,9 @@ public FluidInfo(int id, int mass, long info, double fluidExtinction) {
3333 public final int [] ids ;
3434 public final String [] names ;
3535 public final int [] emissive ;
36+ public final float [] blockHardness ;
37+ public final float [] blockResistance ;
38+ public final float [] blockFriction ;
3639 public final Map <String , String > categoryByName ;
3740 public final Set <Integer > notSolidIds ;
3841 public final Map <Integer , FluidInfo > fluidsById ;
@@ -44,13 +47,18 @@ private BlockIndexData(
4447 int [] ids ,
4548 String [] names ,
4649 int [] emissive ,
50+ float [] blockHardness ,
51+ float [] blockResistance ,
52+ float [] blockFriction ,
4753 Map <String , String > categoryByName ,
4854 Set <Integer > notSolidIds ,
49- Map <Integer , FluidInfo > fluidsById
50- ) {
55+ Map <Integer , FluidInfo > fluidsById ) {
5156 this .ids = ids ;
5257 this .names = names ;
5358 this .emissive = emissive ;
59+ this .blockHardness = blockHardness ;
60+ this .blockResistance = blockResistance ;
61+ this .blockFriction = blockFriction ;
5462 this .categoryByName = categoryByName ;
5563 this .notSolidIds = notSolidIds ;
5664 this .fluidsById = fluidsById ;
@@ -107,8 +115,13 @@ final class Entry {
107115 final int fluidG ;
108116 final int fluidB ;
109117 final double fluidExtinction ;
118+ final float hardness ;
119+ final float resistance ;
120+ final float friction ;
110121
111- Entry (String name , int id , int emissive , String category , boolean transparent , boolean fluid , int mass , int fluidR , int fluidG , int fluidB , double fluidExtinction ) {
122+ Entry (String name , int id , int emissive , String category , boolean transparent , boolean fluid , int mass ,
123+ int fluidR , int fluidG , int fluidB , double fluidExtinction , float hardness , float resistance ,
124+ float friction ) {
112125 this .name = name ;
113126 this .id = id ;
114127 this .emissive = emissive ;
@@ -120,6 +133,9 @@ final class Entry {
120133 this .fluidG = fluidG ;
121134 this .fluidB = fluidB ;
122135 this .fluidExtinction = fluidExtinction ;
136+ this .hardness = hardness ;
137+ this .resistance = resistance ;
138+ this .friction = friction ;
123139 }
124140 }
125141
@@ -135,7 +151,8 @@ final class Entry {
135151 int mass = obj .has ("mass" ) ? obj .get ("mass" ).getAsInt () : 0 ;
136152
137153 int emissivePacked = 0 ;
138- if (obj .has ("emissive" ) && obj .get ("emissive" ).isJsonArray () && obj .getAsJsonArray ("emissive" ).size () >= 3 ) {
154+ if (obj .has ("emissive" ) && obj .get ("emissive" ).isJsonArray ()
155+ && obj .getAsJsonArray ("emissive" ).size () >= 3 ) {
139156 double er = obj .getAsJsonArray ("emissive" ).get (0 ).getAsDouble ();
140157 double eg = obj .getAsJsonArray ("emissive" ).get (1 ).getAsDouble ();
141158 double eb = obj .getAsJsonArray ("emissive" ).get (2 ).getAsDouble ();
@@ -144,7 +161,8 @@ final class Entry {
144161 }
145162
146163 int fr = 0 , fg = 0 , fb = 0 ;
147- if (obj .has ("fluidColor" ) && obj .get ("fluidColor" ).isJsonArray () && obj .getAsJsonArray ("fluidColor" ).size () >= 3 ) {
164+ if (obj .has ("fluidColor" ) && obj .get ("fluidColor" ).isJsonArray ()
165+ && obj .getAsJsonArray ("fluidColor" ).size () >= 3 ) {
148166 double r = obj .getAsJsonArray ("fluidColor" ).get (0 ).getAsDouble ();
149167 double g = obj .getAsJsonArray ("fluidColor" ).get (1 ).getAsDouble ();
150168 double b = obj .getAsJsonArray ("fluidColor" ).get (2 ).getAsDouble ();
@@ -163,8 +181,25 @@ final class Entry {
163181 fluidExtinction = obj .get ("fluidExtinction" ).getAsDouble ();
164182 }
165183
184+ // Parse strength values
185+ float hardness = 1.0f ; // default hardness
186+ float resistance = 1.0f ; // default resistance
187+
188+ if (obj .has ("strength" ) && obj .get ("strength" ).isJsonObject ()) {
189+ JsonObject strengthObj = obj .get ("strength" ).getAsJsonObject ();
190+ hardness = strengthObj .has ("hardness" ) ? strengthObj .get ("hardness" ).getAsFloat () : 1.0f ;
191+ resistance = strengthObj .has ("resistance" ) ? strengthObj .get ("resistance" ).getAsFloat () : 1.0f ;
192+ }
193+
194+ // Parse friction value (default 1.0 if missing)
195+ float friction = 1.0f ;
196+ if (obj .has ("friction" )) {
197+ friction = obj .get ("friction" ).getAsFloat ();
198+ }
199+
166200 if (id >= 0 ) {
167- entries .add (new Entry (name , id , emissivePacked , category , transparent , fluid , mass , fr , fg , fb , fluidExtinction ));
201+ entries .add (new Entry (name , id , emissivePacked , category , transparent , fluid , mass , fr , fg , fb ,
202+ fluidExtinction , hardness , resistance , friction ));
168203 }
169204 }
170205
@@ -173,6 +208,9 @@ final class Entry {
173208 int [] ids = new int [entries .size ()];
174209 String [] names = new String [entries .size ()];
175210 int [] emissive = new int [entries .size ()];
211+ float [] blockHardness = new float [entries .size ()];
212+ float [] blockResistance = new float [entries .size ()];
213+ float [] blockFriction = new float [entries .size ()];
176214 Map <String , String > categoryByName = new HashMap <>(entries .size () * 2 );
177215
178216 Set <Integer > notSolidSet = new HashSet <>();
@@ -183,18 +221,23 @@ final class Entry {
183221 ids [i ] = en .id ;
184222 names [i ] = en .name ;
185223 emissive [i ] = en .emissive ;
224+ blockHardness [i ] = en .hardness ;
225+ blockResistance [i ] = en .resistance ;
226+ blockFriction [i ] = en .friction ;
186227 categoryByName .put (en .name .toLowerCase (Locale .ROOT ), en .category == null ? "" : en .category );
187228
188229 if (en .transparent || en .fluid ) {
189230 notSolidSet .add (en .id );
190231 }
191232 if (en .fluid ) {
192233 int a = 255 ;
193- long info = (en .fluidR & 255L ) | ((en .fluidG & 255L ) << 8 ) | ((en .fluidB & 255L ) << 16 ) | ((a & 255L ) << 24 );
234+ long info = (en .fluidR & 255L ) | ((en .fluidG & 255L ) << 8 ) | ((en .fluidB & 255L ) << 16 )
235+ | ((a & 255L ) << 24 );
194236 fluidsById .put (en .id , new FluidInfo (en .id , en .mass , info , en .fluidExtinction ));
195237 }
196238 }
197239
198- return new BlockIndexData (ids , names , emissive , categoryByName , notSolidSet , fluidsById );
240+ return new BlockIndexData (ids , names , emissive , blockHardness , blockResistance , blockFriction , categoryByName ,
241+ notSolidSet , fluidsById );
199242 }
200243}
0 commit comments