55import com .mojang .serialization .Codec ;
66import net .fabricmc .fabric .api .client .datagen .v1 .provider .FabricModelProvider ;
77import net .fabricmc .fabric .api .datagen .v1 .FabricDataOutput ;
8- import net .minecraft .Util ;
98import net .minecraft .client .data .models .model .ModelInstance ;
109import net .minecraft .client .renderer .block .model .BlockModel ;
1110import net .minecraft .client .renderer .block .model .ItemModelGenerator ;
1918import net .minecraft .data .CachedOutput ;
2019import net .minecraft .data .DataProvider ;
2120import net .minecraft .data .PackOutput ;
21+ import net .minecraft .resources .Identifier ;
2222import net .minecraft .resources .ResourceKey ;
23- import net .minecraft .resources .ResourceLocation ;
2423import net .minecraft .server .packs .resources .ResourceManager ;
2524import net .minecraft .util .ProblemReporter ;
25+ import net .minecraft .util .Util ;
2626import net .minecraft .world .item .Item ;
2727import net .minecraft .world .item .equipment .EquipmentAsset ;
2828import org .geysermc .rainbow .Rainbow ;
@@ -60,11 +60,11 @@ public abstract class RainbowModelProvider extends FabricModelProvider {
6060 private final Path packPath ;
6161
6262 private Map <Item , ClientItem > itemInfos ;
63- private Map <ResourceLocation , ModelInstance > models ;
63+ private Map <Identifier , ModelInstance > models ;
6464
6565 protected RainbowModelProvider (FabricDataOutput output , CompletableFuture <HolderLookup .Provider > registries ,
6666 Map <ResourceKey <EquipmentAsset >, EquipmentClientInfo > equipmentInfos , String packName ,
67- ResourceLocation outputRoot , Path geyserMappingsPath , Path packPath ) {
67+ Identifier outputRoot , Path geyserMappingsPath , Path packPath ) {
6868 super (output );
6969 this .registries = registries ;
7070 this .equipmentInfos = equipmentInfos ;
@@ -78,13 +78,13 @@ protected RainbowModelProvider(FabricDataOutput output, CompletableFuture<Holder
7878
7979 protected RainbowModelProvider (FabricDataOutput output , CompletableFuture <HolderLookup .Provider > registries ,
8080 Map <ResourceKey <EquipmentAsset >, EquipmentClientInfo > equipmentInfos , String packName ,
81- ResourceLocation outputRoot ) {
81+ Identifier outputRoot ) {
8282 this (output , registries , equipmentInfos , packName , outputRoot , Path .of ("geyser_mappings.json" ), Path .of ("pack" ));
8383 }
8484
8585 protected RainbowModelProvider (FabricDataOutput output , CompletableFuture <HolderLookup .Provider > registries ,
8686 Map <ResourceKey <EquipmentAsset >, EquipmentClientInfo > equipmentInfos , String packName ) {
87- this (output , registries , equipmentInfos , packName , ResourceLocation .withDefaultNamespace ("bedrock" ));
87+ this (output , registries , equipmentInfos , packName , Identifier .withDefaultNamespace ("bedrock" ));
8888 }
8989
9090 protected RainbowModelProvider (FabricDataOutput output , CompletableFuture <HolderLookup .Provider > registries , String packName ) {
@@ -105,7 +105,7 @@ protected RainbowModelProvider(FabricDataOutput output, CompletableFuture<Holder
105105 BedrockPack pack = createBedrockPack (new Serializer (output , registries ),
106106 new DatagenResolver (resourceManager , equipmentInfos , itemInfos , models )).build ();
107107
108- Set <Item > sortedItemInfos = new TreeSet <>(Comparator .comparing (item -> item .builtInRegistryHolder ().key ().location ()));
108+ Set <Item > sortedItemInfos = new TreeSet <>(Comparator .comparing (item -> item .builtInRegistryHolder ().key ().identifier ()));
109109 sortedItemInfos .addAll (itemInfos .keySet ());
110110 for (Item item : sortedItemInfos ) {
111111 pack .map (getVanillaItem (item ).builtInRegistryHolder (), getVanillaDataComponentPatch (item ));
@@ -136,7 +136,7 @@ public void setItemInfos(Map<Item, ClientItem> itemInfos) {
136136 }
137137
138138 @ ApiStatus .Internal
139- public void setModels (Map <ResourceLocation , ModelInstance > models ) {
139+ public void setModels (Map <Identifier , ModelInstance > models ) {
140140 this .models = models ;
141141 }
142142
@@ -162,33 +162,33 @@ public CompletableFuture<?> saveTexture(byte[] texture, Path path) {
162162 private static class DatagenResolver implements AssetResolver {
163163 private final ResourceManager resourceManager ;
164164 private final Map <ResourceKey <EquipmentAsset >, EquipmentClientInfo > equipmentInfos ;
165- private final Map <ResourceLocation , ClientItem > itemInfos ;
166- private final Map <ResourceLocation , ModelInstance > models ;
167- private final Map <ResourceLocation , Optional <ResolvedModel >> resolvedModelCache = new HashMap <>();
165+ private final Map <Identifier , ClientItem > itemInfos ;
166+ private final Map <Identifier , ModelInstance > models ;
167+ private final Map <Identifier , Optional <ResolvedModel >> resolvedModelCache = new HashMap <>();
168168
169169 private DatagenResolver (ResourceManager resourceManager , Map <ResourceKey <EquipmentAsset >, EquipmentClientInfo > equipmentInfos ,
170- Map <Item , ClientItem > itemInfos , Map <ResourceLocation , ModelInstance > models ) {
170+ Map <Item , ClientItem > itemInfos , Map <Identifier , ModelInstance > models ) {
171171 this .resourceManager = resourceManager ;
172172 this .equipmentInfos = equipmentInfos ;
173173 this .itemInfos = new HashMap <>();
174174 for (Map .Entry <Item , ClientItem > entry : itemInfos .entrySet ()) {
175- this .itemInfos .put (entry .getKey ().builtInRegistryHolder ().key ().location (), entry .getValue ());
175+ this .itemInfos .put (entry .getKey ().builtInRegistryHolder ().key ().identifier (), entry .getValue ());
176176 }
177177 this .models = models ;
178178 }
179179
180180 @ Override
181- public Optional <ResolvedModel > getResolvedModel (ResourceLocation location ) {
182- return resolvedModelCache .computeIfAbsent (location , key -> Optional .ofNullable (models .get (location ))
181+ public Optional <ResolvedModel > getResolvedModel (Identifier identifier ) {
182+ return resolvedModelCache .computeIfAbsent (identifier , key -> Optional .ofNullable (models .get (identifier ))
183183 .<UnbakedModel >map (instance -> BlockModel .fromStream (new StringReader (instance .get ().toString ())))
184184 .or (() -> {
185- if (location .equals (ItemModelGenerator .GENERATED_ITEM_MODEL_ID )) {
185+ if (identifier .equals (ItemModelGenerator .GENERATED_ITEM_MODEL_ID )) {
186186 return Optional .of (new ItemModelGenerator ());
187187 }
188188 return Optional .empty ();
189189 })
190190 .or (() -> RainbowIO .safeIO (() -> {
191- try (BufferedReader reader = resourceManager .openAsReader (location .withPrefix ("models/" ).withSuffix (".json" ))) {
191+ try (BufferedReader reader = resourceManager .openAsReader (identifier .withPrefix ("models/" ).withSuffix (".json" ))) {
192192 return BlockModel .fromStream (reader );
193193 }
194194 }))
@@ -205,14 +205,14 @@ public Optional<ResolvedModel> getResolvedModel(ResourceLocation location) {
205205
206206 @ Override
207207 public @ NotNull String debugName () {
208- return location .toString ();
208+ return identifier .toString ();
209209 }
210210 }));
211211 }
212212
213213 @ Override
214- public Optional <ClientItem > getClientItem (ResourceLocation location ) {
215- return Optional .ofNullable (itemInfos .get (location ));
214+ public Optional <ClientItem > getClientItem (Identifier identifier ) {
215+ return Optional .ofNullable (itemInfos .get (identifier ));
216216 }
217217
218218 @ Override
@@ -221,9 +221,9 @@ public Optional<EquipmentClientInfo> getEquipmentInfo(ResourceKey<EquipmentAsset
221221 }
222222
223223 @ Override
224- public Optional <TextureResource > getTexture (ResourceLocation atlas , ResourceLocation location ) {
224+ public Optional <TextureResource > getTexture (Identifier atlas , Identifier identifier ) {
225225 // We don't care about atlas since there are none loaded at datagen
226- return resourceManager .getResource (Rainbow .decorateTextureLocation ( location ))
226+ return resourceManager .getResource (Rainbow .decorateTextureIdentifier ( identifier ))
227227 .flatMap (resource -> RainbowIO .safeIO (() -> {
228228 Optional <AnimationMetadataSection > animationMetadata = resource .metadata ().getSection (AnimationMetadataSection .TYPE );
229229 try (InputStream textureStream = resource .open ()) {
0 commit comments