use of net.minecraft.advancements.AdvancementManager in project BuildCraft by BuildCraft.
the class AdvancementUtil method unlockAdvancement.
public static void unlockAdvancement(EntityPlayer player, ResourceLocation advancementName) {
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
AdvancementManager advancementManager = playerMP.getServerWorld().getAdvancementManager();
if (advancementManager == null) {
// Because this *can* happen
return;
}
Advancement advancement = advancementManager.getAdvancement(advancementName);
if (advancement != null) {
// never assume the advancement exists, we create them but they are removable by datapacks
playerMP.getAdvancements().grantCriterion(advancement, "code_trigger");
} else if (UNKNOWN_ADVANCEMENTS.add(advancementName)) {
BCLog.logger.warn("[lib.advancement] Attempted to trigger undefined advancement: " + advancementName);
}
}
}
use of net.minecraft.advancements.AdvancementManager in project ImmersiveEngineering by BluSunrize.
the class Utils method unlockIEAdvancement.
public static void unlockIEAdvancement(EntityPlayer player, String name) {
if (player instanceof EntityPlayerMP) {
PlayerAdvancements advancements = ((EntityPlayerMP) player).getAdvancements();
AdvancementManager manager = ((WorldServer) player.getEntityWorld()).getAdvancementManager();
Advancement advancement = manager.getAdvancement(new ResourceLocation(ImmersiveEngineering.MODID, name));
if (advancement != null)
advancements.grantCriterion(advancement, "code_trigger");
}
}
Aggregations