11package org .embeddedt .modernfix .forge .dynresources ;
22
3+ import com .google .common .collect .ImmutableList ;
34import com .google .common .collect .Lists ;
45import it .unimi .dsi .fastutil .objects .Object2ObjectOpenHashMap ;
56import net .minecraft .client .resources .model .ModelResourceLocation ;
@@ -17,11 +18,11 @@ public class ModelLocationBuilder {
1718 private final Map <Property <?>, PropertyData > propertyToOptionStrings = new Object2ObjectOpenHashMap <>();
1819 private final StringBuilder builder = new StringBuilder ();
1920
20- private record PropertyData (List <String > nameValuePairs , int maxPairLength ) {}
21+ private record PropertyData (ImmutableList <String > nameValuePairs , int maxPairLength ) {}
2122
2223 public void generateForBlock (Set <ResourceLocation > destinationSet , Block block , ResourceLocation baseLocation ) {
2324 var props = block .getStateDefinition ().getProperties ();
24- List <List <String >> optionsList = new ArrayList <>(props .size ());
25+ List <ImmutableList <String >> optionsList = new ArrayList <>(props .size ());
2526 int requiredBuilderSize = Math .max (0 , props .size () - 1 ); // commas
2627 for (var prop : props ) {
2728 var data = propertyToOptionStrings .computeIfAbsent (prop , ModelLocationBuilder ::computePropertyOptions );
@@ -47,14 +48,14 @@ public void generateForBlock(Set<ResourceLocation> destinationSet, Block block,
4748 }
4849
4950 private static PropertyData computePropertyOptions (Property <?> prop ) {
50- List <String > valuesList = new ArrayList <> (prop .getPossibleValues ().size ());
51+ ImmutableList . Builder <String > valuesList = ImmutableList . builderWithExpectedSize (prop .getPossibleValues ().size ());
5152 int maxLength = 0 ;
5253 for (var val : prop .getPossibleValues ()) {
5354 String pair = prop .getName () + "=" + getValueName (prop , val );
5455 valuesList .add (pair .toLowerCase (Locale .ROOT ));
5556 maxLength = Math .max (pair .length (), maxLength );
5657 }
57- return new PropertyData (List . copyOf ( valuesList ), maxLength );
58+ return new PropertyData (valuesList . build ( ), maxLength );
5859 }
5960
6061 private static <T extends Comparable <T >> String getValueName (Property <T > property , Comparable <?> value ) {
0 commit comments