Search in sources :

Example 1 with FMLClientHandler

use of net.minecraftforge.fml.client.FMLClientHandler in project GregTech by GregTechCE.

the class ResourcePackFix method setModResourcePack.

private static void setModResourcePack(String modid, AbstractResourcePack newPack) {
    FMLClientHandler clientHandler = FMLClientHandler.instance();
    IResourcePack oldPack = clientHandler.getResourcePackFor(modid);
    Map<String, IResourcePack> resourcePackMap = ObfuscationReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackMap");
    resourcePackMap.put(modid, newPack);
    List<IResourcePack> resourcePackList = ObfuscationReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackList");
    resourcePackList.remove(oldPack);
    resourcePackList.add(newPack);
}
Also used : FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) IResourcePack(net.minecraft.client.resources.IResourcePack)

Example 2 with FMLClientHandler

use of net.minecraftforge.fml.client.FMLClientHandler in project BiomesOPlenty by Glitchfiend.

the class ClientProxy method replaceForgeResources.

private static void replaceForgeResources() {
    if (MiscConfigurationHandler.overrideForgeBuckets) {
        FMLClientHandler clientHandler = FMLClientHandler.instance();
        List<IResourcePack> resourcePackList = ReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackList");
        Map<String, IResourcePack> resourcePackMap = ReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackMap");
        LegacyV2Adapter resourcePack = (LegacyV2Adapter) clientHandler.getResourcePackFor("forge");
        // Remove the old resource pack from the registry
        resourcePackList.remove(resourcePack);
        resourcePackMap.remove("forge");
        // Replace Forge's resource pack with our modified version
        ForgeRedirectedResourcePack redirectedResourcePack = new ForgeRedirectedResourcePack(FMLCommonHandler.instance().findContainerFor("forge"));
        // Add our new resource pack in its place
        resourcePackList.add(redirectedResourcePack);
        resourcePackMap.put("forge", redirectedResourcePack);
    }
}
Also used : ForgeRedirectedResourcePack(biomesoplenty.client.texture.ForgeRedirectedResourcePack) FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) LegacyV2Adapter(net.minecraft.client.resources.LegacyV2Adapter) IResourcePack(net.minecraft.client.resources.IResourcePack)

Aggregations

IResourcePack (net.minecraft.client.resources.IResourcePack)2 FMLClientHandler (net.minecraftforge.fml.client.FMLClientHandler)2 ForgeRedirectedResourcePack (biomesoplenty.client.texture.ForgeRedirectedResourcePack)1 LegacyV2Adapter (net.minecraft.client.resources.LegacyV2Adapter)1