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


Java PotionTypes.SWIFTNESS属性代码示例

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


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

示例1: handleAttackLogicUpdate

protected void handleAttackLogicUpdate() {
	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.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.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.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
		this.attackTimer = 10;
		this.setAggressive(true);
		IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
		iattributeinstance.removeModifier(MODIFIER);
		iattributeinstance.applyModifier(MODIFIER);
	}
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:25,代码来源:EntityMage.java

示例2: onLivingUpdate

/**
 * 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,代码行数:73,代码来源:EntityWitch.java

示例3: onLivingUpdate

/**
 * 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,代码行数:73,代码来源:EntityWitch.java

示例4: onLivingUpdate

/**
 * 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,代码行数:73,代码来源:EntityWitch.java


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