Search in sources :

Example 1 with ClientAdvancementManager

use of net.minecraft.client.multiplayer.ClientAdvancementManager in project takumicraft by TNTModders.

the class TakumiUtils method getAdvancementUnlocked.

@SideOnly(Side.CLIENT)
public static boolean getAdvancementUnlocked(ResourceLocation location) {
    ClientAdvancementManager manager = Minecraft.getMinecraft().player.connection.getAdvancementManager();
    try {
        Field field = TakumiASMNameMap.getField(ClientAdvancementManager.class, "advancementToProgress");
        field.setAccessible(true);
        Map<Advancement, AdvancementProgress> advancementToProgress = (Map<Advancement, AdvancementProgress>) field.get(manager);
        if (advancementToProgress.containsKey(manager.getAdvancementList().getAdvancement(location))) {
            return advancementToProgress.get(manager.getAdvancementList().getAdvancement(location)).isDone();
        }
    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }
    return false;
}
Also used : Field(java.lang.reflect.Field) AdvancementProgress(net.minecraft.advancements.AdvancementProgress) ClientAdvancementManager(net.minecraft.client.multiplayer.ClientAdvancementManager) TakumiASMNameMap(com.tntmodders.asm.TakumiASMNameMap) Advancement(net.minecraft.advancements.Advancement) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

TakumiASMNameMap (com.tntmodders.asm.TakumiASMNameMap)1 Field (java.lang.reflect.Field)1 Advancement (net.minecraft.advancements.Advancement)1 AdvancementProgress (net.minecraft.advancements.AdvancementProgress)1 ClientAdvancementManager (net.minecraft.client.multiplayer.ClientAdvancementManager)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1