Java 类net.minecraftforge.event.entity.player.AchievementEvent 实例源码

项目:DiscordCE    文件:MinecraftEventHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onAchievement(AchievementEvent e)
{
    if (!Config.achievementMessages
            || !(e.getEntityLiving() instanceof EntityPlayer)
            || e.getEntityLiving().getUniqueID() != Minecraft.getMinecraft().thePlayer.getUniqueID())
        return;

    // Getting discord and minecraft user
    EntityPlayer player = (EntityPlayer) e.getEntityLiving();
    User me = DiscordCE.client.getUserById(DiscordCE.client.getSelfInfo().getId());

    // Getting unlocked ac
    String aString = me.getAsMention() +
            " has just earned the achievement \"" +
            e.getAchievement().getStatName().getUnformattedComponentText() + ".\"";

    // Sending death message
    DiscordCE.client.getTextChannelById(Preferences.i.usingChannel).sendMessageAsync(aString, null);
}
项目:SlackMC    文件:ServerActivityListener.java   
@SubscribeEvent
public void onAchievement(AchievementEvent event)
{
    if (((EntityPlayerMP) event.getEntityPlayer()).getStatFile().hasAchievementUnlocked(event.getAchievement()))
    { // getStatFile
        // This is necessary because the Achievement event fires even if an achievement is already unlocked.
        return;
    }
    if (!((EntityPlayerMP) event.getEntityPlayer()).getStatFile().canUnlockAchievement(event.getAchievement()))
    { // getStatFile
        // This is necessary because the Achievement event fires even if an achievement can not be unlocked yet.
        return;
    }
    if (Slack.instance.senderConnected)
    {
        Slack.instance.getSlackSender().sendToSlack(SlackCommandSender.getInstance(), event.getEntityPlayer().getGameProfile().getName() + " has earned the achievement [" + event.getAchievement().getStatName().getUnformattedText() + "]");
    }
}
项目:Aether-Legacy    文件:PlayerAetherEvents.java   
@SubscribeEvent
public void onAchievementGet(AchievementEvent event)
{
    Achievement achievement = event.getAchievement();
    EntityPlayer player = event.getEntityPlayer();

    if (!(achievement instanceof AetherAchievement))
    {
        return;
    }

    int achievementType = achievement == AchievementsAether.defeat_bronze ? 1 : achievement == AchievementsAether.defeat_silver ? 2 : 0;

    if (!player.worldObj.isRemote && ((EntityPlayerMP)player).getStatFile().canUnlockAchievement(achievement) && !player.hasAchievement(achievement))
    {
        if (event.getAchievement() == AchievementsAether.enter_aether)
        {
            if (!player.inventory.addItemStackToInventory(new ItemStack(ItemsAether.lore_book)))
            {
                player.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, new ItemStack(ItemsAether.lore_book)));
            }

            if (!player.inventory.addItemStackToInventory(new ItemStack(ItemsAether.golden_parachute)))
            {
                player.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, new ItemStack(ItemsAether.golden_parachute)));
            }
        }

        AetherNetworkingManager.sendTo(new PacketAchievement(achievementType), (EntityPlayerMP) player);
    }
}
项目:LightningCraft    文件:AchievementEvents.java   
/** When stuff happens */
@SubscribeEvent
public void onGetAchievement(AchievementEvent e) {
    if(!e.getEntity().getEntityWorld().isRemote && e.getAchievement() == LCAchievements.infuseSkyfather) {
        e.getEntityPlayer().addChatMessage(new TextComponentString(LCText.getAngerGodsChatLore()));
    }
}
项目:EnderCore    文件:FireworkHandler.java   
@SubscribeEvent
public void onAchievement(AchievementEvent event) {
  StatisticsFile file = ((EntityPlayerMP) event.entityPlayer).func_147099_x();
  if (!event.entity.worldObj.isRemote && file.canUnlockAchievement(event.achievement) && !file.hasAchievementUnlocked(event.achievement)
      && ConfigHandler.betterAchievements) {
    event.entityPlayer.getEntityData().setInteger("fireworksLeft", 9);
    event.entityPlayer.getEntityData().setBoolean("fireworkDelay", false);
  }
}
项目:CustomThings    文件:AchievementHandler.java   
@SubscribeEvent
public void onAchievement(final AchievementEvent event)
{
    if (ignoreAchievement || event.entityPlayer.worldObj.isRemote || ((EntityPlayerMP)event.entityPlayer).func_147099_x().hasAchievementUnlocked(event.achievement))
    {
        return;
    }

    AchievementPage page = null;
    for (AchievementPage p : AchievementPage.getAchievementPages())
    {
        if (p.getAchievements().contains(event.achievement))
        {
            page = p;
        }
    }

    final AchievementPage pf = page;
    EnderCore.proxy.getScheduler().schedule(50, new Runnable()
    {
        @Override
        public void run()
        {
            ignoreAchievement = true;
            triggerAchievement(AchievementSource.ACHIEVEMENT_PAGE, event.entityPlayer, pf, event.entityPlayer, event.achievement);
            ignoreAchievement = false;
        }
    });
}
项目:TkIrc    文件:TkEvents.java   
@SubscribeEvent
public void onAchievement(AchievementEvent a){
    if(Config.Achievements){
    StatisticsFile player = ((EntityPlayerMP) a.entityPlayer).func_147099_x();
    if(a.achievement.isAchievement() && player.canUnlockAchievement(a.achievement) && !player.hasAchievementUnlocked(a.achievement)){
        TkIrc.toIrc.sendMessage(Config.cName,dePing(IRCBot.colorNick(a.entityPlayer.getCommandSenderName()))+" has just earned the achievement \""+a.achievement.func_150951_e().getUnformattedText()+"\"");
    }
    }
}
项目:Progression    文件:TriggerAchievement.java   
@SubscribeEvent
public void onAchievementGet(AchievementEvent event) {
    ProgressionAPI.registry.fireTrigger(event.getEntityPlayer(), getProvider().getUnlocalisedName(), event.getAchievement());
}