本文整理汇总了Java中net.minecraft.init.PotionTypes.WATER_BREATHING属性的典型用法代码示例。如果您正苦于以下问题:Java PotionTypes.WATER_BREATHING属性的具体用法?Java PotionTypes.WATER_BREATHING怎么用?Java PotionTypes.WATER_BREATHING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.minecraft.init.PotionTypes
的用法示例。
在下文中一共展示了PotionTypes.WATER_BREATHING属性的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);
}
}
示例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();
}
示例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();
}
示例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();
}