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


Java PotionUtils.getEffectsFromStack方法代码示例

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


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

示例1: tryFireMinigun

import net.minecraft.potion.PotionUtils; //导入方法依赖的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: onItemUseFinish

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
@Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entity) {
	EntityPlayer entityplayer = entity instanceof EntityPlayer ? (EntityPlayer) entity : null;
	if (!world.isRemote) {
		for (BrewEffect effect : BrewUtils.getBrewsFromStack(stack)) {
			BrewStorageHandler.addEntityBrewEffect(entity, effect);
		}

		for (PotionEffect potioneffect : PotionUtils.getEffectsFromStack(stack)) {
			entity.addPotionEffect(new PotionEffect(potioneffect));
		}
	}

	if (entityplayer == null || !entityplayer.capabilities.isCreativeMode) {
		stack.shrink(1);
		if (stack.getCount() <= 0) {
			return new ItemStack(Items.GLASS_BOTTLE);
		}

		if (entityplayer != null) {
			entityplayer.inventory.addItemStackToInventory(new ItemStack(Items.GLASS_BOTTLE));
		}
	}
	return stack;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:26,代码来源:ItemBrewDrink.java

示例3: apply

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Applies all effects in the bottle to the entity; if the bottle has both a potion and a spirit, both are applied.
 */
public void apply(ItemStack bottle, EntityLivingBase entity) {
	if (entity.world.isRemote) return;
	Spirit spirit = getSpirit(bottle);
	if (spirit!=null) {
		
		if (spirit.isAlcoholic()) {
			PotionEffect effect = entity.getActivePotionEffect(Thermionics.POTION_TIPSY);
			int curStrength = 0;
			if (effect!=null) {
				curStrength = effect.getAmplifier();
			}
			
			entity.removeActivePotionEffect(Thermionics.POTION_TIPSY);
			entity.addPotionEffect( new PotionEffect(Thermionics.POTION_TIPSY, 20*30, curStrength+1));
		}
	}
	
	for (PotionEffect potion : PotionUtils.getEffectsFromStack(bottle)) {
		if (potion.getPotion().isInstant()) {
               potion.getPotion().affectEntity(entity, entity, entity, potion.getAmplifier(), 1.0D);
           } else {
               entity.addPotionEffect(new PotionEffect(potion));
           }
	}
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:29,代码来源:ItemSpiritBottle.java

示例4: handleDrinkingPotionUpdate

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
protected void handleDrinkingPotionUpdate() {
	if (this.attackTimer-- <= 0) {
		this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F,
				0.8F + this.rand.nextFloat() * 0.4F);
		this.setAggressive(false);
		ItemStack itemstack = this.getHeldItemOffhand();
		this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);

		if (itemstack != null && itemstack.getItem() == Items.POTIONITEM) {
			List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);

			if (list != null) {
				for (PotionEffect potioneffect : list) {
					this.addPotionEffect(new PotionEffect(potioneffect));
				}
			}
		}

		this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(MODIFIER);
	}
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:22,代码来源:EntityMage.java

