Search in sources :

Example 1 with SimpleSynchronousResourceReloader

use of org.quiltmc.qsl.resource.loader.api.reloader.SimpleSynchronousResourceReloader in project quilt-standard-libraries by QuiltMC.

the class ResourceReloaderTestMod method setupClientReloadListeners.

private void setupClientReloadListeners() {
    ResourceLoader.get(ResourceType.CLIENT_RESOURCES).registerReloader(new SimpleSynchronousResourceReloader() {

        @Override
        public Identifier getQuiltId() {
            return ResourceLoaderTestMod.id("client_second");
        }

        @Override
        public void reload(ResourceManager manager) {
            if (!clientResources) {
                throw new AssertionError("Second resource reloader was called before the first!");
            }
            LOGGER.info("Second client resource reloader is called.");
        }

        @Override
        public Collection<Identifier> getQuiltDependencies() {
            return Collections.singletonList(ResourceLoaderTestMod.id("client_first"));
        }
    });
    ResourceLoader.get(ResourceType.CLIENT_RESOURCES).registerReloader(new SimpleSynchronousResourceReloader() {

        @Override
        public Identifier getQuiltId() {
            return ResourceLoaderTestMod.id("client_first");
        }

        @Override
        public void reload(ResourceManager manager) {
            clientResources = true;
            LOGGER.info("First client resource reloader is called.");
        }
    });
}
Also used : Identifier(net.minecraft.util.Identifier) SimpleSynchronousResourceReloader(org.quiltmc.qsl.resource.loader.api.reloader.SimpleSynchronousResourceReloader) Collection(java.util.Collection) ResourceManager(net.minecraft.resource.ResourceManager)

Example 2 with SimpleSynchronousResourceReloader

use of org.quiltmc.qsl.resource.loader.api.reloader.SimpleSynchronousResourceReloader in project quilt-standard-libraries by QuiltMC.

the class ResourceReloaderTestMod method setupServerReloadListeners.

private void setupServerReloadListeners() {
    ResourceLoader.get(ResourceType.SERVER_DATA).registerReloader(new SimpleSynchronousResourceReloader() {

        @Override
        public Identifier getQuiltId() {
            return ResourceLoaderTestMod.id("server_second");
        }

        @Override
        public void reload(ResourceManager manager) {
            if (!serverResources) {
                throw new AssertionError("Second resource reloader was called before the first!");
            }
            LOGGER.info("Second server resource reloader is called.");
        }

        @Override
        public Collection<Identifier> getQuiltDependencies() {
            return Collections.singletonList(ResourceLoaderTestMod.id("server_first"));
        }
    });
    ResourceLoader.get(ResourceType.SERVER_DATA).registerReloader(new SimpleSynchronousResourceReloader() {

        @Override
        public Identifier getQuiltId() {
            return ResourceLoaderTestMod.id("server_first");
        }

        @Override
        public void reload(ResourceManager manager) {
            serverResources = true;
            LOGGER.info("First server resource reloader is called.");
        }
    });
}
Also used : Identifier(net.minecraft.util.Identifier) SimpleSynchronousResourceReloader(org.quiltmc.qsl.resource.loader.api.reloader.SimpleSynchronousResourceReloader) Collection(java.util.Collection) ResourceManager(net.minecraft.resource.ResourceManager)

Aggregations

Collection (java.util.Collection)2 ResourceManager (net.minecraft.resource.ResourceManager)2 Identifier (net.minecraft.util.Identifier)2 SimpleSynchronousResourceReloader (org.quiltmc.qsl.resource.loader.api.reloader.SimpleSynchronousResourceReloader)2