1010
1111import com .google .common .base .Supplier ;
1212import com .google .common .base .Suppliers ;
13+ import com .google .common .cache .CacheBuilder ;
14+ import com .google .common .cache .CacheLoader ;
15+ import com .google .common .cache .LoadingCache ;
1316import com .google .gson .Gson ;
1417import com .google .gson .GsonBuilder ;
1518import com .google .gson .JsonArray ;
5255import java .util .Base64 ;
5356import java .util .List ;
5457import java .util .UUID ;
58+ import java .util .concurrent .TimeUnit ;
5559import java .util .regex .Matcher ;
5660import java .util .regex .Pattern ;
5761
@@ -64,6 +68,15 @@ public class HeadRecipe extends RunicAltarRecipe {
6468 private static final Supplier <Gson > gson = Suppliers .memoize (() -> new GsonBuilder ()
6569 .registerTypeAdapter (UUID .class , new UUIDTypeAdapter ()).create ());
6670 private static final GameProfile PROFILE_VALID_RESULT = new GameProfile (null , "valid" );
71+ private static final LoadingCache <String , UUID > GENERATED_UUID_CACHE = CacheBuilder .newBuilder ()
72+ .expireAfterAccess (1 , TimeUnit .MINUTES ).build (
73+ new CacheLoader <>() {
74+ @ NotNull
75+ @ Override
76+ public UUID load (@ NotNull String key ) {
77+ return UUID .nameUUIDFromBytes (key .getBytes (StandardCharsets .UTF_8 ));
78+ }
79+ });
6780
6881 public HeadRecipe (ResourceLocation id , ItemStack output , int mana , Ingredient ... inputs ) {
6982 super (id , output , mana , inputs );
@@ -175,8 +188,8 @@ private GameProfile parseProfileFromBook(ItemStack stack, boolean validateOnly)
175188 }
176189 // we got something that looks like a valid skin texture URL, now build rudimentary profile data
177190 String profileTextureJson = "{textures:{SKIN:{url:\" %s\" }}}" .formatted (textureUrl );
178- var profile = new GameProfile (null , name );
179191 String propertyBase64 = Base64 .getEncoder ().encodeToString (profileTextureJson .getBytes (StandardCharsets .UTF_8 ));
192+ var profile = new GameProfile (GENERATED_UUID_CACHE .getUnchecked (propertyBase64 ), name );
180193 profile .getProperties ().put ("textures" , new Property ("Value" , propertyBase64 ));
181194 return profile ;
182195 }
0 commit comments