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


Java EntityPlayer.onItemPickup方法代码示例

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


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

示例1: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer entityIn)
{
    if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
    {
        boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && entityIn.capabilities.isCreativeMode;

        if (this.canBePickedUp == 1 && !entityIn.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1)))
        {
            flag = false;
        }

        if (flag)
        {
            this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
            entityIn.onItemPickup(this, 1);
            this.setDead();
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:23,代码来源:EntityArrow.java

示例2: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer entityIn)
{
    if (!this.world.isRemote && this.inGround && this.arrowShake <= 0)
    {
        boolean flag = this.pickupStatus == EntityArrow.PickupStatus.ALLOWED || this.pickupStatus == EntityArrow.PickupStatus.CREATIVE_ONLY && entityIn.capabilities.isCreativeMode;

        if (this.pickupStatus == EntityArrow.PickupStatus.ALLOWED && !entityIn.inventory.addItemStackToInventory(this.getArrowStack()))
        {
            flag = false;
        }

        if (flag)
        {
            entityIn.onItemPickup(this, 1);
            this.setDead();
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:EntityArrow.java

示例3: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onCollideWithPlayer(EntityPlayer player) {
	if(!this.world.isRemote) {
		if(cannotPickup()) return;
		ItemStack itemstack = this.getItem();
		Item item = itemstack.getItem();
		int i = itemstack.getCount();

		int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, player);
		if(hook < 0) return;

		if(hook == 1 || i <= 0 || player.inventory.addItemStackToInventory(itemstack)) {
			net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerItemPickupEvent(player, this);
			player.onItemPickup(this, i);

			if(itemstack.isEmpty()) {
				this.setDead();
				itemstack.setCount(i);
			}

			player.addStat(StatList.getObjectsPickedUpStats(item), i);
		}
	}
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:25,代码来源:EntityStaticItem.java

示例4: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onCollideWithPlayer(EntityPlayer player) {
	boolean inGround = false;
	try {
		inGround = ReflectionHelper.getPrivateValue(EntityArrow.class, this, "inGround", "field_70254_i");
	} catch (Exception e) {
	}

	if (!worldObj.isRemote && inGround && arrowShake <= 0 && isEffectValid()) {
		boolean flag = canBePickedUp == 1 || canBePickedUp == 2 && player.capabilities.isCreativeMode;

		ItemStack stack = new ItemStack(ModItems.tipped_arrow);
		TippedArrow.setEffect(stack, Potion.potionTypes[effect.getPotionID()], effect.getDuration());

		if (canBePickedUp == 1 && !player.inventory.addItemStackToInventory(stack))
			flag = false;

		if (flag) {
			playSound("random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
			player.onItemPickup(this, 1);
			setDead();
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:25,代码来源:EntityTippedArrow.java

示例5: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的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

示例6: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
    if (!this.world.isRemote && item && par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModItems.itemTracker, 1, freq)))
    {
        //TODO SoundCat for this.
        this.world.playSound(null, posX, posY, posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
        par1EntityPlayer.onItemPickup(this, 1);
        setDead();
    }
}
 
开发者ID:TheCBProject,项目名称:WirelessRedstone,代码行数:12,代码来源:EntityWirelessTracker.java

示例7: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer entityIn)
{
    if (!this.worldObj.isRemote)
    {
        if (this.delayBeforeCanPickup == 0 && entityIn.xpCooldown == 0)
        {
            if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerPickupXpEvent(entityIn, this))) return;
            entityIn.xpCooldown = 2;
            this.worldObj.playSound((EntityPlayer)null, entityIn.posX, entityIn.posY, entityIn.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_TOUCH, SoundCategory.PLAYERS, 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F));
            entityIn.onItemPickup(this, 1);
            ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, entityIn);

            if (itemstack != null && itemstack.isItemDamaged())
            {
                int i = Math.min(this.xpToDurability(this.xpValue), itemstack.getItemDamage());
                this.xpValue -= this.durabilityToXp(i);
                itemstack.setItemDamage(itemstack.getItemDamage() - i);
            }

            if (this.xpValue > 0)
            {
                entityIn.addExperience(this.xpValue);
            }

            this.setDead();
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:32,代码来源:EntityXPOrb.java

示例8: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer entityIn)
{
    if (!this.worldObj.isRemote)
    {
        if (this.delayBeforeCanPickup == 0 && entityIn.xpCooldown == 0)
        {
            entityIn.xpCooldown = 2;
            this.worldObj.playSoundAtEntity(entityIn, "random.orb", 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F));
            entityIn.onItemPickup(this, 1);
            entityIn.addExperience(this.xpValue);
            this.setDead();
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:18,代码来源:EntityXPOrb.java

示例9: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onCollideWithPlayer(EntityPlayer entityIn)
{
	if(!this.world.isRemote && AnimaConfig.allowPlayerPickup)
	{
		if(age < 10)
			return;
		ItemStack itemstack = this.getItem();
		Item item = itemstack.getItem();
		int i = itemstack.getCount();

		int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, entityIn);
		if(hook < 0)
			return;

		if(entityIn.inventory.addItemStackToInventory(itemstack))
		{
			net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerItemPickupEvent(entityIn, this);
			entityIn.onItemPickup(this, i);

			if(itemstack.isEmpty())
			{
				this.setDead();
				itemstack.setCount(i);
			}

			entityIn.addStat(StatList.getObjectsPickedUpStats(item), i);
		}
	}
}
 
开发者ID:Lemonszz,项目名称:Anima-Mundi,代码行数:31,代码来源:EntityNodeItem.java

示例10: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onCollideWithPlayer(EntityPlayer player)
{
	if (!this.world.isRemote && this.thrower == player && this.inGround && this.throwableShake <= 0)
	{
		this.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
		player.onItemPickup(this, 1);
		this.setDead();
	}
}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:11,代码来源:EntityCurseOrb.java

示例11: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer entityIn)
{
    if (!this.world.isRemote)
    {
        if (this.delayBeforeCanPickup == 0 && entityIn.xpCooldown == 0)
        {
            entityIn.xpCooldown = 2;
            entityIn.onItemPickup(this, 1);
            ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, entityIn);

            if (!itemstack.func_190926_b() && itemstack.isItemDamaged())
            {
                int i = Math.min(this.xpToDurability(this.xpValue), itemstack.getItemDamage());
                this.xpValue -= this.durabilityToXp(i);
                itemstack.setItemDamage(itemstack.getItemDamage() - i);
            }

            if (this.xpValue > 0)
            {
                entityIn.addExperience(this.xpValue);
            }

            this.setDead();
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:30,代码来源:EntityXPOrb.java

示例12: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer entityIn)
{
    if (!this.worldObj.isRemote)
    {
        ItemStack itemstack = this.getEntityItem();
        int i = itemstack.stackSize;

        if (this.delayBeforeCanPickup == 0 && (this.owner == null || 6000 - this.age <= 200 || this.owner.equals(entityIn.getName())) && entityIn.inventory.addItemStackToInventory(itemstack))
        {
            if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log))
            {
                entityIn.triggerAchievement(AchievementList.mineWood);
            }

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

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

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

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

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

                if (entityplayer != null && entityplayer != entityIn)
                {
                    entityplayer.triggerAchievement(AchievementList.diamondsToYou);
                }
            }

            if (!this.isSilent())
            {
                this.worldObj.playSoundAtEntity(entityIn, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
            }

            entityIn.onItemPickup(this, i);

            if (itemstack.stackSize <= 0)
            {
                this.setDead();
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:62,代码来源:EntityItem.java

示例13: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer entityIn)
{
    if (!this.worldObj.isRemote)
    {
        if (this.delayBeforeCanPickup > 0) return;
        ItemStack itemstack = this.getEntityItem();
        int i = itemstack.stackSize;

        int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, entityIn, itemstack);
        if (hook < 0) return;

        if (this.delayBeforeCanPickup <= 0 && (this.owner == null || lifespan - this.age <= 200 || this.owner.equals(entityIn.getName())) && (hook == 1 || i <= 0 || entityIn.inventory.addItemStackToInventory(itemstack)))
        {
            if (itemstack.getItem() == Item.getItemFromBlock(Blocks.LOG))
            {
                entityIn.addStat(AchievementList.MINE_WOOD);
            }

            if (itemstack.getItem() == Item.getItemFromBlock(Blocks.LOG2))
            {
                entityIn.addStat(AchievementList.MINE_WOOD);
            }

            if (itemstack.getItem() == Items.LEATHER)
            {
                entityIn.addStat(AchievementList.KILL_COW);
            }

            if (itemstack.getItem() == Items.DIAMOND)
            {
                entityIn.addStat(AchievementList.DIAMONDS);
            }

            if (itemstack.getItem() == Items.BLAZE_ROD)
            {
                entityIn.addStat(AchievementList.BLAZE_ROD);
            }

            if (itemstack.getItem() == Items.DIAMOND && this.getThrower() != null)
            {
                EntityPlayer entityplayer = this.worldObj.getPlayerEntityByName(this.getThrower());

                if (entityplayer != null && entityplayer != entityIn)
                {
                    entityplayer.addStat(AchievementList.DIAMONDS_TO_YOU);
                }
            }

            net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerItemPickupEvent(entityIn, this);
            if (!this.isSilent())
            {
                this.worldObj.playSound((EntityPlayer)null, entityIn.posX, entityIn.posY, entityIn.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
            }

            entityIn.onItemPickup(this, i);

            if (itemstack.stackSize <= 0)
            {
                this.setDead();
            }

            entityIn.addStat(StatList.getObjectsPickedUpStats(itemstack.getItem()), i);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:69,代码来源:EntityItem.java

示例14: onCollideWithPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer entityIn)
{
    if (!this.world.isRemote)
    {
        ItemStack itemstack = this.getEntityItem();
        Item item = itemstack.getItem();
        int i = itemstack.func_190916_E();

        if (this.delayBeforeCanPickup == 0 && (this.owner == null || 6000 - this.age <= 200 || this.owner.equals(entityIn.getName())) && entityIn.inventory.addItemStackToInventory(itemstack))
        {
            if (item == Item.getItemFromBlock(Blocks.LOG))
            {
                entityIn.addStat(AchievementList.MINE_WOOD);
            }

            if (item == Item.getItemFromBlock(Blocks.LOG2))
            {
                entityIn.addStat(AchievementList.MINE_WOOD);
            }

            if (item == Items.LEATHER)
            {
                entityIn.addStat(AchievementList.KILL_COW);
            }

            if (item == Items.DIAMOND)
            {
                entityIn.addStat(AchievementList.DIAMONDS);
            }

            if (item == Items.BLAZE_ROD)
            {
                entityIn.addStat(AchievementList.BLAZE_ROD);
            }

            if (item == Items.DIAMOND && this.getThrower() != null)
            {
                EntityPlayer entityplayer = this.world.getPlayerEntityByName(this.getThrower());

                if (entityplayer != null && entityplayer != entityIn)
                {
                    entityplayer.addStat(AchievementList.DIAMONDS_TO_YOU);
                }
            }

            entityIn.onItemPickup(this, i);

            if (itemstack.func_190926_b())
            {
                this.setDead();
                itemstack.func_190920_e(i);
            }

            entityIn.addStat(StatList.getObjectsPickedUpStats(item), i);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:61,代码来源:EntityItem.java


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