Search in sources :

Example 26 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project Client by Sol-Client.

the class MixinResourcePackRepository method postInit.

@Inject(method = "<init>", at = @At("RETURN"))
public void postInit(File dirResourcepacksIn, File dirServerResourcepacksIn, IResourcePack rprDefaultResourcePackIn, IMetadataSerializer rprMetadataSerializerIn, GameSettings settings, CallbackInfo callback) {
    Map<File, ResourcePackRepository> repos = new HashMap<>();
    Iterator<String> packIterator = settings.resourcePacks.iterator();
    while (packIterator.hasNext()) {
        String packName = packIterator.next();
        File file = new File(dirResourcepacksIn, packName);
        if (!file.exists()) {
            continue;
        }
        File parent = file.getParentFile();
        ResourcePackRepository applicableRepo;
        if (packName.contains("/")) {
            applicableRepo = repos.computeIfAbsent(parent, (ignored) -> {
                ResourcePackRepository repo = new ResourcePackRepository(parent, dirServerResourcepacksIn, rprDefaultResourcePackIn, rprMetadataSerializerIn, settings);
                repo.getRepositoryEntriesAll();
                return repo;
            });
        } else {
            applicableRepo = (ResourcePackRepository) (Object) this;
        }
        for (ResourcePackRepository.Entry entry : applicableRepo.getRepositoryEntriesAll()) {
            if (entry.getResourcePackName().equals(packName)) {
                if (entry.func_183027_f() == 1 || settings.incompatibleResourcePacks.contains(entry.getResourcePackName())) {
                    repositoryEntries.add(entry);
                    break;
                }
                packIterator.remove();
                logger.warn("Removed selected resource pack {} because it\'s no longer compatible", entry.getResourcePackName());
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) IMetadataSerializer(net.minecraft.client.resources.data.IMetadataSerializer) Inject(org.spongepowered.asm.mixin.injection.Inject) Redirect(org.spongepowered.asm.mixin.injection.Redirect) ResourcePackRepository(net.minecraft.client.resources.ResourcePackRepository) HashMap(java.util.HashMap) Final(org.spongepowered.asm.mixin.Final) File(java.io.File) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Mixin(org.spongepowered.asm.mixin.Mixin) IResourcePack(net.minecraft.client.resources.IResourcePack) Map(java.util.Map) GameSettings(net.minecraft.client.settings.GameSettings) Shadow(org.spongepowered.asm.mixin.Shadow) At(org.spongepowered.asm.mixin.injection.At) ResourcePackRepository(net.minecraft.client.resources.ResourcePackRepository) HashMap(java.util.HashMap) File(java.io.File) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

IResourcePack (net.minecraft.client.resources.IResourcePack)25 File (java.io.File)11 IOException (java.io.IOException)11 InputStream (java.io.InputStream)9 List (java.util.List)7 Field (java.lang.reflect.Field)5 IResourceManager (net.minecraft.client.resources.IResourceManager)4 FileNotFoundException (java.io.FileNotFoundException)3 ArrayList (java.util.ArrayList)3 AbstractResourcePack (net.minecraft.client.resources.AbstractResourcePack)3 LegacyV2Adapter (net.minecraft.client.resources.LegacyV2Adapter)3 ResourcePackRepository (net.minecraft.client.resources.ResourcePackRepository)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 FMLClientHandler (net.minecraftforge.fml.client.FMLClientHandler)3 FileInputStream (java.io.FileInputStream)2 Set (java.util.Set)2 ZipFile (java.util.zip.ZipFile)2 FallbackResourceManager (net.minecraft.client.resources.FallbackResourceManager)2 SimpleReloadableResourceManager (net.minecraft.client.resources.SimpleReloadableResourceManager)2 GameSettings (net.minecraft.client.settings.GameSettings)2