net.minecraft.entity.projectile.EntityPotion Java Examples
The following examples show how to use
net.minecraft.entity.projectile.EntityPotion.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityMage.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
protected void attackWithPotion(EntityLivingBase target) { double targetY = target.posY + (double) target.getEyeHeight() - 1.100000023841858D; double targetX = target.posX + target.motionX - this.posX; double d2 = targetY - this.posY; double targetZ = target.posZ + target.motionZ - this.posZ; float f = MathHelper.sqrt(targetX * targetX + targetZ * targetZ); PotionType potiontype = PotionTypes.HARMING; if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS)) { potiontype = PotionTypes.SLOWNESS; } else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON)) { potiontype = PotionTypes.POISON; } else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F) { potiontype = PotionTypes.WEAKNESS; } EntityPotion entitypotion = new EntityPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype)); entitypotion.rotationPitch -= -20.0F; entitypotion.shoot(targetX, d2 + (double) (f * 0.2F), targetZ, 0.75F, 8.0F); this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F); this.world.spawnEntity(entitypotion); }
Example #2
Source File: EntityWitherWitch.java From EnderZoo with Creative Commons Zero v1.0 Universal | 6 votes |
@Override public void attackEntityWithRangedAttack(EntityLivingBase entity, float rangeRatio) { //the EntityPotion class validates if this potion is throwable, and if not it logs error "ThrownPotion entity {} has no item?! if(attackTimer <= 0 && getHeldItem(EnumHand.MAIN_HAND).getItem() == Items.SPLASH_POTION && !isHealing) { attackedWithPotion = entity; double x = entity.posX + entity.motionX - posX; double y = entity.posY + entity.getEyeHeight() - 1.100000023841858D - posY; double z = entity.posZ + entity.motionZ - posZ; float groundDistance = MathHelper.sqrt(x * x + z * z); ItemStack potion = getHeldItem(EnumHand.MAIN_HAND); attackTimer = getHeldItem(EnumHand.MAIN_HAND).getMaxItemUseDuration(); EntityPotion entitypotion = new EntityPotion(world, this, potion); entitypotion.rotationPitch -= -20.0F; entitypotion.setThrowableHeading(x, y + groundDistance * 0.2F, z, 0.75F, 8.0F); world.spawnEntity(entitypotion); setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY); } }
Example #3
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 5 votes |
/** * PotionSplashEvent */ public static PotionSplashEvent callPotionSplashEvent(EntityPotion potion, Map<LivingEntity, Double> affectedEntities) { ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity(); PotionSplashEvent event = new PotionSplashEvent(thrownPotion, affectedEntities); Bukkit.getPluginManager().callEvent(event); return event; }
Example #4
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 5 votes |
public static LingeringPotionSplashEvent callLingeringPotionSplashEvent(EntityPotion potion, EntityAreaEffectCloud cloud) { ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity(); AreaEffectCloud effectCloud = (AreaEffectCloud) cloud.getBukkitEntity(); LingeringPotionSplashEvent event = new LingeringPotionSplashEvent(thrownPotion, effectCloud); Bukkit.getPluginManager().callEvent(event); return event; }
Example #5
Source File: EntityWitherWitch.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
protected void throwHealthPotion() { ItemStack potion = getHeldItem(EnumHand.MAIN_HAND); //if its not a splash or lingering potion it will be an error EntityPotion entitypotion = new EntityPotion(world, this, potion); Vec3d lookVec = getLookVec(); entitypotion.setThrowableHeading(lookVec.x * 0.5, -1, lookVec.z * 0.5, 0.75F, 1.0F); world.spawnEntity(entitypotion); setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY); healTimer = 80; }
Example #6
Source File: CraftThrownPotion.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CraftThrownPotion(CraftServer server, EntityPotion entity) { super(server, entity); }
Example #7
Source File: CraftThrownPotion.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public EntityPotion getHandle() { return (EntityPotion) entity; }
Example #8
Source File: CraftSplashPotion.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CraftSplashPotion(CraftServer server, EntityPotion entity) { super(server, entity); }
Example #9
Source File: CraftSplashPotion.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public EntityPotion getHandle() { return (EntityPotion) entity; }
Example #10
Source File: CraftLingeringPotion.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CraftLingeringPotion(CraftServer server, EntityPotion entity) { super(server, entity); }
Example #11
Source File: CraftLingeringPotion.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public EntityPotion getHandle() { return (EntityPotion) entity; }
Example #12
Source File: DispenserBehaviorPotionProjectile.java From Artifacts with MIT License | 4 votes |
/** * Return the projectile entity spawned by this dispense behavior. */ protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition) { return new EntityPotion(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ(), this.potionItemStack.copy()); }