33import cam72cam .mod .ModCore ;
44import cam72cam .mod .event .platform .LoadDatapackEvent ;
55import net .minecraft .client .Minecraft ;
6- import net .minecraft .resources .*;
7- import net .minecraft .resources .data .IMetadataSectionSerializer ;
8- import net .minecraft .util .ResourceLocation ;
9- import net .minecraft .util .text .StringTextComponent ;
6+ import net .minecraft .network .chat .TextComponent ;
7+ import net .minecraft .resources .ResourceLocation ;
8+ import net .minecraft .server .packs .*;
9+ import net .minecraft .server .packs .metadata .MetadataSectionSerializer ;
10+ import net .minecraft .server .packs .repository .Pack ;
11+ import net .minecraft .server .packs .repository .PackCompatibility ;
12+ import net .minecraft .server .packs .repository .PackSource ;
1013import net .minecraftforge .api .distmarker .Dist ;
1114import net .minecraftforge .api .distmarker .OnlyIn ;
1215import net .minecraftforge .eventbus .api .SubscribeEvent ;
1518import net .minecraftforge .fml .loading .FMLPaths ;
1619
1720import javax .annotation .Nullable ;
18- import java .io .*;
21+ import java .io .ByteArrayInputStream ;
22+ import java .io .File ;
23+ import java .io .IOException ;
24+ import java .io .InputStream ;
1925import java .util .*;
2026import java .util .function .Function ;
2127import java .util .function .Predicate ;
@@ -86,7 +92,7 @@ public static void redirect(Identifier requestedPrefix, Identifier actualPrefix)
8692 * Registers a file or folder as a resource pack to the game.
8793 */
8894 @ OnlyIn (Dist .CLIENT )
89- public static IResourcePack attach (File path ) {
95+ public static PackResources attach (File path ) {
9096 if (path .isDirectory ()) {
9197 return new UMCFolderPack (path );
9298 } else {
@@ -105,29 +111,29 @@ public static void putData(ResourceLocation location, byte[] content) {
105111 * Internal
106112 */
107113 public static void loadClientResources () {
108- List <IResourcePack > packs = new ArrayList <>();
114+ List <PackResources > packs = new ArrayList <>();
109115
110116 for (ModCore .Mod mod : ModCore .instance .getLoadedMods ()) {
111117 BuiltinPack .loadModResource (mod , packs );
112118 }
113119
114- IResourcePack pack = new InternalResourcePack ();
120+ PackResources pack = new InternalResourcePack ();
115121 //Ensure people will get our result first via getResourceStream() and getLastResourceStream()
116122 packs .add (1 , pack );
117123 packs .add (pack );
118124
119125 Minecraft .getInstance ().getResourcePackRepository ().addPackFinder ((consumer , packInfoFactory ) -> {
120- for (IResourcePack pack1 : packs ) {
121- consumer .accept (new ResourcePackInfo (pack1 .getName (),
122- true ,
123- () -> pack1 ,
124- new StringTextComponent ("" ),
125- new StringTextComponent ("" ),
126- PackCompatibility .COMPATIBLE ,
127- ResourcePackInfo . Priority .TOP ,
128- true ,
129- IPackNameDecorator .DEFAULT ,
130- true ));
126+ for (PackResources pack1 : packs ) {
127+ consumer .accept (new Pack (pack1 .getName (),
128+ true ,
129+ () -> pack1 ,
130+ new TextComponent ("" ),
131+ new TextComponent ("" ),
132+ PackCompatibility .COMPATIBLE ,
133+ Pack . Position .TOP ,
134+ true ,
135+ PackSource .DEFAULT ,
136+ true ));
131137 }
132138 });
133139 }
@@ -140,11 +146,11 @@ public static void loadServerResource(LoadDatapackEvent event) {
140146 event .addDataPack (new InternalDataPack ());
141147 }
142148
143- private static void loadModResource (ModCore .Mod mod , List <IResourcePack > packs ) {
149+ private static void loadModResource (ModCore .Mod mod , List <PackResources > packs ) {
144150 String configDir = FMLPaths .CONFIGDIR .toString ();
145151 new File (configDir ).mkdirs ();
146152
147- IResourcePack modPack = BuiltinPack .attach (ModList .get ().getModFileById (mod .modID ()).getFile ().getFilePath ().toFile ());
153+ PackResources modPack = BuiltinPack .attach (ModList .get ().getModFileById (mod .modID ()).getFile ().getFilePath ().toFile ());
148154 // Ensure people will get our result first via getResourceStream() and getLastResourceStream()
149155 // (Also injects last modified time access)
150156 // BUG: sounds can still be overridden by resource packs
@@ -178,7 +184,7 @@ public static void reload() {
178184 /**
179185 * Internal, Client side assets loading
180186 */
181- private static class InternalResourcePack extends ResourcePack {
187+ private static class InternalResourcePack extends AbstractPackResources {
182188 public InternalResourcePack () {
183189 super (ModList .get ().getModFileById ("universalmodcore" ).getFile ().getFilePath ().toFile ());
184190 }
@@ -250,7 +256,7 @@ && handleRedirect(ident, entry.getKey(), entry.getValue()).canLoad()) {
250256 }
251257
252258 @ Override
253- public Collection <ResourceLocation > getResources (ResourcePackType type , String pathIn , String namespace , int maxDepth , Predicate <String > filter ) {
259+ public Collection <ResourceLocation > getResources (PackType type , String pathIn , String namespace , int maxDepth , Predicate <String > filter ) {
254260 //TODO list all redirect/conditional resources, may need new parameters in API?
255261 List <ResourceLocation > result = new ArrayList <>();
256262 final String folder = pathIn + "/" ; // Ensure folders
@@ -278,7 +284,7 @@ public Collection<ResourceLocation> getResources(ResourcePackType type, String p
278284 }
279285
280286 @ Override
281- public Set <String > getNamespaces (ResourcePackType type ) {
287+ public Set <String > getNamespaces (PackType type ) {
282288 Set <String > collect = ModCore .instance .getLoadedMods ().stream ().map (ModCore .Mod ::modID ).collect (Collectors .toSet ());
283289 collect .add ("universalmodcore" );
284290 return collect ;
@@ -291,7 +297,7 @@ public String getName() {
291297
292298 @ Nullable
293299 @ Override
294- public <T > T getMetadataSection (IMetadataSectionSerializer <T > p_195760_1_ ) throws IOException {
300+ public <T > T getMetadataSection (MetadataSectionSerializer <T > p_195760_1_ ) throws IOException {
295301 return getMetadataFromStream (p_195760_1_ , new ByteArrayInputStream ("{}" .getBytes ()));
296302 }
297303
@@ -343,7 +349,7 @@ public static InputStream loadServerResource(Identifier ident) throws IOExceptio
343349 /**
344350 * Internal, Server side data loading
345351 */
346- public static class InternalDataPack extends ResourcePack {
352+ public static class InternalDataPack extends AbstractPackResources {
347353 static Map <ResourceLocation , byte []> data = new HashMap <>();
348354
349355 public InternalDataPack () {
@@ -365,7 +371,7 @@ public boolean hasResource(String resourcePath) {
365371 }
366372
367373 @ Override
368- public Collection <ResourceLocation > getResources (ResourcePackType type , String pathIn , String namespace , int maxDepth , Predicate <String > filter ) {
374+ public Collection <ResourceLocation > getResources (PackType type , String pathIn , String namespace , int maxDepth , Predicate <String > filter ) {
369375 List <ResourceLocation > result = new ArrayList <>();
370376 final String folder = pathIn + "/" ; // Ensure folders
371377 data .keySet ().forEach ((k ) -> {
@@ -381,7 +387,7 @@ public Collection<ResourceLocation> getResources(ResourcePackType type, String p
381387 }
382388
383389 @ Override
384- public Set <String > getNamespaces (ResourcePackType type ) {
390+ public Set <String > getNamespaces (PackType type ) {
385391 Set <String > collect = ModCore .instance .getLoadedMods ().stream ().map (ModCore .Mod ::modID ).collect (Collectors .toSet ());
386392 collect .add ("universalmodcore" );
387393 return collect ;
@@ -398,7 +404,7 @@ public void close() {
398404 }
399405 }
400406
401- private static class UMCFolderPack extends FolderPack {
407+ private static class UMCFolderPack extends FolderPackResources {
402408 public UMCFolderPack (File folder ) {
403409 super (folder );
404410 }
@@ -416,7 +422,7 @@ public boolean hasResource(String resourcePath) {
416422 }
417423 }
418424
419- private static class UMCFilePack extends FilePack {
425+ private static class UMCFilePack extends FilePackResources {
420426 private final File path ;
421427
422428 public UMCFilePack (File fileIn ) {
0 commit comments