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

项目:harshencastle    文件:HandlerHarshenInventory.java   
@SubscribeEvent
public void onPlayerInteractXP(PlayerPickupXpEvent event)
{
        if (!EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, event.getEntityPlayer()).isEmpty())
         return;
        HarshenItemStackHandler handler = HarshenUtils.getHandler(event.getEntityPlayer());
        for(int o = 0; o < handler.getSlots(); o++)
            if(handler.getStackInSlot(o).isItemDamaged() && EnchantmentHelper.getEnchantmentLevel(Enchantments.MENDING, handler.getStackInSlot(o)) > 0)
            {
                int i = Math.min(event.getOrb().xpValue * 2, (handler.getStackInSlot(o).getItemDamage()));
               event.getOrb().xpValue -= i / 2;
               HarshenUtils.damageFirstOccuringItem(event.getEntityPlayer(), handler.getStackInSlot(o).getItem(), - i);
                break;
            }
}
项目:connor41-etfuturum2    文件:ModEnchantments.java   
public static void onPlayerPickupXP(PlayerPickupXpEvent event) {
    EntityPlayer player = event.entityPlayer;
    EntityXPOrb orb = event.orb;
    if (player.worldObj.isRemote)
        return;
    if (!EtFuturum.enableMending)
        return;

    ItemStack[] stacks = new ItemStack[5];
    stacks[0] = player.getCurrentEquippedItem(); // held
    stacks[1] = player.getEquipmentInSlot(1); // boots
    stacks[2] = player.getEquipmentInSlot(2); // leggings
    stacks[3] = player.getEquipmentInSlot(3); // chestplate
    stacks[4] = player.getEquipmentInSlot(4); // helmet

    for (ItemStack stack : stacks)
        if (stack != null && stack.getItemDamage() > 0 && EnchantmentHelper.getEnchantmentLevel(mending.effectId, stack) > 0) {
            int xp = orb.xpValue;
            while (xp > 0 && stack.getItemDamage() > 0) {
                stack.setItemDamage(stack.getItemDamage() - 2);
                xp--;
            }
            if (xp <= 0) {
                orb.setDead();
                event.setCanceled(true);
                return;
            }
        }
}
项目:Event-Tweaks    文件:EXPEventHandler.java   
@SubscribeEvent
public void healPlayerWithExp(PlayerPickupXpEvent e) {
    if(!e.getEntity().getEntityWorld().isRemote) {
        e.getOrb().xpValue *= 1.0;
        if (ConfigurationFile.xpOrbHealValue > 0.0f) {
            e.getEntityPlayer().heal(ConfigurationFile.xpOrbHealValue);
        }
    }
}
项目:Et-Futurum    文件:ModEnchantments.java   
public static void onPlayerPickupXP(PlayerPickupXpEvent event) {
    EntityPlayer player = event.entityPlayer;
    EntityXPOrb orb = event.orb;
    if (player.worldObj.isRemote)
        return;
    if (!EtFuturum.enableMending)
        return;

    ItemStack[] stacks = new ItemStack[5];
    stacks[0] = player.getCurrentEquippedItem(); // held
    stacks[1] = player.getEquipmentInSlot(1); // boots
    stacks[2] = player.getEquipmentInSlot(2); // leggings
    stacks[3] = player.getEquipmentInSlot(3); // chestplate
    stacks[4] = player.getEquipmentInSlot(4); // helmet

    for (ItemStack stack : stacks)
        if (stack != null && stack.getItemDamage() > 0 && EnchantmentHelper.getEnchantmentLevel(mending.effectId, stack) > 0) {
            int xp = orb.xpValue;
            while (xp > 0 && stack.getItemDamage() > 0) {
                stack.setItemDamage(stack.getItemDamage() - 2);
                xp--;
            }
            if (xp <= 0) {
                orb.setDead();
                event.setCanceled(true);
                return;
            }
        }
}
项目:Cauldron    文件:EntityXPOrb.java   
public void onCollideWithPlayer(EntityPlayer p_70100_1_)
{
    if (!this.worldObj.isRemote)
    {
        if (this.field_70532_c == 0 && p_70100_1_.xpCooldown == 0)
        {
            if (MinecraftForge.EVENT_BUS.post(new PlayerPickupXpEvent(p_70100_1_, this))) return;
            p_70100_1_.xpCooldown = 2;
            this.worldObj.playSoundAtEntity(p_70100_1_, "random.orb", 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F));
            p_70100_1_.onItemPickup(this, 1);
            p_70100_1_.addExperience(CraftEventFactory.callPlayerExpChangeEvent(p_70100_1_, this.xpValue).getAmount());
            this.setDead();
        }
    }
}
项目:Cauldron    文件:EntityXPOrb.java   
public void onCollideWithPlayer(EntityPlayer p_70100_1_)
{
    if (!this.worldObj.isRemote)
    {
        if (this.field_70532_c == 0 && p_70100_1_.xpCooldown == 0)
        {
            if (MinecraftForge.EVENT_BUS.post(new PlayerPickupXpEvent(p_70100_1_, this))) return;
            p_70100_1_.xpCooldown = 2;
            this.worldObj.playSoundAtEntity(p_70100_1_, "random.orb", 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F));
            p_70100_1_.onItemPickup(this, 1);
            p_70100_1_.addExperience(this.xpValue);
            this.setDead();
        }
    }
}
项目:GriefGuardian    文件:ClaimGuardEventHandler.java   
@SubscribeEvent
public void onPlayerAttemptXPPickup(PlayerPickupXpEvent event){
    if (event.entityPlayer.worldObj.isRemote)
        return;

    if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.PICKUP_XP, event.orb.posX, event.orb.posY, event.orb.posZ))
        event.setCanceled(true);
}
项目:connor41-etfuturum2    文件:ServerEventHandler.java   
@SubscribeEvent
public void onPlayerPickXP(PlayerPickupXpEvent event) {
    ModEnchantments.onPlayerPickupXP(event);
}
项目:MagicWinds    文件:EventHandlerCommon.java   
@SubscribeEvent
public void onPlayerPickupEvent(PlayerPickupXpEvent event){
    //TODO Xpbonus achievement
}
项目:Alchemy    文件:PotionMultipleXP.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void onPlayerPickupXP(PlayerPickupXpEvent event) {
    PotionEffect effect = event.getEntityPlayer().getActivePotionEffect(AlchemyPotionLoader.multiple_xp);
    if (effect != null)
        event.getOrb().xpValue *= effect.getAmplifier() + 1;
}
项目:Et-Futurum    文件:ServerEventHandler.java   
@SubscribeEvent
public void onPlayerPickXP(PlayerPickupXpEvent event) {
    ModEnchantments.onPlayerPickupXP(event);
}