@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; } }
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; } } }
@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); } } }
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(); } } }
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(); } } }
@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); }
@SubscribeEvent public void onPlayerPickXP(PlayerPickupXpEvent event) { ModEnchantments.onPlayerPickupXP(event); }
@SubscribeEvent public void onPlayerPickupEvent(PlayerPickupXpEvent event){ //TODO Xpbonus achievement }
@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; }