当前位置: 首页>>代码示例>>Java>>正文


Java EntityItemPickupEvent.getEntityPlayer方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.player.EntityItemPickupEvent.getEntityPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java EntityItemPickupEvent.getEntityPlayer方法的具体用法?Java EntityItemPickupEvent.getEntityPlayer怎么用?Java EntityItemPickupEvent.getEntityPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.player.EntityItemPickupEvent的用法示例。


在下文中一共展示了EntityItemPickupEvent.getEntityPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onItemPickUp

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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;
		}
	}
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:17,代码来源:ModEvents.java

示例2: onItemPickup

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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());
			}
		}
	}
}
 
开发者ID:Xilef11,项目名称:runesofwizardry-classics,代码行数:20,代码来源:InscriptionVoid.java

示例3: itemPickup

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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);
   			}
   		}
   	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:17,代码来源:EventHandler.java

示例4: getXP

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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);
       	}
       }
}
 
开发者ID:Wehavecookies56,项目名称:Kingdom-Keys-Re-Coded,代码行数:27,代码来源:DriveFormMaster.java

示例5: onPickup

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:16,代码来源:IfEvents.java

示例6: onPickupItem

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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;
            }
        }
    }
}
 
开发者ID:raoulvdberge,项目名称:refinedstorageaddons,代码行数:15,代码来源:ProxyCommon.java

示例7: onPickupItem

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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());
    }
}
 
开发者ID:Microsoft,项目名称:malmo,代码行数:10,代码来源:RewardForCollectingItemImplementation.java

示例8: pickupSeeds

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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);
        }
    }
}
 
开发者ID:GirafiStudios,项目名称:Culinary-Cultivation,代码行数:33,代码来源:ItemSeedBag.java

示例9: onEvent

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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);
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:8,代码来源:CommandPickup.java

示例10: entityItemPickupEvent

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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()));
}
 
开发者ID:DoubleDoorDevelopment,项目名称:ItemBlacklist,代码行数:8,代码来源:ServerEventHandlers.java

示例11: onPickupDust

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@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;
					}
				}
			}
		}
	}
}
 
开发者ID:Xilef11,项目名称:Runes-of-Wizardry,代码行数:28,代码来源:PickupEventHandler.java