示例5: hasEffect

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
public static boolean hasEffect(ItemStack stack, Potion potion)
{
	for(PotionEffect effect : PotionUtils.getEffectsFromStack(stack))
		if(effect.getPotion() == potion)
			return true;
		
	return false;
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12-OF,代码行数:9,代码来源:InventoryUtils.java

示例6: onItemUseFinish

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
@Nullable
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
    EntityPlayer entityplayer = entityLiving instanceof EntityPlayer ? (EntityPlayer)entityLiving : null;

    if (entityplayer == null || !entityplayer.capabilities.isCreativeMode)
    {
        --stack.stackSize;
    }

    if (!worldIn.isRemote)
    {
        for (PotionEffect potioneffect : PotionUtils.getEffectsFromStack(stack))
        {
            entityLiving.addPotionEffect(new PotionEffect(potioneffect));
        }
    }

    if (entityplayer != null)
    {
        entityplayer.addStat(StatList.getObjectUseStats(this));
    }

    if (entityplayer == null || !entityplayer.capabilities.isCreativeMode)
    {
        if (stack.stackSize <= 0)
        {
            return new ItemStack(Items.GLASS_BOTTLE);
        }

        if (entityplayer != null)
        {
            entityplayer.inventory.addItemStackToInventory(new ItemStack(Items.GLASS_BOTTLE));
        }
    }

    return stack;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:43,代码来源:ItemPotion.java

示例7: onItemTooltip

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.BOTTOM)
public static void onItemTooltip(ItemTooltipEvent event) {
	if (enable_tooltip_debug) {
		ItemStack stack = event.getItemStack();
		Item item = stack.getItem();
		if (item instanceof ItemFood)
			event.getToolTip().add("Food: " + ((ItemFood) item).getHealAmount(stack) + ", " +
					((ItemFood) item).getSaturationModifier(stack));
		if (item instanceof IItemThirst)
			event.getToolTip().add("Thirst: " + ((IItemThirst) item).getThirst(stack) + ", " + 
					((IItemThirst) item).getHydration(stack));
		else if (IItemThirst.callback != null)
			IItemThirst.callback.accept(event);
		if (item instanceof ItemFood && ((ItemFood) item).potionId != null)
			event.getToolTip().add("Effect: " + ((ItemFood) item).potionId + ", " + ((ItemFood) item).potionEffectProbability);
		if (item instanceof IItemPotion && !((IItemPotion) item).getEffects(stack).isEmpty())
			event.getToolTip().add("Effect: " +
					Joiner.on("\n    ").appendTo(new StringBuilder("\n    "), ((IItemPotion) item).getEffects(stack)).toString());
		else if (IItemPotion.callback != null)
			IItemPotion.callback.accept(event);
		if (item instanceof ItemPotion) {
			List<PotionEffect> effects = PotionUtils.getEffectsFromStack(stack);
			if (!effects.isEmpty())
				event.getToolTip().add("Effect: " +
						Joiner.on("\n    ").appendTo(new StringBuilder(effects.size() > 1 ? "\n    " : ""), effects).toString());
		}
		for (int id : OreDictionary.getOreIDs(stack))
			event.getToolTip().add(OreDictionary.getOreName(id));
		event.getToolTip().add(item.getClass().getName());
		addNBTToTooltip(stack.serializeNBT(), event.getToolTip(), 1);
		if (GuiScreen.isCtrlKeyDown() && isKeyDown(KEY_C))
			GuiScreen.setClipboardString(GuiScreen.isShiftKeyDown() ? Joiner.on('\n').join(event.getToolTip()) :
				item.getRegistryName().toString());
	}
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:36,代码来源:RTooltip.java

示例8: update

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
@Override
public void update() {
  if (!isRunning()) {
    return;
  }
  this.shiftAllUp(1);
  if (this.timer == 0) {
    //wipe out the current effects
    this.effects = new ArrayList<PotionEffect>();
    // and try to consume a potion
    ItemStack s = this.getStackInSlot(0);
    List<PotionEffect> newEffects = PotionUtils.getEffectsFromStack(s);
    if (newEffects != null && newEffects.size() > 0) {
      effects = new ArrayList<PotionEffect>();
      if (this.isPotionValid(newEffects)) {
        //first read all potins
        for (PotionEffect eff : newEffects) {
          //cannot set the duration time so we must copy it
          effects.add(new PotionEffect(eff.getPotion(), POTION_TICKS, eff.getAmplifier(), true, false));
        }
        //then refil progress bar
        this.timer = MAX_POTION;
        //then consume the item, unless disabled
        if (doesConsumePotions) {
          this.setInventorySlotContents(0, ItemStack.EMPTY);
        }
      }
      // else at least one is not valid, do not eat the potoin
    }
  }
  else if (this.world.getTotalWorldTime() % 80L == 0L) {
    this.updateTimerIsZero();
    this.updateBeacon();
    world.addBlockEvent(this.pos, Blocks.BEACON, 1, 0);
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:37,代码来源:TileEntityBeaconPotion.java

示例9: cancelCertainPotionBrewing

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
@SubscribeEvent
public void cancelCertainPotionBrewing(PotionBrewEvent.Pre evt) {
    ItemStack modifier = evt.getItem(3);
    for (int i = 0; i < evt.getLength(); i++) {
        ItemStack stack = evt.getItem(i);
        if (!stack.isEmpty()) {
            ItemStack output = BrewingRecipeRegistry.getOutput(stack, modifier);
            if (output.getItem() instanceof ItemPotion) {
                if (!ConfigHandler.allowBrewingPotionSplash && output.getItem() instanceof ItemSplashPotion) {
                    evt.setCanceled(true);
                    return;
                }
                if (!ConfigHandler.allowBrewingPotionLingering && output.getItem() instanceof ItemLingeringPotion) {
                    evt.setCanceled(true);
                    return;
                }
                List<PotionEffect> potionEffects = PotionUtils.getEffectsFromStack(output);
                for (PotionEffect effect : potionEffects) {
                    if (effect.getAmplifier() > ConfigHandler.brewingPotionMaxLevel) {
                        evt.setCanceled(true);
                        return;
                    }
                    if (!ConfigHandler.allowBrewingPotionRegen && effect.getPotion() == MobEffects.REGENERATION) {
                        evt.setCanceled(true);
                        return;
                    }
                }
            }
        }
    }
}
 
开发者ID:liachmodded,项目名称:UHC-Reloaded,代码行数:32,代码来源:CancelPotionBrewing.java

示例10: getEffectsFromStack

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
public static List<PotionEffect> getEffectsFromStack(ItemStack stack)
{
	return PotionUtils.getEffectsFromStack(stack);
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12-OF,代码行数:5,代码来源:WPotion.java

示例11: onImpact

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(RayTraceResult result)
{
    if (!this.world.isRemote)
    {
        ItemStack itemstack = this.getPotion();
        PotionType potiontype = PotionUtils.getPotionFromItem(itemstack);
        List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);
        boolean flag = potiontype == PotionTypes.WATER && list.isEmpty();

        if (result.typeOfHit == RayTraceResult.Type.BLOCK && flag)
        {
            BlockPos blockpos = result.getBlockPos().offset(result.sideHit);
            this.extinguishFires(blockpos);

            for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
            {
                this.extinguishFires(blockpos.offset(enumfacing));
            }
        }

        if (flag)
        {
            this.func_190545_n();
        }
        else if (!list.isEmpty())
        {
            if (this.isLingering())
            {
                this.func_190542_a(itemstack, potiontype);
            }
            else
            {
                this.func_190543_a(result, list);
            }
        }

        int i = potiontype.hasInstantEffect() ? 2007 : 2002;
        this.world.playEvent(i, new BlockPos(this), PotionUtils.func_190932_c(itemstack));
        this.setDead();
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:45,代码来源:EntityPotion.java

示例12: onLivingUpdate

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    if (!this.world.isRemote)
    {
        if (this.isDrinkingPotion())
        {
            if (this.witchAttackTimer-- <= 0)
            {
                this.setAggressive(false);
                ItemStack itemstack = this.getHeldItemMainhand();
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.field_190927_a);

                if (itemstack.getItem() == Items.POTIONITEM)
                {
                    List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);

                    if (list != null)
                    {
                        for (PotionEffect potioneffect : list)
                        {
                            this.addPotionEffect(new PotionEffect(potioneffect));
                        }
                    }
                }

                this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(MODIFIER);
            }
        }
        else
        {
            PotionType potiontype = null;

            if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.WATER) && !this.isPotionActive(MobEffects.WATER_BREATHING))
            {
                potiontype = PotionTypes.WATER_BREATHING;
            }
            else if (this.rand.nextFloat() < 0.15F && (this.isBurning() || this.getLastDamageSource() != null && this.getLastDamageSource().isFireDamage()) && !this.isPotionActive(MobEffects.FIRE_RESISTANCE))
            {
                potiontype = PotionTypes.FIRE_RESISTANCE;
            }
            else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth())
            {
                potiontype = PotionTypes.HEALING;
            }
            else if (this.rand.nextFloat() < 0.5F && this.getAttackTarget() != null && !this.isPotionActive(MobEffects.SPEED) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
            {
                potiontype = PotionTypes.SWIFTNESS;
            }

            if (potiontype != null)
            {
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
                this.witchAttackTimer = this.getHeldItemMainhand().getMaxItemUseDuration();
                this.setAggressive(true);
                this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
                IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
                iattributeinstance.removeModifier(MODIFIER);
                iattributeinstance.applyModifier(MODIFIER);
            }
        }

        if (this.rand.nextFloat() < 7.5E-4F)
        {
            this.world.setEntityState(this, (byte)15);
        }
    }

    super.onLivingUpdate();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:74,代码来源:EntityWitch.java

示例13: onItemUseFinish

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
    EntityPlayer entityplayer = entityLiving instanceof EntityPlayer ? (EntityPlayer)entityLiving : null;

    if (entityplayer == null || !entityplayer.capabilities.isCreativeMode)
    {
        stack.func_190918_g(1);
    }

    if (!worldIn.isRemote)
    {
        for (PotionEffect potioneffect : PotionUtils.getEffectsFromStack(stack))
        {
            if (potioneffect.getPotion().isInstant())
            {
                potioneffect.getPotion().affectEntity(entityplayer, entityplayer, entityLiving, potioneffect.getAmplifier(), 1.0D);
            }
            else
            {
                entityLiving.addPotionEffect(new PotionEffect(potioneffect));
            }
        }
    }

    if (entityplayer != null)
    {
        entityplayer.addStat(StatList.getObjectUseStats(this));
    }

    if (entityplayer == null || !entityplayer.capabilities.isCreativeMode)
    {
        if (stack.func_190926_b())
        {
            return new ItemStack(Items.GLASS_BOTTLE);
        }

        if (entityplayer != null)
        {
            entityplayer.inventory.addItemStackToInventory(new ItemStack(Items.GLASS_BOTTLE));
        }
    }

    return stack;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:49,代码来源:ItemPotion.java

示例14: onLivingUpdate

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    if (!this.worldObj.isRemote)
    {
        if (this.isDrinkingPotion())
        {
            if (this.witchAttackTimer-- <= 0)
            {
                this.setAggressive(false);
                ItemStack itemstack = this.getHeldItemMainhand();
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, (ItemStack)null);

                if (itemstack != null && itemstack.getItem() == Items.POTIONITEM)
                {
                    List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);

                    if (list != null)
                    {
                        for (PotionEffect potioneffect : list)
                        {
                            this.addPotionEffect(new PotionEffect(potioneffect));
                        }
                    }
                }

                this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(MODIFIER);
            }
        }
        else
        {
            PotionType potiontype = null;

            if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.WATER) && !this.isPotionActive(MobEffects.WATER_BREATHING))
            {
                potiontype = PotionTypes.WATER_BREATHING;
            }
            else if (this.rand.nextFloat() < 0.15F && (this.isBurning() || this.getLastDamageSource() != null && this.getLastDamageSource().isFireDamage()) && !this.isPotionActive(MobEffects.FIRE_RESISTANCE))
            {
                potiontype = PotionTypes.FIRE_RESISTANCE;
            }
            else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth())
            {
                potiontype = PotionTypes.HEALING;
            }
            else if (this.rand.nextFloat() < 0.5F && this.getAttackTarget() != null && !this.isPotionActive(MobEffects.SPEED) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
            {
                potiontype = PotionTypes.SWIFTNESS;
            }

            if (potiontype != null)
            {
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
                this.witchAttackTimer = this.getHeldItemMainhand().getMaxItemUseDuration();
                this.setAggressive(true);
                this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
                IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
                iattributeinstance.removeModifier(MODIFIER);
                iattributeinstance.applyModifier(MODIFIER);
            }
        }

        if (this.rand.nextFloat() < 7.5E-4F)
        {
            this.worldObj.setEntityState(this, (byte)15);
        }
    }

    super.onLivingUpdate();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:74,代码来源:EntityWitch.java

