Search in sources :

Example 1 with ISelectiveResourceReloadListener

use of net.minecraftforge.resource.ISelectiveResourceReloadListener 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)

Aggregations

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 ArrayList (java.util.ArrayList)1 Supplier (java.util.function.Supplier)1 Block (net.minecraft.block.Block)1 RenderType (net.minecraft.client.renderer.RenderType)1 RenderTypeLookup (net.minecraft.client.renderer.RenderTypeLookup)1 IReloadableResourceManager (net.minecraft.resources.IReloadableResourceManager)1 IResourceManager (net.minecraft.resources.IResourceManager)1 Tuple (net.minecraft.util.Tuple)1 Dist (net.minecraftforge.api.distmarker.Dist)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1 FMLClientSetupEvent (net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent)1 ISelectiveResourceReloadListener (net.minecraftforge.resource.ISelectiveResourceReloadListener)1 VanillaResourceType (net.minecraftforge.resource.VanillaResourceType)1