~williewillus/patchouli

d63a5eb05a7e930a5756cefeca4d754fd49ea326 — Hubry 3 years ago d8fc0de
Force sending some advancements that Triumph prevents from being synced

Fixes #347
M build.gradle => build.gradle +9 -0
@@ 34,6 34,15 @@ if (System.getenv('BUILD_NUMBER') != null) {
group = "vazkii.patchouli" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = config.mod_name

repositories {
    maven {
        url "https://www.cursemaven.com"
    }
}
dependencies {
    compileOnly 'curse.maven:bnbgamingcore-274341:2991671'
}

minecraft {
    version = "${config.mc_version}-${config.forge_version}"
    runDir = "eclipse/assets"

M src/main/java/vazkii/patchouli/common/base/CommonProxy.java => src/main/java/vazkii/patchouli/common/base/CommonProxy.java +6 -0
@@ 1,12 1,14 @@
package vazkii.patchouli.common.base;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import vazkii.patchouli.api.PatchouliAPI;
import vazkii.patchouli.common.book.BookFolderLoader;
import vazkii.patchouli.common.book.BookRegistry;
import vazkii.patchouli.common.compat.TriumphSyncFixer;
import vazkii.patchouli.common.handler.AdvancementSyncHandler;
import vazkii.patchouli.common.item.PatchouliItems;
import vazkii.patchouli.common.multiblock.MultiblockRegistry;


@@ 27,6 29,10 @@ public class CommonProxy {
		BookRegistry.INSTANCE.init();

		MinecraftForge.EVENT_BUS.register(AdvancementSyncHandler.class);

		if (PatchouliConfig.triumphOverride && Loader.isModLoaded("triumph")) {
			MinecraftForge.EVENT_BUS.register(TriumphSyncFixer.class);
		}
	}
	
	public void init(FMLInitializationEvent event) {

M src/main/java/vazkii/patchouli/common/base/PatchouliConfig.java => src/main/java/vazkii/patchouli/common/base/PatchouliConfig.java +5 -0
@@ 34,6 34,11 @@ public class PatchouliConfig {
	@Comment("Enable if you experience problems with Patchouli not seeing advancements in books.")
	public static boolean enableFirstOpenReload = false;

	@Name("Override Triumph advancement visibility")
	@Comment("If Triumph is installed, hidden advancements are not synced properly, breaking gating entries with them.\n" +
			"If this is set to true, advancements without display info (missing an icon, name or description) will be detected and synced if they are completed.")
	public static boolean triumphOverride = true;

	@Ignore private static Map<String, Boolean> configFlags = new HashMap<>();
	
	public static void preInit() {

A src/main/java/vazkii/patchouli/common/compat/TriumphSyncFixer.java => src/main/java/vazkii/patchouli/common/compat/TriumphSyncFixer.java +17 -0
@@ 0,0 1,17 @@
package vazkii.patchouli.common.compat;

import com.bloodnbonesgaming.bnbgamingcore.events.AdvancementVisibilityEvent;
import net.minecraft.advancements.Advancement;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class TriumphSyncFixer {
	@SubscribeEvent(priority = EventPriority.HIGH)
	public static void unhideAdvancement(AdvancementVisibilityEvent event) {
		Advancement advancement = event.getAdvancement();
		if (advancement.getDisplay() == null
				&& event.getAdvancements().getProgress(advancement).isDone()) {
			event.setCanceled(true);
		}
	}
}