@SubscribeEvent public void onItemPickUp(EntityItemPickupEvent e) { EntityPlayer player = e.getEntityPlayer(); ItemStack entityStack = e.getItem().getItem(); if ((entityStack.isEmpty()) || (player == null)) { return; } ItemStack dankNull = DankNullUtils.getDankNullForStack(player, entityStack); if (!dankNull.isEmpty()) { InventoryDankNull inventory = DankNullUtils.getInventoryFromStack(dankNull); if (inventory != null && (DankNullUtils.addFilteredStackToDankNull(inventory, entityStack))) { entityStack.setCount(0); return; } } }
public void onPlayerPickup(EntityItemPickupEvent e, ItemStack stack) { applyNetwork(stack, n -> { if (RSAddons.INSTANCE.config.networkBagUsesEnergy && stack.getItemDamage() != ItemNetworkBag.TYPE_CREATIVE && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() <= RSAddons.INSTANCE.config.networkBagUsage) { return; } if (!n.getSecurityManager().hasPermission(Permission.INSERT, e.getEntityPlayer())) { return; } if (n.insertItem(e.getItem().getItem(), e.getItem().getItem().getCount(), true) == null) { e.setResult(Event.Result.ALLOW); e.setCanceled(true); n.insertItem(e.getItem().getItem(), e.getItem().getItem().getCount(), false); e.getItem().setDead(); if (RSAddons.INSTANCE.config.networkBagUsesEnergy && stack.getItemDamage() != ItemNetworkBag.TYPE_CREATIVE) { stack.getCapability(CapabilityEnergy.ENERGY, null).extractEnergy(RSAddons.INSTANCE.config.networkBagUsage, false); } } }, error -> { // NO OP }); }
@Override public void onCollideWithPlayer(EntityPlayer player) { if (!this.worldObj.isRemote) { NBTTagCompound nbt = new NBTTagCompound(); this.writeToNBT(nbt); boolean inground = nbt.hasKey("inGround") && nbt.getByte("inGround") == 1; if(inground) { boolean flag = this.canBePickedUp == 1 || (this.canBePickedUp == 2 && player.capabilities.isCreativeMode); EntityItem ei = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(this.pickupItem, 1, 0)); if (this.canBePickedUp == 1) { EntityItemPickupEvent event = new EntityItemPickupEvent(player, ei); if (MinecraftForge.EVENT_BUS.post(event)) return; } ItemStack itemstack = ei.getEntityItem(); if (itemstack.stackSize <= 0) flag = true; else if (this.canBePickedUp == 1 && !player.inventory.addItemStackToInventory(itemstack)) flag = false; if (flag) { this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); player.onItemPickup(this, 1); this.setDead(); } } } }
@SubscribeEvent public void onItemPickup(EntityItemPickupEvent event){ EntityPlayer player = event.getEntityPlayer(); if(player==null)return; ItemStack insc = DustRegistry.getWornInscription(player); if(!insc.isEmpty() && DustRegistry.getInscriptionFromStack(insc)==this){ int damage = insc.getItemDamage(); int damageLeft = getMaxDurability()-damage; if(damageLeft>0){ IVoidStorageCapability store = player.getCapability(VoidStorageCapability.VOID_STORAGE_CAPABILITY, null); if(store!=null){ ItemStack stack = event.getItem().getItem(); ItemStack split = stack.splitStack(damageLeft); store.addStackToVoid(split); if(!player.capabilities.isCreativeMode)insc.setItemDamage(damage+split.getCount()); } } } }
@SubscribeEvent public void itemPickup(EntityItemPickupEvent event){ EntityItem ent = event.getItem(); if(ent == null)return; if(!ItemStackTools.isValid(ent.getEntityItem()))return; EntityPlayer player = event.getEntityPlayer(); if(player !=null && player.isEntityAlive()){ ItemStack backpack = BackpackUtil.getBackpackOnBack(player); if(ItemStackTools.isValid(backpack)){ IBackpack backpackType = BackpackUtil.getType(backpack); if(backpackType !=null && backpackType.handleItemPickup(event, player, backpack)){ event.setCanceled(true); } } } }
@SubscribeEvent public void onItemPickup(EntityItemPickupEvent event) { ItemStack stack = event.getItem().getItem(); for (int i = 0; i < event.getEntityPlayer().inventory.getSizeInventory(); i++) { if (stack.isEmpty() || stack.getCount() == 0) { break; } ItemStack stackInv = event.getEntityPlayer().inventory.getStackInSlot(i); if (!stackInv.isEmpty() && stackInv.getItem() == ModItems.overflowNullifier) { OverflowInventory inv = new OverflowInventory(stackInv); stack = fillOverflowInventory(inv, stack); inv.markDirty(); } } }
@SubscribeEvent public void onItemPickup(EntityItemPickupEvent event, Item item, Block block) { event.setResult(ALLOW); if (block == BlockLoader.blockFlowerForJen) { player.triggerAchievement(Achievements.achievementflowerforjen); } if (item == ItemLoader.itemPatStar) { player.triggerAchievement(Achievements.achievementPatStar); } if (item == ItemLoader.itemJenStar) { player.triggerAchievement(Achievements.achievementJenStar); } }
@SubscribeEvent public static void getXP(EntityItemPickupEvent event) { EntityPlayer player = event.getEntityPlayer(); DriveStateCapability.IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null); if(DRIVE.getActiveDriveName().equals(Strings.Form_Master)) { if(event.getItem().getItem().getItem() == ModItems.DriveOrb) { int amount = (event.getItem().getItem().getTagCompound().getInteger("amount")/5) > 0 ? event.getItem().getItem().getTagCompound().getInteger("amount")/5 : 1; DRIVE.setDriveExp(DRIVE.getActiveDriveName(), DRIVE.getDriveExp(DRIVE.getActiveDriveName())+amount); System.out.println(DRIVE.getDriveExp(DRIVE.getActiveDriveName())+(event.getItem().getItem().getTagCompound().getInteger("amount")/5)); int[] costs = DriveFormRegistry.get(DRIVE.getActiveDriveName()).getExpCosts(); int actualLevel = DRIVE.getDriveLevel(DRIVE.getActiveDriveName()); int actualExp = DRIVE.getDriveExp(DRIVE.getActiveDriveName()); if(costs.length == 7 && actualLevel < 7) { if (actualExp >= costs[actualLevel]){ System.out.println("LEVEL UP"); DRIVE.setDriveLevel(DRIVE.getActiveDriveName(),actualLevel+1); DRIVE.displayLevelUpMessage(player, DRIVE.getActiveDriveName()); } } PacketDispatcher.sendTo(new SyncDriveData(DRIVE), (EntityPlayerMP) player); } } }
@SubscribeEvent public void onPickUp(EntityItemPickupEvent event){ for (int i =0; i!=event.entityPlayer.inventory.getSizeInventory(); i ++){ ItemStack swapper = event.entityPlayer.inventory.getStackInSlot(i); if (swapper != null && swapper.getItem() == this){ ItemInventory inv = new ItemInventory(swapper, swapperSlots); ItemStack swapperStack = inv.getStackInSlot(slotRightClick); if (swapperStack != null){ if (swapperStack.isItemEqual(event.item.getEntityItem()) && ItemStack.areItemStackTagsEqual(swapperStack, event.item.getEntityItem())){ if (swapperStack.stackSize + event.item.getEntityItem().stackSize <= swapperStack.getMaxStackSize()){ swapperStack.stackSize += event.item.getEntityItem().stackSize; event.item.getEntityItem().stackSize = 0; } else { int qtyToMove = swapperStack.getMaxStackSize() - swapperStack.stackSize; swapperStack.stackSize += qtyToMove; event.item.getEntityItem().stackSize -= qtyToMove; } inv.setInventorySlotContents(slotRightClick, swapperStack); } } } } }
@SubscribeEvent public void onPickup(EntityItemPickupEvent event){ ItemStack item = event.item.getEntityItem(); if(item == null) return; if(isSoulbound(item)){ String fidelis = getFidelisID(item); String id = getID(event.entityPlayer); if(!fidelis.equals("") && !fidelis.equals(id)) { event.setCanceled(true); if(event.entityPlayer.ticksExisted % 40 == 0) event.entityPlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_RED + "This item is not yours. it belongs to " + getOwner(item))); return; } } }
@SubscribeEvent public void onRingPickUp(EntityItemPickupEvent event) { if (!Loader.isModLoaded("Baubles")) { ItemStack item = event.item.getEntityItem(); if (item != null && item.getItem() instanceof ItemMagicRing) { NBTTagCompound tag = SimpleUtil.getRingTag(item); if (tag != null) { ISpell spell = SimpleUtil.getSpell(tag); if (spell != null) { IPlayerSession session = Rings.proxy.manaHandler.getPlayerSession(event.entityPlayer); SpellCastedEvent spellEvent = new SpellCastedEvent(event.entityPlayer, spell, session); if (MinecraftForge.EVENT_BUS.post(spellEvent)) return; spell.onEquipped(item, event.entityPlayer, session); if (FMLCommonHandler.instance().getEffectiveSide().isServer() && !event.entityPlayer.capabilities.isCreativeMode) Rings.proxy.manaHandler.updatePlayerSession(session, event.entityPlayer.getEntityWorld().provider.dimensionId); } } } } }
@SubscribeEvent public void onEntityItemPickupEvent(EntityItemPickupEvent event) { if (ItemPickupManager.onEntityItemPickupEvent(event)) { return; } if (ItemHandyBag.onEntityItemPickupEvent(event)) { return; } if (ItemNullifier.onEntityItemPickupEvent(event)) { return; } }
@SubscribeEvent public void onPickup(EntityItemPickupEvent event) { EntityPlayer player = event.entityPlayer; ItemStack item = event.item.getEntityItem(); for (int i = 0; i < 9; i++) { ItemStack stack = player.inventory.getStackInSlot(i); if ((stack != null) && (stack.getItem() instanceof ItemPouch)) { InventoryPouch inv = InventoryPouch.getOrCreate(player, i); ItemStack type = inv.getItem(); Entry entry = PouchAPI.getEntry(type); if ((entry == null) || !entry.matches(item)) continue; ItemStack result = InventoryUtils.insertStack(inv, item, false); if (result != null) item.stackSize = result.stackSize; else { item.stackSize = 0; return; } } } }
@SubscribeEvent public void onItemPickup(EntityItemPickupEvent event) { ItemStack stack = event.item.getEntityItem(); EntityPlayer player = event.entityPlayer; if (stack != null && stack.getItem() instanceof IHandlePickup) { int size = stack.stackSize; if (((IHandlePickup) stack.getItem()).onPickupItem(stack, player)) { if (stack.stackSize < size) { FMLCommonHandler.instance().firePlayerItemPickupEvent(player, event.item); event.item.playSound(Sounds.POP, 0.2F, ((event.item.worldObj.rand.nextFloat() - event.item.worldObj.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); player.onItemPickup(event.item, size - stack.stackSize); } if (stack.stackSize <= 0) { event.item.setDead(); event.setCanceled(true); } } else { event.setCanceled(true); } } }
@SubscribeEvent public void onItemPickupAttempt(EntityItemPickupEvent event){ if (event.entityPlayer.worldObj.isRemote) return; if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.PICKUP_ITEMS, event.item.posX, event.item.posY, event.item.posZ)) event.setCanceled(true); else GriefGuardian._dal.logAction( (EntityPlayerMP)event.entityPlayer, Actions.ITEM_PICKUP, (int)Math.floor(event.entity.posX), (int)Math.floor(event.entity.posY), (int)Math.floor(event.entity.posZ), event.item.getEntityItem(), ""); }
/** * Returns whether an in-progress EntityAIBase should continue executing */ @Override public boolean continueExecuting(){ if(curPickingUpEntity.isDead) return false; if(Vec3.createVectorHelper(curPickingUpEntity.posX, curPickingUpEntity.posY, curPickingUpEntity.posZ).distanceTo(drone.getPosition()) < 1.5) { ItemStack stack = curPickingUpEntity.getEntityItem(); if(itemPickupWidget.isItemValidForFilters(stack)) { new EventHandlerPneumaticCraft().onPlayerPickup(new EntityItemPickupEvent(drone.getFakePlayer(), curPickingUpEntity));//not posting the event globally, as I don't have a way of handling a canceled event. int stackSize = stack.stackSize; ItemStack remainder = PneumaticCraftUtils.exportStackToInventory(drone.getInventory(), stack, ForgeDirection.UP);//side doesn't matter, drones aren't ISided. if(remainder == null) { drone.onItemPickupEvent(curPickingUpEntity, stackSize); curPickingUpEntity.setDead(); } } return false; } return !drone.getPathNavigator().hasNoPath(); }
@Override public int emitRedstoneOnEvent(PlayerEvent event, TileEntity sensor, int range) { if (event instanceof EntityItemPickupEvent) { return 15; } return 0; }
@SubscribeEvent public static void onPickup(EntityItemPickupEvent e) { if (e.getEntityPlayer() instanceof EntityPlayerMP) { EntityPlayerMP p = (EntityPlayerMP) e.getEntityPlayer(); for (Pair<IfEntry, IRSCollect> pair : PurMag.INSTANCE.getIfRegistry().getAllResearchableSteps(IRSCollect.class, p)) { if (pair.getRight().getIngredient().apply(e.getItem().getItem())) { p.getCapability(CapabilityRegistry.ENTRY_STORE_CAP, null).unlockStepAndSync(pair.getLeft().getId(), p); } } } }
@SubscribeEvent public static void itemPickup(EntityItemPickupEvent event) { if(!(event.getEntity() instanceof EntityPlayer) || event.getItem().getItem().isEmpty()) return; if(event.getItem().getItem().getItem() instanceof ItemAnimaShield) { ItemAnimaShield i = (ItemAnimaShield) event.getItem().getItem().getItem(); i.setOff(event.getItem().getItem(), event.getEntityPlayer()); } }
@SubscribeEvent public void onPickupItem(EntityItemPickupEvent event) { if (event.item != null && event.item.getEntityItem() != null) { ItemStack stack = event.item.getEntityItem(); checkForMatch(stack); } }
@SubscribeEvent public void onPickupItem(EntityItemPickupEvent event) { if (event.item != null && event.entityPlayer instanceof EntityPlayerMP ) { // This event is received on the server side, so we need to pass it to the client. sendItemStackToClient((EntityPlayerMP)event.entityPlayer, MalmoMessageType.SERVER_COLLECTITEM, event.item.getEntityItem()); } }
@SubscribeEvent public void onPickupItem(EntityItemPickupEvent e) { if (!e.getEntityPlayer().world.isRemote) { for (int i = 0; i < 9 * 4; ++i) { ItemStack stack = e.getEntityPlayer().inventory.getStackInSlot(i); if (stack.getItem() == RSAddonsItems.NETWORK_BAG) { ((ItemNetworkBag) stack.getItem()).onPlayerPickup(e, stack); break; } } } }
@SubscribeEvent public void unstableIngotDestroyer(final EntityItemPickupEvent event) { if (ExtraUtils.unstableIngot != null && event.item.getEntityItem().getItem() == ExtraUtils.unstableIngot && event.item.getEntityItem().hasTagCompound() && (event.item.getEntityItem().getTagCompound().hasKey("crafting") || event.item.getEntityItem().getTagCompound().hasKey("time"))) { event.item.setDead(); event.setCanceled(true); } }
@SubscribeEvent public void onItemDetect( EntityItemPickupEvent event ){ for( Achievement a : Achievements.detectAchievements ){ if( Achievements.achievementsIgnoreMeta.get( a.hashCode() ) ){ if( event.getItem().getEntityItem().getItem() == a.theItemStack.getItem() ){ Achievements.trigger( a, event.getEntityPlayer() ); } } else{ if( ItemStack.areItemsEqual( event.getItem().getEntityItem(), a.theItemStack ) ){ Achievements.trigger( a, event.getEntityPlayer() ); } } } }
@SubscribeEvent public void onItemPickedUp(EntityItemPickupEvent event) { if (event.getItem().getEntityItem() != null && event.getItem().getEntityItem().getItem() == Item.getItemFromBlock(BlocksAether.aether_log)) { event.getEntityPlayer().addStat(AchievementList.MINE_WOOD); } }
@SubscribeEvent public void onPickupItem(EntityItemPickupEvent event) { if (event.getItem() != null && event.getItem().getEntityItem() != null) { ItemStack stack = event.getItem().getEntityItem(); checkForMatch(stack); } }
@SubscribeEvent public void onPickupItem(EntityItemPickupEvent event) { if (event.getItem() != null && event.getEntityPlayer() instanceof EntityPlayerMP ) { // This event is received on the server side, so we need to pass it to the client. sendItemStackToClient((EntityPlayerMP)event.getEntityPlayer(), MalmoMessageType.SERVER_COLLECTITEM, event.getItem().getEntityItem()); } }
@SubscribeEvent public void onItemPickedUp (EntityItemPickupEvent event) { // Null Charm final List<ItemStack> charms = itemNullCharm.getItem(event.getEntityPlayer()); for (final ItemStack charm : charms) { if (ItemNullCharm.isBlackListed(event.getItem().getItem(), charm)) { event.getItem().setDead(); event.setCanceled(true); return; } } }
@SubscribeEvent public static void pickupSeeds(EntityItemPickupEvent event) { boolean handled = false; EntityItem entityItem = event.getItem(); if (entityItem != null) { ItemStack leftover = entityItem.getItem(); InventoryPlayer playerInv = event.getEntityPlayer().inventory; for (int i = 0; i < playerInv.getSizeInventory(); i++) { ItemStack playerSlotStack = playerInv.getStackInSlot(i); if (playerSlotStack.getItem() instanceof ItemSeedBag) { SeedBagInventory seedBagInventory = new SeedBagInventory(playerSlotStack); ItemStack original = leftover.copy(); leftover = InventoryHandlerHelper.insertStackIntoInventory(seedBagInventory, leftover, EnumFacing.DOWN, true); if (!leftover.isEmpty()) { if (leftover.getCount() <= 0) { finishSeeds(event, entityItem, event.getEntityPlayer(), leftover); } } else { finishSeeds(event, entityItem, event.getEntityPlayer(), leftover); return; } if (!handled) { handled = original.getCount() != leftover.getCount(); } } } if (handled) { finishSeeds(event, entityItem, event.getEntityPlayer(), leftover); } } }
private static void finishSeeds(EntityItemPickupEvent event, EntityItem entity, EntityPlayer player, @Nonnull ItemStack leftover) { entity.setDead(); event.setCanceled(true); player.world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((player.world.rand.nextFloat() - player.world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); if (!leftover.isEmpty()) { ItemHandlerHelper.giveItemToPlayer(player, leftover); } }
@Override public void onEvent(EntityItemPickupEvent event) { if (event.getEntityPlayer() instanceof EntityPlayerMP) { if (getPlayerSettings((EntityPlayerMP) event.getEntityPlayer()).disablePickups.contains(event.getItem().getItem().getItem())) event.setCanceled(true); } }
public void addSynthesisMaterialToBag(IItemHandler inv, EntityItemPickupEvent event) { for (int j = 0; j < inv.getSlots(); j++) { ItemStack bagItem = inv.getStackInSlot(j); ItemStack pickUp = event.getItem().getItem(); if (!ItemStack.areItemStacksEqual(bagItem, ItemStack.EMPTY)) { if (bagItem.getItem().equals(pickUp.getItem())) { if (bagItem.hasTagCompound() && pickUp.hasTagCompound()) { if (bagItem.getTagCompound().hasKey("material") && pickUp.getTagCompound().hasKey("material")) { if (bagItem.getTagCompound().getString("material").equals(pickUp.getTagCompound().getString("material"))) { if (bagItem.getCount() < 64) { if (bagItem.getCount() + pickUp.getCount() <= 64) { ItemStack stack = new ItemStack(pickUp.copy().getItem(), pickUp.copy().getCount()); stack.setTagCompound(new NBTTagCompound()); stack.getTagCompound().setString("material", bagItem.getTagCompound().getString("material")); stack.getTagCompound().setString("rank", bagItem.getTagCompound().getString("rank")); inv.insertItem(j, stack, false); pickUp.setCount(0); return; } } } } } } } else if (ItemStack.areItemStacksEqual(bagItem, ItemStack.EMPTY)) { inv.insertItem(j, pickUp.copy(), false); pickUp.setCount(0); return; } } }
@SubscribeEvent public void pickUpItem(EntityItemPickupEvent event) { if (!event.item.worldObj.isRemote && event.entityPlayer != null) { ItemStack stack = event.item.getEntityItem(); EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer; unlockAchievement(player, stack); } }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void entityItemPickupEvent(EntityItemPickupEvent event) { EntityPlayer player = event.getEntityPlayer(); if (!Helper.shouldCare(player)) return; event.getItem().setItem(GlobalBanList.process(player.dimension, event.getItem().getItem())); }
@SubscribeEvent public void onEntityPickup(EntityItemPickupEvent event) { if (event.entity instanceof EntityPlayer) { ImperiumPlayer playerImperium = ImperiumPlayer.get((EntityPlayer) event.entity); if (event.item.getEntityItem().getItem() == ModItems.brushwood) { if (!playerImperium.eventListDone.toString().contains("BRUSHWOOD")) { playerImperium.addInstantEvent(TutorialEvents.BRUSHWOOD); playerImperium.syncToServer("events"); } } } }
@SubscribeEvent public void onPickupDust(EntityItemPickupEvent event){ ItemStack dust = event.getItem().getItem(); //RunesOfWizardry.log().info(dust); if(dust.getItem() instanceof IDust && dust.getCount()>0){ EntityPlayer player = event.getEntityPlayer(); //Couldn't get a zombie to pick up dust, but adding the check doen't hurt if(player==null)return; InventoryPlayer inv = player.inventory; for(int i=0;i<inv.getSizeInventory();i++){ //if(i==inv.currentItem)continue;//supposedly avoids deleting items ItemStack stack = inv.getStackInSlot(i); if(!stack.isEmpty() && stack.getItem() instanceof ItemDustPouch){ ItemDustPouch pouch = (ItemDustPouch)stack.getItem(); ItemStack contents = pouch.getDustStack(stack, 0);//get the dust type if(ItemStack.areItemsEqual(dust, contents)&&ItemStack.areItemStackTagsEqual(dust, contents)){ boolean ok = pouch.addDust(stack, dust); event.setResult(Result.ALLOW); if(ok){ dust.setCount(0); return; } } } } } }