當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityItemPickupEvent.getResult方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.EntityItemPickupEvent.getResult方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityItemPickupEvent.getResult方法的具體用法?Java EntityItemPickupEvent.getResult怎麽用?Java EntityItemPickupEvent.getResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.entity.player.EntityItemPickupEvent的用法示例。


在下文中一共展示了EntityItemPickupEvent.getResult方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCollideWithPlayer

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //導入方法依賴的package包/類
public void onCollideWithPlayer(EntityPlayer p_70100_1_)
{
    if (!this.worldObj.isRemote)
    {
        if (this.delayBeforeCanPickup > 0)
        {
            return;
        }

        EntityItemPickupEvent event = new EntityItemPickupEvent(p_70100_1_, this);

        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return;
        }

        ItemStack itemstack = this.getEntityItem();
        int i = itemstack.stackSize;

        if (this.delayBeforeCanPickup <= 0 && (this.field_145802_g == null || lifespan - this.age <= 200 || this.field_145802_g.equals(p_70100_1_.getCommandSenderName())) && (event.getResult() == Result.ALLOW || i <= 0 || p_70100_1_.inventory.addItemStackToInventory(itemstack)))
        {
            if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log))
            {
                p_70100_1_.triggerAchievement(AchievementList.mineWood);
            }

            if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log2))
            {
                p_70100_1_.triggerAchievement(AchievementList.mineWood);
            }

            if (itemstack.getItem() == Items.leather)
            {
                p_70100_1_.triggerAchievement(AchievementList.killCow);
            }

            if (itemstack.getItem() == Items.diamond)
            {
                p_70100_1_.triggerAchievement(AchievementList.diamonds);
            }

            if (itemstack.getItem() == Items.blaze_rod)
            {
                p_70100_1_.triggerAchievement(AchievementList.blazeRod);
            }

            if (itemstack.getItem() == Items.diamond && this.func_145800_j() != null)
            {
                EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(this.func_145800_j());

                if (entityplayer1 != null && entityplayer1 != p_70100_1_)
                {
                    entityplayer1.triggerAchievement(AchievementList.field_150966_x);
                }
            }

            FMLCommonHandler.instance().firePlayerItemPickupEvent(p_70100_1_, this);

            this.worldObj.playSoundAtEntity(p_70100_1_, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
            p_70100_1_.onItemPickup(this, i);

            if (itemstack.stackSize <= 0)
            {
                this.setDead();
            }
        }
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:69,代碼來源:EntityItem.java

示例2: onCollideWithPlayer

import net.minecraftforge.event.entity.player.EntityItemPickupEvent; //導入方法依賴的package包/類
/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
    if (!this.worldObj.isRemote)
    {
        if (this.delayBeforeCanPickup > 0)
        {
            return;
        }

        EntityItemPickupEvent event = new EntityItemPickupEvent(par1EntityPlayer, this);

        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return;
        }

        ItemStack itemstack = this.getEntityItem();
        int i = itemstack.stackSize;

        if (this.delayBeforeCanPickup <= 0 && (event.getResult() == Result.ALLOW || i <= 0 || par1EntityPlayer.inventory.addItemStackToInventory(itemstack)))
        {
            if (itemstack.itemID == Block.wood.blockID)
            {
                par1EntityPlayer.triggerAchievement(AchievementList.mineWood);
            }

            if (itemstack.itemID == Item.leather.itemID)
            {
                par1EntityPlayer.triggerAchievement(AchievementList.killCow);
            }

            if (itemstack.itemID == Item.diamond.itemID)
            {
                par1EntityPlayer.triggerAchievement(AchievementList.diamonds);
            }

            if (itemstack.itemID == Item.blazeRod.itemID)
            {
                par1EntityPlayer.triggerAchievement(AchievementList.blazeRod);
            }

            GameRegistry.onPickupNotification(par1EntityPlayer, this);

            this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
            par1EntityPlayer.onItemPickup(this, i);

            if (itemstack.stackSize <= 0)
            {
                this.setDead();
            }
        }
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:57,代碼來源:EntityItem.java


注:本文中的net.minecraftforge.event.entity.player.EntityItemPickupEvent.getResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。