use of net.minecraft.entity.projectile.EntityPotion in project Cavern2 by kegare.
the class EntityCavenicWitch method attackEntityWithRangedAttack.
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
int count = getAttackPotionCount();
for (int i = 0; i < count; ++i) {
if (!isDrinkingPotion()) {
double d0 = target.posY + target.getEyeHeight() - 1.100000023841858D;
double d1 = target.posX + target.motionX - posX;
double d2 = d0 - posY;
double d3 = target.posZ + target.motionZ - posZ;
float f = MathHelper.sqrt(d1 * d1 + d3 * d3);
PotionType potion = PotionTypes.HARMING;
if (rand.nextFloat() < (target.getHealth() >= 8.0F ? 0.5F : 0.3F)) {
if (target.isEntityUndead()) {
potion = PotionTypes.HEALING;
} else {
potion = PotionTypes.POISON;
}
} else if (rand.nextFloat() < 0.25F) {
potion = PotionTypes.WEAKNESS;
} else if (rand.nextFloat() < 0.2F) {
potion = PotionTypes.SLOWNESS;
}
EntityPotion entity = new EntityPotion(world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potion));
entity.rotationPitch -= -20.0F;
entity.shoot(d1, d2 + f * 0.2F, d3, 0.75F, 8.0F);
world.playSound(null, posX, posY, posZ, SoundEvents.ENTITY_WITCH_THROW, getSoundCategory(), 1.0F, 0.8F + rand.nextFloat() * 0.4F);
world.spawnEntity(entity);
}
}
}
use of net.minecraft.entity.projectile.EntityPotion in project takumicraft by TNTModders.
the class EntityWitchCreeper method attackEntityWithRangedAttack.
/**
* Attack the specified entity using a ranged attack.
*/
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
if (!this.isDrinkingPotion()) {
double d0 = target.posY + target.getEyeHeight() - 1.100000023841858D;
double d1 = target.posX + target.motionX - this.posX;
double d2 = d0 - this.posY;
double d3 = target.posZ + target.motionZ - this.posZ;
float f = MathHelper.sqrt(d1 * d1 + d3 * d3);
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 EntityTakumiPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
entitypotion.rotationPitch -= -15.0F;
entitypotion.setThrowableHeading(d1, d2 + f * 0.2F, d3, 0.75F, 8.0F);
this.world.playSound(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);
}
}
use of net.minecraft.entity.projectile.EntityPotion in project BloodMagic by WayofTime.
the class TileMimic method update.
@Override
public void update() {
if (getWorld().isRemote) {
return;
}
internalCounter++;
if (internalCounter % potionSpawnInterval == 0 && this.getBlockMetadata() == BlockMimic.sentientMimicMeta) {
ItemStack potionStack = this.getStackInSlot(1);
if (!potionStack.isEmpty()) {
AxisAlignedBB bb = new AxisAlignedBB(this.getPos()).expand(playerCheckRadius, playerCheckRadius, playerCheckRadius);
List<EntityPlayer> playerList = getWorld().getEntitiesWithinAABB(EntityPlayer.class, bb);
for (EntityPlayer player : playerList) {
if (!player.capabilities.isCreativeMode) {
double posX = this.pos.getX() + 0.5 + (2 * getWorld().rand.nextDouble() - 1) * potionSpawnRadius;
double posY = this.pos.getY() + 0.5 + (2 * getWorld().rand.nextDouble() - 1) * potionSpawnRadius;
double posZ = this.pos.getZ() + 0.5 + (2 * getWorld().rand.nextDouble() - 1) * potionSpawnRadius;
ItemStack newStack = new ItemStack(potionStack.getItem() == RegistrarBloodMagicItems.POTION_FLASK ? Items.SPLASH_POTION : potionStack.getItem());
newStack.setTagCompound(potionStack.getTagCompound());
EntityPotion potionEntity = new EntityPotion(getWorld(), posX, posY, posZ, newStack);
getWorld().spawnEntity(potionEntity);
break;
}
}
}
}
if (this.getBlockMetadata() == BlockMimic.sentientMimicMeta && getWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(mimicedTile instanceof IInventory)) {
AxisAlignedBB bb = new AxisAlignedBB(this.getPos()).expand(playerCheckRadius, playerCheckRadius, playerCheckRadius);
List<EntityPlayer> playerList = getWorld().getEntitiesWithinAABB(EntityPlayer.class, bb);
for (EntityPlayer player : playerList) {
if (!player.capabilities.isCreativeMode && Utils.canEntitySeeBlock(getWorld(), player, getPos())) {
spawnMimicEntity(player);
break;
}
}
}
}
use of net.minecraft.entity.projectile.EntityPotion in project GregTech by GregTechCE.
the class FieldProjectorEventHandler method isHostileProjectile.
private static Pair<Boolean, Entity> isHostileProjectile(Entity entity, Entity owner) {
if (entity instanceof EntityFireball) {
EntityLivingBase shooter = ((EntityFireball) entity).shootingEntity;
return Pair.of(!owner.isEntityEqual(shooter), shooter);
} else if (entity instanceof EntityArrow) {
Entity shooter = ((EntityArrow) entity).shootingEntity;
return Pair.of(!owner.isEntityEqual(shooter), shooter);
} else if (entity instanceof EntityPotion) {
EntityLivingBase shooter = ((EntityPotion) entity).getThrower();
ItemStack potionStack = ((EntityPotion) entity).getPotion();
List<PotionEffect> effectList = PotionUtils.getEffectsFromStack(potionStack);
boolean hasBadEffects = effectList.stream().anyMatch(it -> it.getPotion().isBadEffect());
// potions without bad effects are not hostile, so do not touch them
return Pair.of(!owner.isEntityEqual(shooter) && hasBadEffects, shooter);
} else if (entity instanceof EntityThrowable) {
EntityLivingBase shooter = ((EntityThrowable) entity).getThrower();
return Pair.of(!owner.isEntityEqual(shooter), shooter);
} else if (entity instanceof IThrowableEntity) {
Entity shooter = ((IThrowableEntity) entity).getThrower();
return Pair.of(!owner.isEntityEqual(shooter), shooter);
} else if (entity instanceof IProjectile) {
// unknown projectiles are always hostile
return Pair.of(true, null);
}
return Pair.of(false, null);
}
use of net.minecraft.entity.projectile.EntityPotion in project PneumaticCraft by MineMaarten.
the class TileEntityAirCannon method getPayloadEntity.
// warning: no null-check for inventory slot 0
private Entity getPayloadEntity() {
if (getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE, getUpgradeSlots()) > 0) {
Item item = inventory[0].getItem();
if (item == Item.getItemFromBlock(Blocks.tnt)) {
EntityTNTPrimed tnt = new EntityTNTPrimed(worldObj);
tnt.fuse = 80;
return tnt;
} else if (item == Items.experience_bottle)
return new EntityExpBottle(worldObj);
else if (item == Items.potionitem) {
EntityPotion potion = new EntityPotion(worldObj);
potion.setPotionDamage(inventory[0].getItemDamage());
return potion;
} else if (item == Items.arrow)
return new EntityArrow(worldObj);
else if (item == Items.egg)
return new EntityEgg(worldObj);
else // EntitySmallFireball(worldObj);
if (item == Items.snowball)
return new EntitySnowball(worldObj);
else if (item == Items.spawn_egg)
return ItemMonsterPlacer.spawnCreature(worldObj, inventory[0].getItemDamage(), 0, 0, 0);
else if (item == Items.minecart)
return new EntityMinecartEmpty(worldObj);
else if (item == Items.chest_minecart)
return new EntityMinecartChest(worldObj);
else if (item == Items.furnace_minecart)
return new EntityMinecartFurnace(worldObj);
else if (item == Items.hopper_minecart)
return new EntityMinecartHopper(worldObj);
else if (item == Items.tnt_minecart)
return new EntityMinecartTNT(worldObj);
else if (item == Items.boat)
return new EntityBoat(worldObj);
}
EntityItem item = new EntityItem(worldObj);
item.setEntityItemStack(inventory[0].copy());
// 1200 ticks left to live, = 60s.
item.age = 4800;
// add
item.lifespan += Math.min(getUpgrades(ItemMachineUpgrade.UPGRADE_ITEM_LIFE, getUpgradeSlots()) * 600, 4800);
// min.
return item;
}
Aggregations