Search in sources :

Example 1 with IReloadableResourceManager

use of net.minecraft.resources.IReloadableResourceManager in project Structurize by ldtteam.

the class ClientLifecycleSubscriber method onClientInit.

/**
 * Called when client app is initialized.
 *
 * @param event event
 */
@SubscribeEvent
public static void onClientInit(final FMLClientSetupEvent event) {
    OptifineCompat.getInstance().intialize();
    final IResourceManager rm = event.getMinecraftSupplier().get().getResourceManager();
    if (rm instanceof IReloadableResourceManager) {
        ((IReloadableResourceManager) rm).registerReloadListener((ISelectiveResourceReloadListener) (resourceManager, resourcePredicate) -> {
            if (resourcePredicate.test(VanillaResourceType.MODELS) || resourcePredicate.test(VanillaResourceType.TEXTURES) || resourcePredicate.test(VanillaResourceType.SHADERS)) {
                Log.getLogger().debug("Clearing blueprint renderer cache.");
                BlueprintHandler.getInstance().clearCache();
            }
            Log.getLogger().debug("Clearing gui XML cache.");
            Loader.cleanParsedCache();
        });
    }
    // final RenderType s = RenderType.getSolid();
    // ModBlocks.blockSubstitution;
    // ModBlocks.blockSolidSubstitution;
    // ModBlocks.blockFluidSubstitution;
    // ModBlocks.multiBlock;
    // ModBlocks.blockDecoBarrel_onside;
    // ModBlocks.blockDecoBarrel_standing;
    // ModBlocks.paperWalls;
    // ModBlocks.floatingCarpets;
    // ModBlocks.timberFrames;
    // ModBlocks.shingles;
    // ModBlocks.shingleSlabs;
    // final RenderType c = RenderType.getCutout();
    // final RenderType cm = RenderType.getCutoutMipped();
    final RenderType t = RenderType.translucent();
    ModBlocks.getPaperWalls().forEach(frame -> RenderTypeLookup.setRenderLayer(frame, t));
    // ModBlocks.CACTI_BLOCKS
    // ModBlocks.BRICKS
    DELAYED_RENDER_TYPE_SETUP.forEach(tu -> {
        if (!tu.getB().equals(RenderType.solid())) {
            RenderTypeLookup.setRenderLayer(tu.getA().get(), tu.getB());
        }
    });
    DELAYED_RENDER_TYPE_SETUP.clear();
    DELAYED_RENDER_TYPE_SETUP.trimToSize();
}
Also used : ISelectiveResourceReloadListener(net.minecraftforge.resource.ISelectiveResourceReloadListener) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) BlueprintHandler(com.ldtteam.structures.client.BlueprintHandler) IResourceManager(net.minecraft.resources.IResourceManager) Tuple(net.minecraft.util.Tuple) RenderType(net.minecraft.client.renderer.RenderType) FMLClientSetupEvent(net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent) Supplier(java.util.function.Supplier) VanillaResourceType(net.minecraftforge.resource.VanillaResourceType) Dist(net.minecraftforge.api.distmarker.Dist) ArrayList(java.util.ArrayList) Loader(com.ldtteam.blockout.Loader) RenderTypeLookup(net.minecraft.client.renderer.RenderTypeLookup) OptifineCompat(com.ldtteam.structurize.optifine.OptifineCompat) ModBlocks(com.ldtteam.structurize.blocks.ModBlocks) Block(net.minecraft.block.Block) Log(com.ldtteam.structurize.api.util.Log) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) IReloadableResourceManager(net.minecraft.resources.IReloadableResourceManager) IReloadableResourceManager(net.minecraft.resources.IReloadableResourceManager) IResourceManager(net.minecraft.resources.IResourceManager) RenderType(net.minecraft.client.renderer.RenderType) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with IReloadableResourceManager

use of net.minecraft.resources.IReloadableResourceManager in project RGBBlocks by PlatinPython.

the class ClientUtils method registerVirtualPack.