示例15: onLivingUpdate

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    if (!this.worldObj.isRemote)
    {
        if (this.isDrinkingPotion())
        {
            if (this.witchAttackTimer-- <= 0)
            {
                this.setAggressive(false);
                ItemStack itemstack = this.getHeldItemMainhand();
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, (ItemStack)null);

                if (itemstack != null && itemstack.getItem() == Items.POTIONITEM)
                {
                    List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);

                    if (list != null)
                    {
                        for (PotionEffect potioneffect : list)
                        {
                            this.addPotionEffect(new PotionEffect(potioneffect));
                        }
                    }
                }

                this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(MODIFIER);
            }
        }
        else
        {
            PotionType potiontype = null;

            if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.WATER) && !this.isPotionActive(MobEffects.WATER_BREATHING))
            {
                potiontype = PotionTypes.WATER_BREATHING;
            }
            else if (this.rand.nextFloat() < 0.15F && (this.isBurning() || this.func_189748_bU() != null && this.func_189748_bU().isFireDamage()) && !this.isPotionActive(MobEffects.FIRE_RESISTANCE))
            {
                potiontype = PotionTypes.FIRE_RESISTANCE;
            }
            else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth())
            {
                potiontype = PotionTypes.HEALING;
            }
            else if (this.rand.nextFloat() < 0.5F && this.getAttackTarget() != null && !this.isPotionActive(MobEffects.SPEED) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
            {
                potiontype = PotionTypes.SWIFTNESS;
            }

            if (potiontype != null)
            {
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
                this.witchAttackTimer = this.getHeldItemMainhand().getMaxItemUseDuration();
                this.setAggressive(true);
                this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
                IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
                iattributeinstance.removeModifier(MODIFIER);
                iattributeinstance.applyModifier(MODIFIER);
            }
        }

        if (this.rand.nextFloat() < 7.5E-4F)
        {
            this.worldObj.setEntityState(this, (byte)15);
        }
    }

    super.onLivingUpdate();
}
 
开发者ID:BlazeAxtrius,项目名称:ExpandedRailsMod,代码行数:74,代码来源:EntityWitch.java


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