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


Java EntityLivingBase.getHeldItem方法代码示例

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


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

示例1: onHurt

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onHurt(LivingHurtEvent ev) {
    DamageSource source = ev.getSource();
    Entity root = source.getImmediateSource();
    if (root instanceof EntityLivingBase) {
        EntityLivingBase cause = (EntityLivingBase) root;
        EntityLivingBase hurt = ev.getEntityLiving();

        EnumHand active = cause.getActiveHand();
        ItemStack stack = cause.getHeldItem(active);
        RandoresItemHelper.doEmpowered(stack, hurt, cause);

        if(stack.getItem() instanceof RandoresSledgehammer) {
            Vec3d vector = hurt.getPositionVector().subtract(cause.getPositionVector()).normalize().scale(2);
            hurt.addVelocity(vector.x, 0.5, vector.z);
        }
    }
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:19,代码来源:LivingHurtListener.java

示例2: invisibilityCheck

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
private boolean invisibilityCheck(EntityLivingBase entity) {
    if (invisibilityType.getValue() == InvisibilityTargetingType.ALWAYS)
        return true;

    if (invisibilityType.getValue() == InvisibilityTargetingType.NEVER)
        return !entity.isInvisible();

    if (invisibilityType.getValue() == InvisibilityTargetingType.ARMOURED) {
        if (entity instanceof EntityPlayer) {
            EntityPlayer p = (EntityPlayer) entity;
            boolean hasArmour = false;
            for (ItemStack stack : p.inventory.armorInventory) {
                if (stack != null) {
                    hasArmour = true;
                }
            }
            return !(entity.isInvisible() && entity.getHeldItem() == null && !hasArmour);
        }
        return !(entity.isInvisible() && entity.getHeldItem() == null);
    }

    return true;
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:24,代码来源:KillAura.java

示例3: setLivingAnimations

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Used for easily adding entity-dependent animations. The second and third float params here are the same second
 * and third as in the setRotationAngles method.
 */
public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime)
{
    this.rightArmPose = ModelBiped.ArmPose.EMPTY;
    this.leftArmPose = ModelBiped.ArmPose.EMPTY;
    ItemStack itemstack = entitylivingbaseIn.getHeldItem(EnumHand.MAIN_HAND);

    if (itemstack.getItem() == Items.BOW && ((AbstractSkeleton)entitylivingbaseIn).isSwingingArms())
    {
        if (entitylivingbaseIn.getPrimaryHand() == EnumHandSide.RIGHT)
        {
            this.rightArmPose = ModelBiped.ArmPose.BOW_AND_ARROW;
        }
        else
        {
            this.leftArmPose = ModelBiped.ArmPose.BOW_AND_ARROW;
        }
    }

    super.setLivingAnimations(entitylivingbaseIn, p_78086_2_, p_78086_3_, partialTickTime);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:25,代码来源:ModelSkeleton.java

示例4: setupEntity

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void setupEntity(int mode, float scale, boolean efficient, int shrink, float damage, EntityLivingBase owner,
		boolean nogravity, float knockback) {
	this.dropItems = !efficient;
	this.nogravity = nogravity;
	this.scale = scale;
	this.owner = owner;
	this.shrink = shrink;
	this.damage = damage;
	this.setSize(scale / (shrink * shrink), scale / (shrink * shrink));
	this.sticky = mode;
	this.stack = owner.getHeldItem(EnumHand.MAIN_HAND);
	this.knockback = knockback;
	if(this.sticky==3)
		this.noClip=true;
	this.health = Math.min(80,BlockLauncher.getHardness(this.block, this.world)*1.55f);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:17,代码来源:EntityFallingEnchantedBlock.java

示例5: EntityProjectileBase

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public EntityProjectileBase(World world, EntityLivingBase shooter, EnumHand hand) {
	this(world);
	this.shootingEntity = shooter;
	this.usedWeapon = shooter.getHeldItem(hand).copy();
	this.usedWeaponOrig=shooter.getHeldItem(hand);
	this.setLocationAndAngles(shooter.posX, shooter.posY + shooter.getEyeHeight(), shooter.posZ,
			shooter.rotationYawHead, shooter.rotationPitch + this.getPitchAddition());
	this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F
			* (hand == EnumHand.MAIN_HAND ? 1 : -1);
	this.posY -= shooter instanceof EntitySentry ? -0.1D : 0.1D;
	this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F
			* (hand == EnumHand.MAIN_HAND ? 1 : -1);
	this.setPosition(this.posX, this.posY, this.posZ);
	this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI)
			* MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
	this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI)
			* MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
	this.motionY = (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
	this.setThrowableHeading(this.motionX, this.motionY, this.motionZ,
			((ItemWeapon) this.usedWeapon.getItem()).getProjectileSpeed(usedWeapon, shooter),
			((ItemWeapon) this.usedWeapon.getItem()).getWeaponSpread(usedWeapon, shooter));
	if(((ItemWeapon) this.usedWeapon.getItem()).canPenetrate(this.usedWeapon,this.shootingEntity)){
		this.setPenetrate();
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:26,代码来源:EntityProjectileBase.java

示例6: setLivingAnimations

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Used for easily adding entity-dependent animations. The second and third float params here are the same second
 * and third as in the setRotationAngles method.
 */
public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime)
{
    this.rightArmPose = ModelBiped.ArmPose.EMPTY;
    this.leftArmPose = ModelBiped.ArmPose.EMPTY;
    ItemStack itemstack = entitylivingbaseIn.getHeldItem(EnumHand.MAIN_HAND);

    if (itemstack != null && itemstack.getItem() == Items.BOW && ((EntitySkeleton)entitylivingbaseIn).isSwingingArms())
    {
        if (entitylivingbaseIn.getPrimaryHand() == EnumHandSide.RIGHT)
        {
            this.rightArmPose = ModelBiped.ArmPose.BOW_AND_ARROW;
        }
        else
        {
            this.leftArmPose = ModelBiped.ArmPose.BOW_AND_ARROW;
        }
    }

    super.setLivingAnimations(entitylivingbaseIn, p_78086_2_, p_78086_3_, partialTickTime);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:ModelSkeleton.java

示例7: getStateForOrePlacementImpl

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static IBlockState getStateForOrePlacementImpl(Block self, World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
    ItemStack stack = placer.getHeldItem(hand);
    if (RandoresItemData.hasData(stack)) {
        return RandoresWorldData.delegate(new RandoresItemData(stack), def -> self.getDefaultState().withProperty(RandoresOre.HARVEST_LEVEL, def.getOre().getHarvestLevel()), self::getDefaultState);
    }
    return self.getDefaultState();
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:8,代码来源:RandoresItemHelper.java

示例8: renderEquippedItems

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
protected void renderEquippedItems(EntityLivingBase entity, float unknown)
   {
	GL11.glColor3f(1.0F, 1.0F, 1.0F);
       super.renderEquippedItems(entity, unknown);
       
       ItemStack itemstack = entity.getHeldItem();	// The weapon you're holding
       
       if (itemstack != null && itemstack.getItem() != null) 
       { 
       	 GL11.glPushMatrix();

            GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F);

            float scale = 0.625F;

            GL11.glTranslatef(0.3F, 0.2F, -0.25F);		// 0.0F, 0.1875F, 0.0F, left/right, up/down, forward/backward?
            GL11.glScalef(scale, -scale, scale);
            GL11.glRotatef(-20.0F, 1.0F, 0.0F, 0.0F);	// -100
            GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);

            int color = itemstack.getItem().getColorFromItemStack(itemstack, 0);
            float colorR = (float) (color >> 16 & 255) / 255.0F;
            float colorB = (float) (color >> 8 & 255) / 255.0F;
            float colorG = (float) (color & 255) / 255.0F;
            GL11.glColor4f(colorR, colorB, colorG, 1.0F);
           
            this.renderManager.itemRenderer.renderItem(entity, itemstack, 0);

            GL11.glPopMatrix();
       }
       
       this.renderStoredItems((Entity_BB) entity);
   }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:35,代码来源:Render_FlyingAA.java

示例9: getLightLevel

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static int getLightLevel(Entity p_getLightLevel_0_)
{
    if (p_getLightLevel_0_ == Config.getMinecraft().getRenderViewEntity() && !Config.isDynamicHandLight())
    {
        return 0;
    }
    else
    {
        if (p_getLightLevel_0_ instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)p_getLightLevel_0_;

            if (entityplayer.isSpectator())
            {
                return 0;
            }
        }

        if (p_getLightLevel_0_.isBurning())
        {
            return 15;
        }
        else if (p_getLightLevel_0_ instanceof EntityFireball)
        {
            return 15;
        }
        else if (p_getLightLevel_0_ instanceof EntityTNTPrimed)
        {
            return 15;
        }
        else if (p_getLightLevel_0_ instanceof EntityBlaze)
        {
            EntityBlaze entityblaze = (EntityBlaze)p_getLightLevel_0_;
            return entityblaze.func_70845_n() ? 15 : 10;
        }
        else if (p_getLightLevel_0_ instanceof EntityMagmaCube)
        {
            EntityMagmaCube entitymagmacube = (EntityMagmaCube)p_getLightLevel_0_;
            return (double)entitymagmacube.squishFactor > 0.6D ? 13 : 8;
        }
        else
        {
            if (p_getLightLevel_0_ instanceof EntityCreeper)
            {
                EntityCreeper entitycreeper = (EntityCreeper)p_getLightLevel_0_;

                if ((double)entitycreeper.getCreeperFlashIntensity(0.0F) > 0.001D)
                {
                    return 15;
                }
            }

            if (p_getLightLevel_0_ instanceof EntityLivingBase)
            {
                EntityLivingBase entitylivingbase = (EntityLivingBase)p_getLightLevel_0_;
                ItemStack itemstack2 = entitylivingbase.getHeldItem();
                int i = getLightLevel(itemstack2);
                ItemStack itemstack1 = entitylivingbase.getEquipmentInSlot(4);
                int j = getLightLevel(itemstack1);
                return Math.max(i, j);
            }
            else if (p_getLightLevel_0_ instanceof EntityItem)
            {
                EntityItem entityitem = (EntityItem)p_getLightLevel_0_;
                ItemStack itemstack = getItemStack(entityitem);
                return getLightLevel(itemstack);
            }
            else
            {
                return 0;
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:75,代码来源:DynamicLights.java

示例10: handleMessage

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void handleMessage(TF2Message.ActionMessage message, EntityLivingBase player, boolean client) {
	if (player != null) {
		/*
		 * int
		 * oldValue=playerAction.get().containsKey(player)?playerAction.get(
		 * ).get(player):0; if(player.getHeldItem(EnumHand.MAIN_HAND) !=
		 * null && player.getHeldItem(EnumHand.MAIN_HAND).getItem()
		 * instanceof ItemUsable){
		 * if((oldValue&1)==0&&(message.value&1)!=0){
		 * ((ItemUsable)player.getHeldItem(EnumHand.MAIN_HAND).getItem()).
		 * startUse(player.getHeldItem(EnumHand.MAIN_HAND), player,
		 * player.world); } if((oldValue&1)==0&&(message.value&1)!=0){
		 * ((ItemUsable)player.getHeldItem(EnumHand.MAIN_HAND).getItem()).
		 * endUse(player.getHeldItem(EnumHand.MAIN_HAND), player,
		 * player.world); } }
		 */
		/*
		 * if(previousPlayerAction.get(player.world.isRemote).containsKey
		 * (player)){
		 * previousPlayerAction.get(player.world.isRemote).put(player,
		 * 0); } int
		 * oldState=previousPlayerAction.get(player.world.isRemote).get(
		 * player);
		 * 
		 * previousPlayerAction.get(player.world.isRemote).put(player,
		 * playerAction.get(true).get(player));
		 */

		WeaponsCapability cap = player.getCapability(TF2weapons.WEAPONS_CAP, null);
		ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
		int oldState = cap.state & 3;
		//System.out.println("Action: "+message.value);
		cap.state = message.value + (cap.state & 8);

		if (!stack.isEmpty() && stack.getItem() instanceof ItemUsable && oldState != (message.value & 3)
				&& stack.getCapability(TF2weapons.WEAPONS_DATA_CAP, null).active == 2) {
			if ((oldState & 2) < (message.value & 2)) {
				((ItemUsable) stack.getItem()).startUse(stack, player, player.world, oldState,
						message.value & 3);
				cap.stateDo(player, stack);
			} else if ((oldState & 2) > (message.value & 2))
				((ItemUsable) stack.getItem()).endUse(stack, player, player.world, oldState, message.value & 3);
			if ((oldState & 1) < (message.value & 1)) {
				((ItemUsable) stack.getItem()).startUse(stack, player, player.world, oldState,
						message.value & 3);
				cap.stateDo(player, stack);
			} else if ((oldState & 1) > (message.value & 1))
				((ItemUsable) stack.getItem()).endUse(stack, player, player.world, oldState, message.value & 3);
		}
		// System.out.println("change
		// "+playerAction.get(player.world.isRemote).get(player));
		// System.out.println("dostal: "+message.value);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:55,代码来源:TF2ActionHandler.java


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