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


Java EntityPlayer.getActiveItemStack方法代码示例

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


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

示例1: saveToNBT

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private void saveToNBT(EntityPlayer playerIn) {
	if (!playerIn.getEntityWorld().isRemote) {
		String listPidTotal="";
		for(int i=0;i<listPid.size();i++){
			listPidTotal+=listPid.get(i);
			if(i+1<listPid.size()){
				listPidTotal+="%,%";
			}
		}
		//System.out.println(listPid.size());
		ItemStack itemStackBook = playerIn.getActiveItemStack();
		if (itemStackBook != null) {
			NBTTagCompound nbt = new NBTTagCompound();
			nbt.setString("listPid", listPidTotal);
			nbt.setInteger("index", index);
			itemStackBook.setTagCompound(nbt);
		}
	}
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:20,代码来源:ContainerPictureBook.java

示例2: doAxeStuff

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private void doAxeStuff(EntityLivingBase attacked, EntityLivingBase attacker)
{
    //Copied from EntityMob#attackEntityAsMob() L134-150 START
    if (attacked instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)attacked;
        ItemStack itemstack = attacker.getHeldItemMainhand();
        ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.EMPTY;

        if (!itemstack.isEmpty() && !itemstack1.isEmpty() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == RegisterItems.wickerShield)
        {
            float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(attacker) * 0.05F;

            if (attacker.world.rand.nextFloat() < f1)
            {
            entityplayer.getCooldownTracker().setCooldown(RegisterItems.wickerShield, 100);
            attacker.world.setEntityState(entityplayer, (byte) 30);
            }
        }
    }
    //Copied from EntityMob#attackEntityAsMob() L134-150 END
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:23,代码来源:ItemWickerShield.java

示例3: attackEntityAsMob

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).knockBack(this, (float)i * 0.5F, (double)MathHelper.sin(this.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.field_190927_a;

            if (!itemstack.func_190926_b() && !itemstack1.func_190926_b() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
            {
                float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1)
                {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.world.setEntityState(entityplayer, (byte)30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:53,代码来源:EntityMob.java

示例4: attackEntityAsMob

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean attackEntityAsMob(Entity entityIn) {
	float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
	int i = 0;

	if (entityIn instanceof EntityLivingBase) {
		f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(),
				((EntityLivingBase) entityIn).getCreatureAttribute());
		i += EnchantmentHelper.getKnockbackModifier(this);
	}

	boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

	if (flag) {
		if (i > 0 && entityIn instanceof EntityLivingBase) {
			((EntityLivingBase) entityIn).knockBack(this, i * 0.5F, MathHelper.sin(this.rotationYaw * 0.017453292F),
					(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
			this.motionX *= 0.6D;
			this.motionZ *= 0.6D;
		}

		int j = EnchantmentHelper.getFireAspectModifier(this);

		if (j > 0)
			entityIn.setFire(j * 4);

		if (entityIn instanceof EntityPlayer) {
			EntityPlayer entityplayer = (EntityPlayer) entityIn;
			ItemStack itemstack = this.getHeldItemMainhand();
			ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

			if (!itemstack.isEmpty() && itemstack1 != null && itemstack.getItem() instanceof ItemAxe
					&& itemstack1.getItem() == Items.SHIELD) {
				float f1 = 0.25F + EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

				if (this.rand.nextFloat() < f1) {
					entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
					this.world.setEntityState(entityplayer, (byte) 30);
				}
			}
		}

		this.applyEnchantments(this, entityIn);
	}

	return flag;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:48,代码来源:EntityTF2Character.java

示例5: attackEntityAsMob

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean attackEntityAsMob(Entity entityIn) {
	float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
	int i = 0;

	if (entityIn instanceof EntityLivingBase) {
		f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(),
				((EntityLivingBase) entityIn).getCreatureAttribute());
		i += EnchantmentHelper.getKnockbackModifier(this);
	}

	boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

	if (flag) {
		if (i > 0 && entityIn instanceof EntityLivingBase) {
			((EntityLivingBase) entityIn).knockBack(this, i * 0.5F, MathHelper.sin(this.rotationYaw * 0.017453292F),
					(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
			this.motionX *= 0.6D;
			this.motionZ *= 0.6D;
		}

		int j = EnchantmentHelper.getFireAspectModifier(this);

		if (j > 0)
			entityIn.setFire(j * 4);

		if (entityIn instanceof EntityPlayer) {
			EntityPlayer entityplayer = (EntityPlayer) entityIn;
			ItemStack itemstack = this.getHeldItemMainhand();
			ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

			if (!itemstack.isEmpty() && itemstack1 != null && itemstack.getItem() instanceof ItemAxe
					&& itemstack1.getItem() == Items.SHIELD) {
				float f1 = 0.25F + EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

				if (this.rand.nextFloat() < f1) {
					entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
					this.world.setEntityState(entityplayer, (byte) 30);
				}
			}
		}

		this.applyEnchantments(this, entityIn);

		if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).getHealth() <= 0)
			if (entityIn instanceof EntityBuilding)
				this.playSound(TF2Sounds.MOB_SAXTON_DESTROY, 2.2F, 1f);
			else
				this.playSound(TF2Sounds.MOB_SAXTON_KILL, 2.2F, 1f);
	}

	return flag;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:54,代码来源:EntitySaxtonHale.java

示例6: attackEntityAsMob

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).knockBack(this, (float)i * 0.5F, (double)MathHelper.sin(this.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

            if (itemstack != null && itemstack1 != null && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
            {
                float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1)
                {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.worldObj.setEntityState(entityplayer, (byte)30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:53,代码来源:EntityMob.java


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