private static void registerVirtualPack() {
    Minecraft minecraft = Minecraft.getInstance();
    minecraft.getResourcePackRepository().addPackFinder((infoConsumer, packInfo) -> infoConsumer.accept(new ResourcePackInfo("rgbblocks_textures", true, () -> VIRTUAL_PACK, new TranslationTextComponent("rgbblocks.pack_title"), new TranslationTextComponent("rgbblocks.pack_description"), PackCompatibility.COMPATIBLE, ResourcePackInfo.Priority.TOP, true, IPackNameDecorator.DEFAULT, true)));
    IReloadableResourceManager resourceManager = (IReloadableResourceManager) minecraft.getResourceManager();
    resourceManager.registerReloadListener(VIRTUAL_PACK);
}
Also used : IReloadableResourceManager(net.minecraft.resources.IReloadableResourceManager) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Minecraft(net.minecraft.client.Minecraft) ResourcePackInfo(net.minecraft.resources.ResourcePackInfo)

Example 3 with IReloadableResourceManager

use of net.minecraft.resources.IReloadableResourceManager in project Vampirism by TeamLapen.

the class ModEntitiesRender method registerEntityRenderer.

public static void registerEntityRenderer(Supplier<Minecraft> minecraftSupplier) {
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.blinding_bat, safeFactory(BatRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.converted_creature_imob, safeFactory(ConvertedCreatureRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.converted_creature, safeFactory(ConvertedCreatureRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.converted_horse, renderingManager -> {
        HorseRenderer renderer = new HorseRenderer(renderingManager);
        renderer.addLayer(new VampireEntityLayer<>(renderer, new ResourceLocation(REFERENCE.MODID, "textures/entity/vanilla/horse_overlay.png"), false));
        return renderer;
    });
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.converted_donkey, safeFactory(ConvertedChestedHorseRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.converted_mule, safeFactory(ConvertedChestedHorseRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.converted_sheep, safeFactory(ConvertedCreatureRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.converted_cow, safeFactory(ConvertedCreatureRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.hunter, safeFactory(BasicHunterRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.hunter_imob, safeFactory(BasicHunterRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.vampire, safeFactory(BasicVampireRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.vampire_imob, safeFactory(BasicVampireRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.hunter_trainer, e -> new HunterTrainerRenderer(e, true));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.vampire_baron, safeFactory(VampireBaronRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.advanced_hunter, safeFactory(AdvancedHunterRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.advanced_hunter_imob, safeFactory(AdvancedHunterRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.advanced_vampire, safeFactory(AdvancedVampireRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.advanced_vampire_imob, safeFactory(AdvancedVampireRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.villager_converted, safeFactory(ConvertedVillagerRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.villager_angry, (renderManager) -> new HunterVillagerRenderer(renderManager, (IReloadableResourceManager) minecraftSupplier.get().getResourceManager()));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.crossbow_arrow, safeFactory(CrossbowArrowRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.particle_cloud, safeFactory(RenderAreaParticleCloud::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.throwable_item, manager -> new ThrowableItemRenderer(manager, Minecraft.getInstance().getItemRenderer()));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.dark_blood_projectile, safeFactory(DarkBloodProjectileRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.soul_orb, manager -> new SoulOrbRenderer(manager, Minecraft.getInstance().getItemRenderer()));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.hunter_trainer_dummy, e -> new HunterTrainerRenderer(e, false));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.dummy_creature, safeFactory(DummyRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.vampire_minion, safeFactory(VampireMinionRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.hunter_minion, safeFactory(HunterMinionRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.task_master_vampire, safeFactory(VampireTaskMasterRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.task_master_hunter, safeFactory(HunterTaskMasterRenderer::new));
    RenderingRegistry.registerEntityRenderingHandler(ModEntities.dummy_sit_entity, safeFactory(DummyRenderer::new));
}
Also used : HorseRenderer(net.minecraft.client.renderer.entity.HorseRenderer) IReloadableResourceManager(net.minecraft.resources.IReloadableResourceManager) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 4 with IReloadableResourceManager

use of net.minecraft.resources.IReloadableResourceManager in project AstralSorcery by HellFirePvP.

the class ClientProxy method initialize.

@Override
public void initialize() {
    this.clientScheduler = new ClientScheduler();
    if (!AstralSorcery.isDoingDataGeneration()) {
        IReloadableResourceManager resMgr = (IReloadableResourceManager) Minecraft.getInstance().getResourceManager();
        resMgr.addReloadListener(AssetLibrary.INSTANCE);
        resMgr.addReloadListener(AssetPreLoader.INSTANCE);
        resMgr.addReloadListener(ColorizationHelper.onReload());
        resMgr.addReloadListener((stage, resourceManager, preparationsProfiler, reloadProfiler, backgroundExecutor, gameExecutor) -> stage.markCompleteAwaitingOthers(Unit.INSTANCE).thenRunAsync(() -> {
            if (!SelectiveReloadStateHandler.INSTANCE.get().test(VanillaResourceType.LANGUAGES)) {
                return;
            }
            PerkTree.PERK_TREE.getPerkPoints(LogicalSide.CLIENT).stream().map(PerkTreePoint::getPerk).forEach(AbstractPerk::clearClientTextCaches);
        }));
    }
    this.clientConfig = new ClientConfig();
    super.initialize();
    this.addTomeBookmarks();
    RandomWordGenerator.init();
    this.clientConfig.buildConfiguration();
}
Also used : PerkTreePoint(hellfirepvp.astralsorcery.common.perk.tree.PerkTreePoint) IReloadableResourceManager(net.minecraft.resources.IReloadableResourceManager) ClientConfig(hellfirepvp.astralsorcery.client.data.config.ClientConfig)

Example 5 with IReloadableResourceManager

use of net.minecraft.resources.IReloadableResourceManager in project Mekanism by mekanism.

the class ClientRegistration method createRobitTextureAtlas.

private static void createRobitTextureAtlas() {
    // TODO - 1.18: Move registering the sprite uploader to RegisterClientReloadListenersEvent
    Minecraft minecraft = Minecraft.getInstance();
    RobitSpriteUploader spriteUploader = new RobitSpriteUploader(minecraft.getTextureManager());
    IResourceManager resourceManager = minecraft.getResourceManager();
    if (resourceManager instanceof IReloadableResourceManager) {
        IReloadableResourceManager reloadableResourceManager = (IReloadableResourceManager) resourceManager;
        reloadableResourceManager.registerReloadListener(spriteUploader);
    }
}
Also used : IReloadableResourceManager(net.minecraft.resources.IReloadableResourceManager) IResourceManager(net.minecraft.resources.IResourceManager) Minecraft(net.minecraft.client.Minecraft)

Aggregations

IReloadableResourceManager (net.minecraft.resources.IReloadableResourceManager)7 IResourceManager (net.minecraft.resources.IResourceManager)3 Minecraft (net.minecraft.client.Minecraft)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 IProxy (com.davenonymous.libnonymous.setup.IProxy)1 ModCommands (com.davenonymous.riddlechests.command.ModCommands)1 Networking (com.davenonymous.riddlechests.network.Networking)1 ProxyClient (com.davenonymous.riddlechests.proxy.ProxyClient)1 ProxyServer (com.davenonymous.riddlechests.proxy.ProxyServer)1 LootTableMappingRecipeHelper (com.davenonymous.riddlechests.recipe.loottable.LootTableMappingRecipeHelper)1 Config (com.davenonymous.riddlechests.setup.Config)1 ModObjects (com.davenonymous.riddlechests.setup.ModObjects)1 WorldGenEvents (com.davenonymous.riddlechests.setup.WorldGenEvents)1 Logz (com.davenonymous.riddlechests.util.Logz)1 Loader (com.ldtteam.blockout.Loader)1 BlueprintHandler (com.ldtteam.structures.client.BlueprintHandler)1 Log (com.ldtteam.structurize.api.util.Log)1 ModBlocks (com.ldtteam.structurize.blocks.ModBlocks)1 OptifineCompat (com.ldtteam.structurize.optifine.OptifineCompat)1 ClientConfig (hellfirepvp.astralsorcery.client.data.config.ClientConfig)1