示例12: onTryPickupItem

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onTryPickupItem(EntityItemPickupEvent event)
{
       if (!SettingsFlags.instance.enableCustomInventory)
       {
           return;
       }

	if (event.getItem() != null && !event.getItem().getItem().isEmpty() && !event.getItem().isDead && !event.getEntityPlayer().world.isRemote)
	{
		int i = PlayerInventoryHelper.findFirstAvailableSlotFor(event.getItem().getItem(), Optional.empty(), event.getEntityPlayer());
		if (i == -1)
		{
			event.setCanceled(true);
		}
		else
		{
			if (i < Short.MAX_VALUE)
			{
				event.getEntityPlayer().inventory.setInventorySlotContents(i, event.getItem().getItem().copy());
				net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerItemPickupEvent(event.getEntityPlayer(), event.getItem());
				event.getEntityPlayer().onItemPickup(event.getItem(), event.getItem().getItem().getCount());
				event.getEntityPlayer().addStat(StatList.getObjectsPickedUpStats(event.getItem().getItem().getItem()), event.getItem().getItem().getCount());
				event.getItem().setDead();
				event.setCanceled(true);
			}
			else
			{
				int slotID = i - Short.MAX_VALUE;
				ItemStack toIncrement = event.getEntityPlayer().inventory.getStackInSlot(slotID);
				Optional<Slot> s = Optional.ofNullable(event.getEntityPlayer().openContainer != null ? event.getEntityPlayer().openContainer.getSlot(slotID) : null);
				int max = Math.min(toIncrement.getMaxStackSize(), s.map(slot -> slot.getItemStackLimit(toIncrement)).orElseGet(() -> event.getEntityPlayer().inventory.getInventoryStackLimit()));
				int current = toIncrement.getCount();
				final int added = Math.min(event.getItem().getItem().getCount(), max - current);
				net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerItemPickupEvent(event.getEntityPlayer(), event.getItem());
				event.getEntityPlayer().addStat(StatList.getObjectsPickedUpStats(event.getItem().getItem().getItem()), added);
				event.getItem().getItem().shrink(added);
				toIncrement.grow(added);
				event.getEntityPlayer().world.playSound(null, event.getEntityPlayer().getPosition(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, (event.getEntityPlayer().world.rand.nextFloat() - event.getEntityPlayer().world.rand.nextFloat()) * 1.4F + 2.0F);
				if (toIncrement.isEmpty())
				{
					event.getItem().setDead();
				}
				
				event.setCanceled(true);
			}
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:50,代码来源:ExPHandlerServer.java

示例13: onItemPickup

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemPickup(EntityItemPickupEvent event)
{
	if (!event.getEntityPlayer().world.isRemote)
	{
		ItemStack pickedUp = event.getItem().getEntityItem();
		if (pickedUp != null)
		{
			Item in = pickedUp.getItem();
			if (in instanceof IDecayable)
			{
				EntityPlayer p = event.getEntityPlayer();
				for (int i = 0; i < p.inventory.getSizeInventory(); i++)
				{
					ItemStack inInv = p.inventory.getStackInSlot(i);
					if (inInv != null && inInv.getItem() == in)
					{
						long inDecayStart = IDecayable.getDecayStart(inInv);
						long pickDecayStart = IDecayable.getDecayStart(pickedUp);
						int inSize = inInv.stackSize;
						int pickSize = pickedUp.stackSize;
						int maxSize = inInv.getMaxStackSize();

						if (inSize == maxSize) continue;

						int diff = pickSize - (maxSize - inSize);
						if (diff > 0) pickSize = maxSize - inSize;

						long avg = (inDecayStart * inSize + pickDecayStart * pickSize) / (inSize + pickSize);

						pickedUp.stackSize -= pickSize;
						inInv.stackSize += pickSize;
						IDecayable.setDecayStart(inInv, avg);
						event.getEntityPlayer().world.playSound(null, event.getEntityPlayer().posX, event.getEntityPlayer().posY, event.getEntityPlayer().posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((event.getEntityPlayer().getRNG().nextFloat() - event.getEntityPlayer().getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F);

						break;
					}
				}
			}
		}
	}
}
 
开发者ID:BubbleTrouble14,项目名称:ARKCraft,代码行数:43,代码来源:CommonEventHandler.java

示例14: onItemPickup

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemPickup(EntityItemPickupEvent event) {
	if (event.getItem().getItem().getItem() == UniversalCoins.Items.iron_coin
			|| event.getItem().getItem().getItem() == UniversalCoins.Items.gold_coin
			|| event.getItem().getItem().getItem() == UniversalCoins.Items.emerald_coin
			|| event.getItem().getItem().getItem() == UniversalCoins.Items.diamond_coin
			|| event.getItem().getItem().getItem() == UniversalCoins.Items.obsidian_coin) {
		// event.getEntityPlayer().addStat(Achievements.achCoin, 1);
		world = event.getEntityPlayer().world;
		EntityPlayer player = event.getEntityPlayer();
		NonNullList<ItemStack> inventory = player.inventory.mainInventory;
		DecimalFormat formatter = new DecimalFormat("#,###,###,###");
		for (int i = 0; i < inventory.size(); i++) {
			if (inventory.get(i) != null && inventory.get(i).getItem() == UniversalCoins.Items.ender_card) {
				if (!inventory.get(i).hasTagCompound())
					return; // card has not been initialized. Nothing we can
							// do here
				accountNumber = inventory.get(i).getTagCompound().getString("Account");
				FMLLog.info("Account: " + accountNumber);
				long accountBalance = UniversalAccounts.getInstance().getAccountBalance(accountNumber);
				if (accountBalance == -1)
					return; // get out of here if the card is invalid
				if (event.getItem().getItem().getCount() == 0)
					return; // no need to notify on zero size stack
				int coinValue = 0;
				int depositAmount = 0;
				int stackSize = event.getItem().getItem().getCount();
				switch (event.getItem().getItem().getUnlocalizedName()) {
				case "item.universalcoins.iron_coin":
					coinValue = UniversalCoins.coinValues[0];
					break;
				case "item.universalcoins.gold_coin":
					coinValue = UniversalCoins.coinValues[1];
					break;
				case "item.universalcoins.emerald_coin":
					coinValue = UniversalCoins.coinValues[2];
					break;
				case "item.universalcoins.diamond_coin":
					coinValue = UniversalCoins.coinValues[3];
					break;
				case "item.universalcoins.obsidian_coin":
					coinValue = UniversalCoins.coinValues[4];
					break;
				}
				if (UniversalAccounts.getInstance().creditAccount(accountNumber, coinValue * stackSize, true)) {
					UniversalAccounts.getInstance().creditAccount(accountNumber, coinValue * stackSize, false);
					event.getItem().getItem().setCount(0);
					player.sendMessage(new TextComponentString(I18n.translateToLocal("item.card.deposit") + " "
							+ formatter.format(stackSize * coinValue) + " "
							+ I18n.translateToLocal("general.currency.single")));
					break; // no need to continue. We are done here
				}
			}
		}
	}
}
 
开发者ID:notabadminer,项目名称:UniversalCoins,代码行数:57,代码来源:UCPlayerPickupEventHandler.java

示例15: onEntityItemPickupEvent

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入方法依赖的package包/类
/**
 * Tries to first fill the matching stacks in the player's inventory,
 * and then depending on the bag's mode, tries to add the remaining items
 * to the bag's inventory.
 * @param event
 * @return true if all items were handled and further processing of the event should not occur
 */
public static boolean onEntityItemPickupEvent(EntityItemPickupEvent event)
{
    EntityItem entityItem = event.getItem();
    ItemStack stack = entityItem.getItem();
    EntityPlayer player = event.getEntityPlayer();

    if (player.getEntityWorld().isRemote || entityItem.isDead || stack.isEmpty())
    {
        return true;
    }

    ItemStack origStack = ItemStack.EMPTY;
    final int origStackSize = stack.getCount();
    int stackSizeLast = origStackSize;
    boolean ret = false;

    IItemHandler playerInv = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    // Not all the items could fit into existing stacks in the player's inventory, move them directly to the bag
    List<Integer> slots = InventoryUtils.getSlotNumbersOfMatchingItems(playerInv, EnderUtilitiesItems.HANDY_BAG);

    for (int slot : slots)
    {
        ItemStack bagStack = playerInv.getStackInSlot(slot);

        // Bag is not locked
        if (bagStack.isEmpty() == false && bagStack.getItem() == EnderUtilitiesItems.HANDY_BAG && ItemHandyBag.bagIsOpenable(bagStack))
        {
            // Delayed the stack copying until we know if there is a valid bag,
            // so check if the stack was copied already or not.
            if (origStack == ItemStack.EMPTY)
            {
                origStack = stack.copy();
            }

            stack = handleItems(stack, bagStack, player);

            if (stack.isEmpty() || stack.getCount() != stackSizeLast)
            {
                if (stack.isEmpty())
                {
                    entityItem.setDead();
                    event.setCanceled(true);
                    ret = true;
                    break;
                }

                ItemStack pickedUpStack = origStack.copy();
                pickedUpStack.setCount(stackSizeLast - stack.getCount());

                FMLCommonHandler.instance().firePlayerItemPickupEvent(player, entityItem, pickedUpStack);
                player.onItemPickup(entityItem, origStackSize);
            }

            stackSizeLast = stack.getCount();
        }
    }

    // Not everything was handled, update the stack
    if (entityItem.isDead == false && stack.getCount() != origStackSize)
    {
        entityItem.setItem(stack);
    }

    // At least some items were picked up
    if (entityItem.isSilent() == false && (entityItem.isDead || stack.getCount() != origStackSize))
    {
        player.getEntityWorld().playSound(null, player.getPosition(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.MASTER,
                0.2F, ((itemRand.nextFloat() - itemRand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
    }

    return ret;
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:80,代码来源:ItemHandyBag.java


注:本文中的net.minecraftforge.event.entity.player.EntityItemPickupEvent.getEntityPlayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。