Search in sources :

Example 1 with ResourcePackRepository

use of net.minecraft.client.resources.ResourcePackRepository in project Almura by AlmuraDev.

the class AlmuraSettings method applyPack.

protected static void applyPack(String pack) {
    final GameSettings settings = Minecraft.getMinecraft().gameSettings;
    final ClientConfiguration configuration = configAdapter.get();
    if (!settings.resourcePacks.contains(pack)) {
        settings.resourcePacks.add(pack);
    }
    settings.saveOptions();
    final ResourcePackRepository resourcepackrepository = Minecraft.getMinecraft().getResourcePackRepository();
    final Iterator<String> iterator = settings.resourcePacks.iterator();
    while (iterator.hasNext()) {
        String name = iterator.next();
        for (ResourcePackRepository.Entry resourcepackrepository$entry : ((ResourcePackRepositoryAccessor) resourcepackrepository).accessor$getRepositoryEntriesAll()) {
            if (resourcepackrepository$entry.getResourcePackName().equals(name)) {
                if (resourcepackrepository$entry.getPackFormat() == 3 || settings.incompatibleResourcePacks.contains(resourcepackrepository$entry.getResourcePackName())) {
                    if (!((ResourcePackRepositoryAccessor) resourcepackrepository).accessor$getRepositoryEntries().contains(resourcepackrepository$entry)) {
                        ((ResourcePackRepositoryAccessor) resourcepackrepository).accessor$getRepositoryEntries().add(resourcepackrepository$entry);
                    }
                    break;
                }
                iterator.remove();
            }
        }
    }
}
Also used : ResourcePackRepository(net.minecraft.client.resources.ResourcePackRepository) ResourcePackRepositoryAccessor(com.almuradev.almura.asm.mixin.accessors.client.resources.ResourcePackRepositoryAccessor) GameSettings(net.minecraft.client.settings.GameSettings) ClientConfiguration(com.almuradev.almura.core.client.config.ClientConfiguration)

Aggregations

ResourcePackRepositoryAccessor (com.almuradev.almura.asm.mixin.accessors.client.resources.ResourcePackRepositoryAccessor)1 ClientConfiguration (com.almuradev.almura.core.client.config.ClientConfiguration)1 ResourcePackRepository (net.minecraft.client.resources.ResourcePackRepository)1 GameSettings (net.minecraft.client.settings.GameSettings)1