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


Java EntityLivingBase.addPotionEffect方法代码示例

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


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

示例1: tryFireMinigun

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public boolean tryFireMinigun(EntityLivingBase target) {
    boolean lastShotOfAmmo = false;
    if (!ammo.isEmpty() && (pressurizable == null || pressurizable.getPressure(stack) > 0)) {
        setMinigunTriggerTimeOut(Math.max(10, getMinigunSoundCounter()));
        if (getMinigunSpeed() == MAX_GUN_SPEED && (!requiresTarget || gunAimedAtTarget)) {
            if (!requiresTarget) target = raytraceTarget();
            lastShotOfAmmo = ammo.attemptDamageItem(1, rand, player instanceof EntityPlayerMP ? (EntityPlayerMP) player : null);
            if (pressurizable != null) pressurizable.addAir(stack, -airUsage);
            if (target != null) {
                ItemStack potion = ItemGunAmmo.getPotion(ammo);
                if (!potion.isEmpty()) {
                    if (rand.nextInt(20) == 0) {
                        List<PotionEffect> effects = PotionUtils.getEffectsFromStack(potion);
                        for (PotionEffect effect : effects) {
                            target.addPotionEffect(new PotionEffect(effect));
                        }
                    }
                } else {
                    target.attackEntityFrom(DamageSource.causePlayerDamage(player), ConfigHandler.general.configMinigunDamage);
                }
            }
        }
    }
    return lastShotOfAmmo;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:Minigun.java

示例2: arrowHit

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
protected void arrowHit(EntityLivingBase living)
{
    super.arrowHit(living);

    for (PotionEffect potioneffect : this.potion.getEffects())
    {
        living.addPotionEffect(new PotionEffect(potioneffect.getPotion(), Math.max(potioneffect.getDuration() / 8, 1), potioneffect.getAmplifier(), potioneffect.getIsAmbient(), potioneffect.doesShowParticles()));
    }

    if (!this.customPotionEffects.isEmpty())
    {
        for (PotionEffect potioneffect1 : this.customPotionEffects)
        {
            living.addPotionEffect(potioneffect1);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:EntityTippedArrow.java

示例3: applyPotionEffect

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void applyPotionEffect(EntityLivingBase entitylivingbase, ShotPotion pot)
{
	if (entitylivingbase == null) { return; }	// Not a valid entity, for some reason
	
	if (pot == null) { return; }				// Nothing to apply
	
	PotionEffect potion = entitylivingbase.getActivePotionEffect(pot.potion);
	
	if (potion != null)	// Already exists. Extending it
	{
		int dur = potion.getDuration();
		
		entitylivingbase.addPotionEffect( new PotionEffect(pot.potion.id, pot.Duration + dur, pot.Strength - 1, false) );
	}
	else { entitylivingbase.addPotionEffect( new PotionEffect(pot.potion.id, pot.Duration, pot.Strength - 1, false) ); }	// Fresh
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:17,代码来源:Helper.java

示例4: applyEffects

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void applyEffects(EntityLivingBase target, EntityLivingBase source, EntityLivingBase indirectsource) {
    for (CaskPotionEffect effect : effects)
    {
        PotionEffect potioneffect = effect.potionEffect;
        PotionEffect currentStack = target.getActivePotionEffect(potioneffect.getPotion());
        if (potioneffect.getPotion().isInstant())
        {
            potioneffect.getPotion().affectEntity(source, indirectsource, target, potioneffect.getAmplifier(), 1.0D);
        }
        else
        {
            int amplifier = currentStack.getAmplifier();
            int duration = currentStack.getDuration();
            if(currentStack != null)
            {
                amplifier = Math.min(amplifier + currentStack.getAmplifier() + 1,effect.maxStack);
                if(amplifier != currentStack.getAmplifier())
                    duration += currentStack.getDuration();
            }
            PotionEffect newStack = new PotionEffect(potioneffect.getPotion(),duration,amplifier,false,false); //TODO: curative item?? alchemical hangover cure???
            target.addPotionEffect(newStack);
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:25,代码来源:CaskManager.java

示例5: onItemUse

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemUse(LivingEntityUseItemEvent event)
{
    EntityLivingBase living = event.getEntityLiving();
    ItemStack stack = event.getItem();
    PotionEffect effect = living.getActivePotionEffect(this);

    if(ItemUtil.matchesOreDict(stack,"torch") && effect != null)
    {
        //TODO: Blow a cloud of fire out
        if(effect.getDuration() > 10)
        {
            PotionEffect reducedEffect = new PotionEffect(this, effect.getDuration() - 5, effect.getAmplifier(), effect.getIsAmbient(), effect.doesShowParticles());
            reducedEffect.setCurativeItems(effect.getCurativeItems());
            living.addPotionEffect(reducedEffect);
        }
        else
        {
            living.removePotionEffect(this);
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:23,代码来源:PotionFireLung.java

示例6: doSplash

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
private void doSplash() {
	AxisAlignedBB axisalignedbb = this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D);
	List<EntityLivingBase> list = this.world.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);

	if (!list.isEmpty()) {
		Tuple<List<BrewEffect>, List<PotionEffect>> tuple = BrewUtils.deSerialize(NBTHelper.fixNBT(getBrew()));

		for (EntityLivingBase entity : list) {
			double distance = this.getDistanceSq(entity);

			if (distance < 16.0D) {
				for (BrewEffect effect : tuple.getFirst()) {
					BrewStorageHandler.addEntityBrewEffect(entity, effect.copy());
				}

				for (PotionEffect potioneffect : tuple.getSecond()) {
					entity.addPotionEffect(new PotionEffect(potioneffect));
				}
			}
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:23,代码来源:EntityBrew.java

示例7: onEntityWalk

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onEntityWalk(World world, BlockPos pos, Entity entity) {
	if (world.isRemote) return;
	if (entity instanceof EntityLivingBase) {
		EntityLivingBase living = (EntityLivingBase)entity;
		
		living.addPotionEffect(new PotionEffect(Thermionics.POTION_EFFORTLESS_SPEED, 20, level));
	}
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:10,代码来源:BlockRoad.java

示例8: updateTick

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
	
	List<EntityLivingBase> elb = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos.add(-range, -3, -range), pos.add(range, 3, range)));
	for (EntityLivingBase entity : elb) {
		if (!entity.isDead && (entity instanceof EntityMob || entity instanceof EntitySlime) && !world.isRemote) {
			entity.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 500));
		}
	}
	world.scheduleUpdate(pos, this, 100);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:12,代码来源:BlockTotemhead.java

示例9: onArmorTick

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onArmorTick(World world, final EntityPlayer player, ItemStack itemStack) {
	if (!world.isRemote) {
		if (player.ticksExisted % 20 == 0) {
			float heal = TF2Attribute.getModifier("Health Regen", itemStack, 0, player);
			if(heal > 0) {
				int lastHitTime = player.ticksExisted - player.getEntityData().getInteger("lasthit");
				if (lastHitTime >= 120)
					player.heal(heal);
				else if(lastHitTime >= 60)
					player.heal(TF2Util.lerp(heal, heal/4f, (lastHitTime-60)/60f));
				else
					player.heal(heal/4f);
			}
		}
		if (player.ticksExisted % 5 == 0 && itemStack.getTagCompound().getBoolean("Active")) {
			itemStack.getTagCompound().setFloat("Rage",
					Math.max(0,
							itemStack.getTagCompound().getFloat("Rage")
									- 1 / (TF2Attribute.getModifier("Buff Duration", itemStack,
											getData(itemStack).getInt(PropertyType.DURATION), player) - 20)));
			if (itemStack.getTagCompound().getFloat("Rage") <= 0)
				itemStack.getTagCompound().setBoolean("Active", false);
			for (EntityLivingBase living : world.getEntitiesWithinAABB(EntityLivingBase.class,
					player.getEntityBoundingBox().grow(10, 10, 10), new Predicate<EntityLivingBase>() {

						@Override
						public boolean apply(EntityLivingBase input) {
							// TODO Auto-generated method stub
							return TF2Util.isOnSameTeam(player, input);
						}

					}))
				living.addPotionEffect(new PotionEffect(this.getBuff(itemStack), 25));

		}
		if (player.isCreative())
			itemStack.getTagCompound().setFloat("Rage", 1);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:41,代码来源:ItemSoldierBackpack.java

示例10: setAttackTarget

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void setAttackTarget(EntityLivingBase ent){
	if(this.getAttackTarget()!=null&&ent instanceof EntityBuilding)
		return;
	if(ent!=null&&ent.hasCapability(TF2weapons.WEAPONS_CAP, null)&&ent.getCapability(TF2weapons.WEAPONS_CAP, null).itProtection>0)
		return;
	
	if(ent!=this.getAttackTarget()&&this.getAttackTarget()!=null){
		boolean hadeffect=this.getAttackTarget().getActivePotionEffect(TF2weapons.it)!=null;
		this.getAttackTarget().removePotionEffect(TF2weapons.it);
		if(ent==null&&hadeffect)
			this.getAttackTarget().addPotionEffect(new PotionEffect(TF2weapons.it,12));
	}
	if(ent!=null){
		/*if(ent.getActivePotionEffect(TF2weapons.it)==null&&this.scareTick<=0){
			for(EntityLivingBase living:this.world.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().grow(10, 10, 10), new Predicate<EntityLivingBase>(){

				@Override
				public boolean apply(EntityLivingBase input) {
					// TODO Auto-generated method stub
					return getDistanceSqToEntity(input)<100 && !TF2weapons.isOnSameTeam(EntityHHH.this, input) && !(input.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null 
							&& input.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem()==Item.getItemFromBlock(Blocks.PUMPKIN));
				}
				
			})){
				TF2weapons.stun(living, 100, false);
			}
			this.scareTick=200;
		}*/
		this.targetTime=300;
		ent.addPotionEffect(new PotionEffect(TF2weapons.it,600));
		if(ent!=this.getAttackTarget()&&this.rand.nextBoolean()){
			
		}
	}
	super.setAttackTarget(ent);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:37,代码来源:EntityHHH.java

示例11: performEffect

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
	if (caster != null) {
		caster.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 160, 0, false, true));
		caster.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 160, 0, false, false));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:8,代码来源:SpellSelfHeal.java

示例12: onImpact

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
protected void onImpact(RayTraceResult mop) 
{
	switch(mop.typeOfHit)
	{
	case BLOCK:
		if (!inTerrain)
		{
			doBlockHitEffects(world, mop);
		}
		BlockPos pos = mop.getBlockPos();
		IBlockState state = world.getBlockState(pos);
		if(state.getBlock().canCollideCheck(state, false))
		{
			this.inTerrain = true;
			this.stuckPos = pos;
			//Why setVelocity is @SideOnly(Side.CLIENT) I do not know
			this.motionX = this.motionY = this.motionZ = 0.0F;
		}	
		break;
	case ENTITY:
		if(mop.entityHit instanceof EntityLivingBase && mop.entityHit != this.getThrower())
		{
			EntityLivingBase entityLiving = (EntityLivingBase) mop.entityHit;
			int dmg = 2;
			if(this.getThrower() instanceof EntityPlayer && ((EntityPlayer)this.getThrower()).capabilities.isCreativeMode) dmg = 0;
			if(!world.isRemote && !knife.attemptDamageItem(dmg, rand, (EntityPlayerMP) this.getThrower()))
			{
				entityLiving.attackEntityFrom(DamageSource.causeThrownDamage(mop.entityHit, this.getThrower()), baseDamage * force);
				entityLiving.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, (int) (100 * force), 2, false, false));
			}
		}
		break;
	default:
		break;
	}
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:38,代码来源:EntityThrownKnife.java

示例13: onUpdate

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack stack, World par2World, Entity par3Entity, int par4, boolean par5) {
	super.onUpdate(stack, par2World, par3Entity, par4, par5);
	if(stack.isEmpty())
		return;
	/*
	 * if(itemProperties.get(par2World.isRemote).get(par3Entity)==null){
	 * itemProperties.get(par2World.isRemote).put((EntityLivingBase)
	 * par3Entity, new NBTTagCompound()); }
	 */
	WeaponsCapability cap = par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null);
	WeaponData.WeaponDataCapability stackcap = stack.getCapability(TF2weapons.WEAPONS_DATA_CAP, null);
	EntityLivingBase living=(EntityLivingBase) par3Entity;
	if (stackcap.active == 0 && par5) {
		stackcap.active = 1;
		// itemProperties.get(par2World.isRemote).get(par3Entity).setShort("reloadd",
		// (short) 800);

		if(!par2World.isRemote && living.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).getModifier(ItemWeapon.HEALTH_MODIFIER)!=null){
			float addHealth=(float) living.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).getModifier(ItemWeapon.HEALTH_MODIFIER).getAmount();
			living.setHealth((living.getMaxHealth())/(living.getMaxHealth()-addHealth)*living.getHealth());
		}
		cap.fire1Cool = this.getDeployTime(stack, living);
		cap.fire2Cool = this.getDeployTime(stack, living);
	} else if (stackcap.active > 0
			&& stack != living.getHeldItemOffhand() && !par5) {
		if (stackcap.active == 2 && (cap.state & 3) > 0)
			this.endUse(stack, living, par2World, cap.state, 0);
		
		stackcap.active = 0;
		this.holster(cap, stack, living, par2World);

	}
	if (par3Entity.ticksExisted % 5 == 0 && stackcap.active == 2
			&& TF2Attribute.getModifier("Mark Death", stack, 0, living) > 0)
		living.addPotionEffect(new PotionEffect(TF2weapons.markDeath,
				(int) TF2Attribute.getModifier("Mark Death", stack, 0,living) * 20));
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:39,代码来源:ItemUsable.java

示例14: onEntityDamaged

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Called whenever a mob is damaged with an item that has this enchantment on it.
 */
public void onEntityDamaged(EntityLivingBase user, Entity target, int level)
{
    if (target instanceof EntityLivingBase)
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)target;

        if (this.damageType == 2 && entitylivingbase.getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD)
        {
            int i = 20 + user.getRNG().nextInt(10 * level);
            entitylivingbase.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, i, 3));
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:EnchantmentDamage.java

示例15: arrowHit

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
protected void arrowHit(EntityLivingBase living) {
	if(arrowType == EnumHarshenArrowTypes.RIPPER
			&&!(Lists.newArrayList(living.getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet
			&& Lists.newArrayList(living.getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate
			&& Lists.newArrayList(living.getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings
			&& Lists.newArrayList(living.getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots))
		living.addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1));
		
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:11,代码来源:HarshenArrow.java


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