Search in sources :

Example 1 with ResourceManagerReloadListener

use of net.minecraft.server.packs.resources.ResourceManagerReloadListener in project Beyond-Earth by MrScautHD.

the class AlienTrade method addReloadListener.

@SubscribeEvent
public static void addReloadListener(AddReloadListenerEvent event) {
    if (event.getServerResources() != null) {
        RecipeManager recipeManager = event.getServerResources().getRecipeManager();
        event.addListener(new ResourceManagerReloadListener() {

            @Override
            public void onResourceManagerReload(ResourceManager resourceManager) {
                AlienTrade.registerTrades(recipeManager);
            }
        });
    }
}
Also used : RecipeManager(net.minecraft.world.item.crafting.RecipeManager) ResourceManager(net.minecraft.server.packs.resources.ResourceManager) ResourceManagerReloadListener(net.minecraft.server.packs.resources.ResourceManagerReloadListener) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with ResourceManagerReloadListener

use of net.minecraft.server.packs.resources.ResourceManagerReloadListener in project Applied-Energistics-2 by AppliedEnergistics.

the class StyleManagerTest method testInitialize.

@Test
void testInitialize() throws IOException {
    ReloadableResourceManager resourceManager = MockResourceManager.create();
    StyleManager.initialize(resourceManager);
    verify(resourceManager).registerReloadListener(reloadCaptor.capture());
    assertThat(reloadCaptor.getValue()).isNotNull().isInstanceOf(ResourceManagerReloadListener.class);
    ((ResourceManagerReloadListener) reloadCaptor.getValue()).onResourceManagerReload(resourceManager);
}
Also used : ReloadableResourceManager(net.minecraft.server.packs.resources.ReloadableResourceManager) ResourceManagerReloadListener(net.minecraft.server.packs.resources.ResourceManagerReloadListener) Test(org.junit.jupiter.api.Test)

Example 3 with ResourceManagerReloadListener

use of net.minecraft.server.packs.resources.ResourceManagerReloadListener in project Beyond-Earth by MrScautHD.

the class AlienTrade method addReloadListener.

public static void addReloadListener(AddReloadListenerEvent event) {
    if (event.getServerResources() != null) {
        RecipeManager recipeManager = event.getServerResources().getRecipeManager();
        event.addListener(new ResourceManagerReloadListener() {

            @Override
            public void onResourceManagerReload(ResourceManager resourceManager) {
                AlienTrade.registerTrades(recipeManager);
            }
        });
    }
}
Also used : RecipeManager(net.minecraft.world.item.crafting.RecipeManager) ResourceManager(net.minecraft.server.packs.resources.ResourceManager) ResourceManagerReloadListener(net.minecraft.server.packs.resources.ResourceManagerReloadListener)

Example 4 with ResourceManagerReloadListener

use of net.minecraft.server.packs.resources.ResourceManagerReloadListener in project ModernUI by BloCamLimb.

the class ModernUITextMC method init.

public static void init() {
    FMLJavaModLoadingContext.get().getModEventBus().register(ModernUITextMC.class);
    FMLPaths.getOrCreateGameRelativePath(FMLPaths.CONFIGDIR.get().resolve(ModernUI.NAME_CPT), ModernUI.NAME_CPT);
    ModContainer mod = ModLoadingContext.get().getActiveContainer();
    ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
    CONFIG = new Config(builder);
    CONFIG_SPEC = builder.build();
    mod.addConfig(new ModConfig(ModConfig.Type.CLIENT, CONFIG_SPEC, mod, ModernUI.NAME_CPT + "/text.toml"));
    FMLJavaModLoadingContext.get().getModEventBus().addListener(CONFIG::reload);
    if (!DatagenModLoader.isRunningDataGen()) {
        ((ReloadableResourceManager) Minecraft.getInstance().getResourceManager()).registerReloadListener((ResourceManagerReloadListener) (manager) -> TextLayoutEngine.getInstance().reload());
    }
}
Also used : ModContainer(net.minecraftforge.fml.ModContainer) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) ModernUI(icyllis.modernui.ModernUI) ForgeConfigSpec(net.minecraftforge.common.ForgeConfigSpec) IConfigSpec(net.minecraftforge.fml.config.IConfigSpec) FMLClientSetupEvent(net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent) DefaultVertexFormat(com.mojang.blaze3d.vertex.DefaultVertexFormat) MuiForgeApi(icyllis.modernui.forge.MuiForgeApi) Dist(net.minecraftforge.api.distmarker.Dist) FMLJavaModLoadingContext(net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) ModLoadingContext(net.minecraftforge.fml.ModLoadingContext) Nonnull(javax.annotation.Nonnull) FMLPaths(net.minecraftforge.fml.loading.FMLPaths) ShaderInstance(net.minecraft.client.renderer.ShaderInstance) DatagenModLoader(net.minecraftforge.data.loading.DatagenModLoader) ArchCore(icyllis.modernui.core.ArchCore) ResourceManagerReloadListener(net.minecraft.server.packs.resources.ResourceManagerReloadListener) IOException(java.io.IOException) RegisterShadersEvent(net.minecraftforge.client.event.RegisterShadersEvent) ReloadableResourceManager(net.minecraft.server.packs.resources.ReloadableResourceManager) ResourceProvider(net.minecraft.server.packs.resources.ResourceProvider) ModConfig(net.minecraftforge.fml.config.ModConfig) ModConfigEvent(net.minecraftforge.fml.event.config.ModConfigEvent) ReloadableResourceManager(net.minecraft.server.packs.resources.ReloadableResourceManager) ForgeConfigSpec(net.minecraftforge.common.ForgeConfigSpec) ModContainer(net.minecraftforge.fml.ModContainer) ModConfig(net.minecraftforge.fml.config.ModConfig) ModConfig(net.minecraftforge.fml.config.ModConfig)

Aggregations

ResourceManagerReloadListener (net.minecraft.server.packs.resources.ResourceManagerReloadListener)4 ReloadableResourceManager (net.minecraft.server.packs.resources.ReloadableResourceManager)2 ResourceManager (net.minecraft.server.packs.resources.ResourceManager)2 RecipeManager (net.minecraft.world.item.crafting.RecipeManager)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 DefaultVertexFormat (com.mojang.blaze3d.vertex.DefaultVertexFormat)1 ModernUI (icyllis.modernui.ModernUI)1 ArchCore (icyllis.modernui.core.ArchCore)1 MuiForgeApi (icyllis.modernui.forge.MuiForgeApi)1 IOException (java.io.IOException)1 Nonnull (javax.annotation.Nonnull)1 Minecraft (net.minecraft.client.Minecraft)1 ShaderInstance (net.minecraft.client.renderer.ShaderInstance)1 ResourceProvider (net.minecraft.server.packs.resources.ResourceProvider)1 Dist (net.minecraftforge.api.distmarker.Dist)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1 RegisterShadersEvent (net.minecraftforge.client.event.RegisterShadersEvent)1 ForgeConfigSpec (net.minecraftforge.common.ForgeConfigSpec)1 DatagenModLoader (net.minecraftforge.data.loading.DatagenModLoader)1 ModContainer (net.minecraftforge.fml.ModContainer)1