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


Java EntityItemPickupEvent类代码示例

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


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

示例1: onItemPickup

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

示例2: 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

示例3: onPlayerPickup

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

示例4: onCollideWithPlayer

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

示例5: 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

示例6: 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

示例7: onItemPickup

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

示例8: 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

示例9: onPickUp

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

示例10: onPickup

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

示例11: onRingPickUp

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

示例12: onEntityItemPickupEvent

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //导入依赖的package包/类
@SubscribeEvent
public void onEntityItemPickupEvent(EntityItemPickupEvent event)
{
    if (ItemPickupManager.onEntityItemPickupEvent(event))
    {
        return;
    }

    if (ItemHandyBag.onEntityItemPickupEvent(event))
    {
        return;
    }

    if (ItemNullifier.onEntityItemPickupEvent(event))
    {
        return;
    }
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:19,代码来源:ItemPickupEventHandler.java

示例13: onPickup

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

示例14: onItemPickup

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

示例15: onItemPickupAttempt

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


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