@SuppressWarnings("unchecked")
 protected Entity areaOfEffect() {
   List<EntityLivingBase> list =
       worldObj.getEntitiesWithinAABB(
           EntityLivingBase.class,
           AxisAlignedBB.getBoundingBox(
                   attacker.boundingBox.minX,
                   attacker.boundingBox.minY,
                   attacker.boundingBox.minZ,
                   attacker.boundingBox.maxX,
                   attacker.boundingBox.maxY,
                   attacker.boundingBox.maxZ)
               .expand(8D, 1D, 8D));
   for (int i = 0; i < list.size(); i++) {
     Entity entity = list.get(i);
     if (entity != null)
       if (entity instanceof EntityLivingBase
           && !(entity instanceof EntityTarantulaMiniboss)
           && !(entity instanceof EntityTarantula)
           && !(entity instanceof EntityTarantulaBaby)) {
         float Knockback = 2;
         entity.attackEntityFrom(DamageSource.causeMobDamage(attacker), 8.0F);
         entity.addVelocity(
             -MathHelper.sin(attacker.rotationYaw * 3.141593F / 180.0F) * Knockback * 0.5F,
             0.4D,
             MathHelper.cos(attacker.rotationYaw * 3.141593F / 180.0F) * Knockback * 0.5F);
         attacker.playSound("erebus:blamsound", 1.5F, 1.0F);
         ((EntityLivingBase) entity)
             .addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 8 * 20, 0));
         ((EntityLivingBase) entity)
             .addPotionEffect(new PotionEffect(Potion.blindness.id, 5 * 20, 0));
       }
   }
   return null;
 }
Ejemplo n.º 2
0
 /** Drops the entity's currently held item into the world */
 public static void dropHeldItem(EntityLivingBase entity) {
   if (!entity.worldObj.isRemote && entity.getHeldItem() != null) {
     EntityItem drop =
         new EntityItem(
             entity.worldObj,
             entity.posX,
             entity.posY - 0.30000001192092896D + (double) entity.getEyeHeight(),
             entity.posZ,
             entity.getHeldItem().copy());
     float f = 0.3F;
     float f1 = entity.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F;
     drop.motionX =
         (double)
             (-MathHelper.sin(entity.rotationYaw / 180.0F * (float) Math.PI)
                 * MathHelper.cos(entity.rotationPitch / 180.0F * (float) Math.PI)
                 * f);
     drop.motionZ =
         (double)
             (MathHelper.cos(entity.rotationYaw / 180.0F * (float) Math.PI)
                 * MathHelper.cos(entity.rotationPitch / 180.0F * (float) Math.PI)
                 * f);
     drop.motionY =
         (double) (-MathHelper.sin(entity.rotationPitch / 180.0F * (float) Math.PI) * f + 0.1F);
     f = 0.02F * entity.worldObj.rand.nextFloat();
     drop.motionX += Math.cos((double) f1) * (double) f;
     drop.motionY +=
         (double) ((entity.worldObj.rand.nextFloat() - entity.worldObj.rand.nextFloat()) * 0.1F);
     drop.motionZ += Math.sin((double) f1) * (double) f;
     drop.delayBeforeCanPickup = 40;
     entity.worldObj.spawnEntityInWorld(drop);
     entity.setCurrentItemOrArmor(0, (ItemStack) null);
   }
 }
  @Override
  public IMessage onMessage(PacketKurosawaAttack message, MessageContext ctx) {
    EntityPlayer player = ctx.getServerHandler().playerEntity;
    Kurosawa item = (Kurosawa) player.getHeldItem().getItem();

    if (!item.getCooldown()) {
      World world = player.worldObj;
      EntityLivingBase target = (EntityLivingBase) world.getEntityByID(message.targetID);
      Vec3 targetPos = target.getPositionVector();
      Vec3 attackerPos = player.getPositionVector();

      Vec3 distance = targetPos.subtractReverse(attackerPos).normalize();
      distance = new Vec3(distance.xCoord * 3, distance.yCoord * 3, distance.zCoord * 3);

      player.setPositionAndRotation(
          target.posX - distance.xCoord,
          target.posY - distance.yCoord,
          target.posZ - distance.zCoord,
          player.rotationYaw + 180,
          player.rotationPitch);
      player.setRotationYawHead(player.rotationYawHead + 180);
      player.cameraPitch += 180;
      player.setPositionAndUpdate(
          target.posX - distance.xCoord,
          target.posY - distance.yCoord,
          target.posZ - distance.zCoord);
      target.attackEntityFrom(DamageSource.causePlayerDamage(player), 44);
      item.setCooldown();
    }
    return null;
  }
 @SuppressWarnings("unchecked")
 private void pop() {
   List<EntityLivingBase> ents =
       worldObj.getEntitiesWithinAABB(
           EntityLivingBase.class,
           AxisAlignedBB.getBoundingBox(
               xCoord + 1.0,
               yCoord + 1.0,
               zCoord + 1.0,
               xCoord + xLength - 1,
               yCoord + 3.0,
               zCoord + zLength - 1));
   for (EntityLivingBase ent : ents) {
     if (ent instanceof EntityPlayer) {
       EntityPlayerMP player = (EntityPlayerMP) ent;
       if (!player.capabilities.isCreativeMode) {
         player.playerNetServerHandler.sendPacket(
             new S12PacketEntityVelocity(
                 player.getEntityId(), 0.0, MathHelper.randomDoubleInRange(0.5, 2), 0.0));
       }
     } else {
       if (!ent.isDead) {
         ent.addVelocity(0.0, MathHelper.randomDoubleInRange(0.5, 2), 0);
       }
     }
   }
 }
 /** Applies permanent buffs / debuffs to vanilla mobs */
 private void initBuffs(EntityLivingBase entity) {
   if (!ZSSEntityInfo.get(entity).getActiveBuffsMap().isEmpty()) {
     return;
   }
   // double damage from cold effects, highly resistant to fire damage
   if (entity.isImmuneToFire()) {
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_FIRE, Integer.MAX_VALUE, 75);
     ZSSEntityInfo.get(entity).applyBuff(Buff.WEAKNESS_COLD, Integer.MAX_VALUE, 100);
   }
   if (entity.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) {
     if (!entity.isImmuneToFire()) {
       ZSSEntityInfo.get(entity).applyBuff(Buff.WEAKNESS_FIRE, Integer.MAX_VALUE, 50);
     }
     ZSSEntityInfo.get(entity).applyBuff(Buff.WEAKNESS_HOLY, Integer.MAX_VALUE, 300);
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_COLD, Integer.MAX_VALUE, 50);
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_STUN, Integer.MAX_VALUE, 50);
   }
   if (entity instanceof EntityGolem) {
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_COLD, Integer.MAX_VALUE, 100);
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_STUN, Integer.MAX_VALUE, 100);
   }
   if (entity instanceof EntityWitch) {
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_MAGIC, Integer.MAX_VALUE, 75);
   }
   if (entity instanceof EntityWither) {
     ZSSEntityInfo.get(entity).removeBuff(Buff.WEAKNESS_COLD);
   }
 }
Ejemplo n.º 6
0
  @Override
  protected void spawnProjectiles() {
    if (!TragicConfig.getBoolean("jabbaProjectiles")) return;
    EntityLivingBase entity = this.getAttackTarget();
    double d0 = entity.posX - this.posX;
    double d1 =
        entity.getEntityBoundingBox().minY
            + entity.height / 2.0F
            - (this.posY + this.height / 2.0F);
    double d2 = entity.posZ - this.posZ;

    float f1 = MathHelper.sqrt_float(this.getDistanceToEntity(entity)) * 0.5F;

    for (byte i = 0; i < 5; ++i) {
      EntityPoisonBarb poisonbarb =
          new EntityPoisonBarb(
              this.worldObj,
              this,
              d0 + this.rand.nextGaussian() * f1,
              d1,
              d2 + this.rand.nextGaussian() * f1);
      poisonbarb.posX = this.posX + d0 * 0.115D;
      poisonbarb.posY = this.posY + 0.435D;
      poisonbarb.posZ = this.posZ + d0 * 0.115D;
      this.worldObj.spawnEntityInWorld(poisonbarb);

      this.setAngerTicks(this.getAngerTicks() - 50);
    }
  }
Ejemplo n.º 7
0
  public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLiving, float par2) {
    if (!this.getAggressive()) {
      EntityPotion var2 = new EntityPotion(this.worldObj, this, 32732);
      var2.rotationPitch -= -20.0F;
      double var3 = par1EntityLiving.posX + par1EntityLiving.motionX - this.posX;
      double var5 =
          par1EntityLiving.posY
              + (double) par1EntityLiving.getEyeHeight()
              - 1.100000023841858D
              - this.posY;
      double var7 = par1EntityLiving.posZ + par1EntityLiving.motionZ - this.posZ;
      float var9 = MathHelper.sqrt_double(var3 * var3 + var7 * var7);
      if (var9 >= 8.0F && !par1EntityLiving.isPotionActive(Potion.moveSlowdown)) {
        var2.setPotionDamage(32698);
      } else if (par1EntityLiving.getHealth() >= 8.0F
          && !par1EntityLiving.isPotionActive(Potion.poison)) {
        var2.setPotionDamage(32660);
      } else if (var9 <= 3.0F
          && !par1EntityLiving.isPotionActive(Potion.weakness)
          && this.rand.nextFloat() < 0.25F) {
        var2.setPotionDamage(32696);
      }

      var2.setThrowableHeading(var3, var5 + (double) (var9 * 0.2F), var7, 0.75F, 8.0F);
      this.worldObj.spawnEntityInWorld(var2);
    }
  }
Ejemplo n.º 8
0
 @Override
 protected boolean isValidTarget(Entity ent) {
   if (ent instanceof TargetEntity) return ((TargetEntity) ent).shouldTarget(this, placerUUID);
   if (!(ent instanceof EntityLivingBase)) return false;
   EntityLivingBase elb = (EntityLivingBase) ent;
   if (elb.isDead || elb.getHealth() <= 0) return false;
   if (ent.onGround || ent.isInWater() || ent.isInsideOfMaterial(Material.lava)) return false;
   if (elb instanceof EntityFlying && ReikaEntityHelper.isHostile(elb)) {
     return ReikaMathLibrary.py3d(
             ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
         > 2;
   }
   if (ent instanceof EntityBlaze || ent instanceof EntityWither || ent instanceof EntityDragon) {
     return ReikaMathLibrary.py3d(
             ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
         > 2;
   }
   if (ent instanceof FlyingMob) {
     FlyingMob fm = (FlyingMob) ent;
     return fm.isCurrentlyFlying()
         && fm.isHostile()
         && ReikaMathLibrary.py3d(
                 ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
             > 2;
   }
   if (InterfaceCache.BCROBOT.instanceOf(ent)) {
     return true;
   }
   return false;
 }
  private void updateNearbyEntities() {
    ArrayList<EntityLivingBase> toRemove = new ArrayList<EntityLivingBase>();
    List<EntityLivingBase> nearbyEntities =
        this.worldObj.getEntitiesWithinAABB(
            EntityLivingBase.class,
            AxisAlignedBB.getBoundingBox(
                this.xCoord - 10,
                this.yCoord,
                this.zCoord - 10,
                this.xCoord + 10,
                this.yCoord + 4,
                this.zCoord + 10));
    for (EntityLivingBase entity : nearbyEntities) {
      if (entity.isEntityInvulnerable()
          || entity instanceof IBossDisplayData
          || entity instanceof EntityDarkling
          || entity instanceof EntityPlayer
          || entity instanceof EntityAirSled
          || entity instanceof EntityWinterGuardianArm
          || entity instanceof EntityThrownSickle
          || entity instanceof EntityFlicker
          || entity instanceof EntityShadowHelper) continue;
      if (!cachedEntities.contains(entity)) cachedEntities.add(entity);
    }

    ticksSinceLastEntityScan = 0;
  }
Ejemplo n.º 10
0
 @SubscribeEvent(priority = EventPriority.LOWEST)
 public void disallowDespawn(AllowDespawn ad) {
   EntityLivingBase e = ad.entityLiving;
   PotionEffect pe = e.getActivePotionEffect(RotaryCraft.freeze);
   if (pe == null) return;
   ad.setResult(Result.DENY);
 }
Ejemplo n.º 11
0
  public EntityMeteorChunk(
      World world,
      EntityLivingBase shootingEntity,
      EntityLivingBase target,
      float speed,
      float randMod) {
    super(world);
    this.renderDistanceWeight = 10.0D;
    this.shootingEntity = shootingEntity;

    if (shootingEntity instanceof EntityPlayer) {
      this.canBePickedUp = 1;
    }

    this.posY = shootingEntity.posY + shootingEntity.getEyeHeight() - 0.10000000149011612D;
    double d0 = target.posX - shootingEntity.posX;
    double d1 = target.getEntityBoundingBox().minY + target.height / 3.0F - this.posY;
    double d2 = target.posZ - shootingEntity.posZ;
    double d3 = MathHelper.sqrt_double(d0 * d0 + d2 * d2);

    if (d3 >= 1.0E-7D) {
      float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
      float f3 = (float) -(Math.atan2(d1, d3) * 180.0D / Math.PI);
      double d4 = d0 / d3;
      double d5 = d2 / d3;
      this.setLocationAndAngles(
          shootingEntity.posX + d4, this.posY, shootingEntity.posZ + d5, f2, f3);
      float f4 = (float) d3 * 0.2F;
      this.setThrowableHeading(d0, d1 + f4, d2, speed, randMod);
    }
  }
Ejemplo n.º 12
0
  private void doBolt(EntityBallLightning other) {
    Vec3 vec = ReikaVectorHelper.getVec2Pt(posX, posY, posZ, other.posX, other.posY, other.posZ);
    // EntityGluon g = new EntityGluon(this, other);
    // worldObj.spawnEntityInWorld(g);
    targetColor = other.color;

    ReikaPacketHelper.sendDataPacket(
        ChromatiCraft.packetChannel,
        ChromaPackets.GLUON.ordinal(),
        new DimensionTarget(worldObj),
        this.getEntityId(),
        other.getEntityId());

    double len = vec.lengthVector();
    for (double i = 0; i < len; i += 0.0625) {
      double dx = posX - i * vec.xCoord / len;
      double dy = posY - i * vec.yCoord / len;
      double dz = posZ - i * vec.zCoord / len;
      if (worldObj.isRemote) this.gluonParticles(other, dx, dy, dz, (float) (i / len));

      if (ChromaOptions.HOSTILEFOREST.getState()) {
        AxisAlignedBB box =
            AxisAlignedBB.getBoundingBox(dx, dy, dz, dx, dy, dz).expand(0.5, 0.5, 0.5);
        List<EntityLivingBase> elb = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box);
        for (EntityLivingBase e : elb) {
          e.attackEntityFrom(DamageSource.generic, isPylonSpawn ? 4 : 1);
        }
      }
    }
  }
Ejemplo n.º 13
0
  @Override
  public boolean attackEntityAsMob(Entity par1Entity) {
    if (this.worldObj.isRemote) return false;

    boolean result = super.attackEntityAsMob(par1Entity);

    EnumDifficulty dif = this.worldObj.getDifficulty();
    int x = 2;

    if (dif == EnumDifficulty.NORMAL) {
      x = 3;
    } else if (dif == EnumDifficulty.HARD) {
      x = 4;
    }

    if (result) {
      if (this.isSpinning()) this.setSpinTicks(0);
      if (this.getFlutterTicks() > 0) this.setFlutterTicks(0);

      if (par1Entity instanceof EntityLivingBase) {
        if (rand.nextInt(16 / x) == 0)
          ((EntityLivingBase) par1Entity)
              .addPotionEffect(
                  new PotionEffect(
                      Potion.moveSlowdown.id, 100 + rand.nextInt(140), 1 + rand.nextInt(2)));
        if (rand.nextInt(32 / x) == 0)
          ((EntityLivingBase) par1Entity)
              .addPotionEffect(
                  new PotionEffect(
                      Potion.digSlowdown.id, 100 + rand.nextInt(140), 1 + rand.nextInt(2)));
      }
    }

    return result;
  }
  /** Returns whether the EntityAIBase should begin execution. */
  @SuppressWarnings("unchecked")
  @Override
  public boolean shouldExecute() {
    EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();

    if (entitylivingbase == null) {
      return false;
    } else if (!entitylivingbase.isEntityAlive()) {
      return false;
    } else if (this.classTarget != null
        && !this.classTarget.isAssignableFrom(entitylivingbase.getClass())) {
      return false;
    } else if (this.worldObj.isDaytime()) {
      return false;
    } else {
      if (--this.field_75445_i <= 0) {
        this.entityPathEntity =
            this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
        this.field_75445_i = 4 + this.attacker.getRNG().nextInt(7);
        return this.entityPathEntity != null;
      } else {
        return true;
      }
    }
  }
Ejemplo n.º 15
0
  /** Damages the item in the ItemStack */
  public void damageItem(int par1, EntityLivingBase par2EntityLivingBase) {
    if (!(par2EntityLivingBase instanceof EntityPlayer)
        || !((EntityPlayer) par2EntityLivingBase).capabilities.isCreativeMode) {
      if (this.isItemStackDamageable()) {
        if (this.attemptDamageItem(par1, par2EntityLivingBase.getRNG())) {
          par2EntityLivingBase.renderBrokenItemStack(this);
          --this.stackSize;

          if (par2EntityLivingBase instanceof EntityPlayer) {
            EntityPlayer entityplayer = (EntityPlayer) par2EntityLivingBase;
            entityplayer.addStat(
                StatList.objectBreakStats[Item.getIdFromItem(this.field_151002_e)], 1);

            if (this.stackSize == 0 && this.getItem() instanceof ItemBow) {
              entityplayer.destroyCurrentEquippedItem();
            }
          }

          if (this.stackSize < 0) {
            this.stackSize = 0;
          }

          this.itemDamage = 0;
        }
      }
    }
  }
  /** Performs a ranged attack according to the AI's rangedAttackID. */
  private void doRangedAttack() {
    // 43% chance to "miss"
    int chanceToMiss = entityHost.isPotionActive(Potion.moveSpeed) ? 10 : 43;
    if (worldObj.rand.nextInt(100) < chanceToMiss) {
      AMCore.instance.proxy.particleManager.BoltFromPointToPoint(
          worldObj,
          entityHost.posX,
          entityHost.posY + entityHost.getEyeHeight(),
          entityHost.posZ,
          attackTarget.posX + worldObj.rand.nextFloat() - 0.5f,
          attackTarget.posY + attackTarget.getEyeHeight() + worldObj.rand.nextFloat() - 0.5f,
          attackTarget.posZ + worldObj.rand.nextFloat() - 0.5f,
          2,
          -1);
    } else {
      AMCore.instance.proxy.particleManager.BoltFromEntityToEntity(
          worldObj, entityHost, entityHost, attackTarget, this.damage, 2, -1);
      float manaDrained =
          this.manaDrainedPerCasterLevel * ExtendedProperties.For(attackTarget).getMagicLevel();
      ExtendedProperties.For(attackTarget)
          .setCurrentMana(ExtendedProperties.For(attackTarget).getCurrentMana() - (manaDrained));
      ExtendedProperties.For(attackTarget).forceSync();

      attackTarget.attackEntityFrom(
          DamageSource.causeIndirectMagicDamage(entityHost, entityHost), this.damage);

      if (manaDrained > 100) {
        entityHost.heal(1);
        if (entityHost.worldObj.difficultySetting == EnumDifficulty.HARD) {
          attackTarget.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 40, 1, true));
          entityHost.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 40, 3, true));
        }
      }
    }
  }
Ejemplo n.º 17
0
 public boolean tryFireMinigun(EntityLivingBase target) {
   boolean lastShotOfAmmo = false;
   if (ammo != null && (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);
       if (pressurizable != null) pressurizable.addAir(stack, -airUsage);
       if (target != null) {
         ItemStack potion = ItemGunAmmo.getPotion(ammo);
         if (potion != null) {
           if (rand.nextInt(20) == 0) {
             List<PotionEffect> effects = Items.potionitem.getEffects(potion);
             if (effects != null) {
               for (PotionEffect effect : effects) {
                 target.addPotionEffect(new PotionEffect(effect));
               }
             }
           }
         } else {
           target.attackEntityFrom(DamageSource.causePlayerDamage(player), 4);
         }
       }
     }
   }
   return lastShotOfAmmo;
 }
  protected void onImpact(MovingObjectPosition par1MovingObjectPosition) {
    if (par1MovingObjectPosition.entityHit != null) {
      int i0 = StuffWorthThrowingConfig.rockMinDamage;
      int i1 = StuffWorthThrowingConfig.rockMaxDamage - i0 + 1;
      int i2 = this.rand.nextInt(i1) + i0 + StuffWorthThrowingConfig.brokenBrickStronger;
      int i3 = StuffWorthThrowingConfig.dizzyMultiplier;
      int i4 = StuffWorthThrowingConfig.debuffMultiplier;

      if (!this.worldObj.isRemote && StuffWorthThrowingConfig.itemStatusEffects) {
        EntityLivingBase entityLiving = (EntityLivingBase) par1MovingObjectPosition.entityHit;

        entityLiving.setFire(i2 * i4 / 20);
        if (StuffWorthThrowingConfig.dizzyBricks) {
          entityLiving.addPotionEffect(new PotionEffect(Potion.confusion.getId(), i2 * i3, 0));
        }
      }

      par1MovingObjectPosition.entityHit.attackEntityFrom(
          DamageSource.causeThrownDamage(this, this.getThrower()), (byte) i2);
    }

    for (int i = 0; i < 8; ++i) {
      this.worldObj.spawnParticle("smoke", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
    }

    if (!this.worldObj.isRemote) {
      this.setDead();
    }
  }
Ejemplo n.º 19
0
 @Override
 public boolean itemInteractionForEntity(
     ItemStack itemStack, EntityPlayer player, EntityLivingBase entity) {
   if (entity.worldObj.isRemote) {
     return false;
   } else {
     ItemStack container;
     switch (itemStack.getItemDamage()) {
       case 0:
         break;
       case 1:
         container = LifeSystem.findFilledLifeContainer(player.inventory.mainInventory);
         if (container != null && entity.getHealth() < entity.getMaxHealth()) {
           if (((ILifeContainer) container.getItem()).takeLife(container, 1) > 0) {
             entity.heal(1f);
             player.addStat(ModAchievements.useLP, 1);
             return true;
           }
         }
         break;
       case 2:
         break;
     }
   }
   return false;
 }
 @Override
 protected void onImpact(MovingObjectPosition mop) {
   if (!this.worldObj.isRemote && getThrower() != null) {
     if (mop.entityHit != null) {
       Entity ent = mop.entityHit;
       if (ent instanceof EntityLivingBase) {
         ((EntityLivingBase) ent)
             .attackEntityFrom(DamageSource.causeIndirectMagicDamage(getThrower(), ent), this.dmg);
         if (this.corrosive) {
           try {
             ((EntityLivingBase) ent).addPotionEffect(new PotionEffect(Potion.wither.id, 160, 1));
           } catch (Exception e) {
             e.printStackTrace();
           }
         } else {
           try {
             ((EntityLivingBase) ent)
                 .addPotionEffect(new PotionEffect(Potion.weakness.id, 160, 1));
           } catch (Exception e) {
             e.printStackTrace();
           }
         }
       }
     }
     this.worldObj.playSoundAtEntity(
         this, "random.fizz", 0.5F, 2.6F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.8F);
     this.ticksExisted = 100;
     this.worldObj.setEntityState(this, (byte) 16);
   }
   setDead();
 }
  private void tryAbility(EntityLivingBase mob, EntityLivingBase target) {
    if (target == null || !mob.canEntityBeSeen(target)) {
      return;
    }

    if (mob.getDistanceToEntity(target) > MIN_DISTANCE) {
      double diffX = target.posX - mob.posX;
      double diffY =
          target.boundingBox.minY
              + (double) (target.height / 2.0F)
              - (mob.posY + (double) (mob.height / 2.0F));
      double diffZ = target.posZ - mob.posZ;
      mob.renderYawOffset =
          mob.rotationYaw = -((float) Math.atan2(diffX, diffZ)) * 180.0F / (float) Math.PI;

      mob.worldObj.playAuxSFXAtEntity(
          (EntityPlayer) null, 1008, (int) mob.posX, (int) mob.posY, (int) mob.posZ, 0);
      EntityLargeFireball entFB = new EntityLargeFireball(mob.worldObj, mob, diffX, diffY, diffZ);
      double spawnOffset = 2.0D;
      Vec3 mobLook = mob.getLook(1.0F);
      entFB.posX = mob.posX + mobLook.xCoord * spawnOffset;
      entFB.posY = mob.posY + (double) (mob.height / 2.0F) + 0.5D;
      entFB.posZ = mob.posZ + mobLook.zCoord * spawnOffset;
      mob.worldObj.spawnEntityInWorld(entFB);
    }
  }
  public EntityMamormeterShot(
      World world,
      EntityLivingBase thrower,
      EntityLivingBase target,
      float var4,
      float var5,
      boolean b) {
    super(world);
    this.shootingEntity = thrower;

    if (thrower instanceof EntityPlayer) {
      this.canBePickedUp = 1;
    }

    this.posY = thrower.posY + thrower.getEyeHeight() - 0.10000000149011612D;
    double var6 = target.posX - thrower.posX;
    double var8 = target.posY + target.getEyeHeight() - 0.699999988079071D - this.posY;
    double var10 = target.posZ - thrower.posZ;
    double var12 = MathHelper.sqrt_double(var6 * var6 + var10 * var10);

    if (var12 >= 1.0E-7D) {
      float var14 = (float) (Math.atan2(var10, var6) * 180.0D / Math.PI) - 90.0F;
      float var15 = (float) (-(Math.atan2(var8, var12) * 180.0D / Math.PI));
      double var16 = var6 / var12;
      double var18 = var10 / var12;
      this.setLocationAndAngles(
          thrower.posX + var16, this.posY, thrower.posZ + var18, var14, var15);
      this.yOffset = 0.0F;
      float var20 = (float) var12 * 0.2F;
      this.setArrowHeading(var6, var8 + var20, var10, var4, var5);
    }
    this.explosive = b;
  }
  @SuppressWarnings("unchecked")
  private void potion() {
    List<EntityLivingBase> ents =
        worldObj.getEntitiesWithinAABB(
            EntityLivingBase.class,
            AxisAlignedBB.getBoundingBox(
                xCoord + 1.0,
                yCoord + 1.0,
                zCoord + 1.0,
                xCoord + xLength - 1,
                yCoord + 3.0,
                zCoord + zLength - 1));
    if (ents != null && ents.size() > 0) {
      Potion potion = null;
      // Try and find a potion, 15 times max
      for (int i = 0; i < 15; i++) {
        potion = Potion.potionTypes[worldObj.rand.nextInt(Potion.potionTypes.length)];
        if (potion != null) break;
      }

      if (potion == null) return;

      EntityLivingBase ent = ents.get(worldObj.rand.nextInt(ents.size()));
      ent.addPotionEffect(
          new PotionEffect(potion.id, MathHelper.randomIntInRange(3, 10), 1, false));
    }
  }
 public static boolean removeModifier(
     EntityLivingBase entity, IAttribute attribute, AttributeModifier modifier) {
   if (entity.getEntityAttribute(attribute).getModifier(modifier.getID()) != null) {
     entity.getEntityAttribute(attribute).removeModifier(modifier);
     return true;
   } else return false;
 }
Ejemplo n.º 25
0
  public static MovingObjectPosition getMovingObjectPositionFromPlayer(
      World world, EntityLivingBase living, boolean bool) {
    float f = 1.0F;
    float f1 = living.prevRotationPitch + (living.rotationPitch - living.prevRotationPitch) * f;
    float f2 = living.prevRotationYaw + (living.rotationYaw - living.prevRotationYaw) * f;
    double d0 = living.prevPosX + (living.posX - living.prevPosX) * (double) f;
    double d1 =
        living.prevPosY
            + (living.posY - living.prevPosY) * (double) f
            + (double)
                (world.isRemote
                    ? living.getEyeHeight()
                        - (living instanceof EntityPlayer
                            ? ((EntityPlayer) living).getDefaultEyeHeight()
                            : 0)
                    : living
                        .getEyeHeight()); // isRemote check to revert changes to ray trace position
    // due to adding the eye height clientside and player
    // yOffset differences
    double d2 = living.prevPosZ + (living.posZ - living.prevPosZ) * (double) f;
    Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
    float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
    float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
    float f5 = -MathHelper.cos(-f1 * 0.017453292F);
    float f6 = MathHelper.sin(-f1 * 0.017453292F);
    float f7 = f4 * f5;
    float f8 = f3 * f5;
    double d3 = 5.0D;
    if (living instanceof EntityPlayerMP)
      d3 = ((EntityPlayerMP) living).theItemInWorldManager.getBlockReachDistance();

    Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
    return world.func_147447_a(vec3, vec31, bool, !bool, false);
  }
Ejemplo n.º 26
0
 public void func_111187_a(
     EntityLivingBase p_111187_1_, BaseAttributeMap p_111187_2_, int p_111187_3_) {
   super.func_111187_a(p_111187_1_, p_111187_2_, p_111187_3_);
   if (p_111187_1_.func_110143_aJ() > p_111187_1_.func_110138_aP()) {
     p_111187_1_.func_70606_j(p_111187_1_.func_110138_aP());
   }
 }
Ejemplo n.º 27
0
 public static float[] getRotationsNeeded(Entity entity) {
   if (entity == null) return null;
   double diffX = entity.posX - Minecraft.getMinecraft().thePlayer.posX;
   double diffY;
   if (entity instanceof EntityLivingBase) {
     EntityLivingBase entityLivingBase = (EntityLivingBase) entity;
     diffY =
         entityLivingBase.posY
             + entityLivingBase.getEyeHeight() * 0.9
             - (Minecraft.getMinecraft().thePlayer.posY
                 + Minecraft.getMinecraft().thePlayer.getEyeHeight());
   } else
     diffY =
         (entity.boundingBox.minY + entity.boundingBox.maxY) / 2.0D
             - (Minecraft.getMinecraft().thePlayer.posY
                 + Minecraft.getMinecraft().thePlayer.getEyeHeight());
   double diffZ = entity.posZ - Minecraft.getMinecraft().thePlayer.posZ;
   double dist = MathHelper.sqrt_double(diffX * diffX + diffZ * diffZ);
   float yaw = (float) (Math.atan2(diffZ, diffX) * 180.0D / Math.PI) - 90.0F;
   float pitch = (float) -(Math.atan2(diffY, dist) * 180.0D / Math.PI);
   return new float[] {
     Minecraft.getMinecraft().thePlayer.rotationYaw
         + MathHelper.wrapAngleTo180_float(yaw - Minecraft.getMinecraft().thePlayer.rotationYaw),
     Minecraft.getMinecraft().thePlayer.rotationPitch
         + MathHelper.wrapAngleTo180_float(
             pitch - Minecraft.getMinecraft().thePlayer.rotationPitch)
   };
 }
Ejemplo n.º 28
0
  @Override
  protected void onImpact(MovingObjectPosition par1MovingObjectPosition) {
    if (!this.worldObj.isRemote
        && potionStack.getItem() != null
        && potionStack.getItem() instanceof ItemPotion) {
      @SuppressWarnings("unchecked")
      List<PotionEffect> effectList = ((ItemPotion) potionStack.getItem()).getEffects(potionStack);

      if (effectList != null && !effectList.isEmpty()) {
        AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D);
        @SuppressWarnings("unchecked")
        List<EntityLivingBase> entityList =
            this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);

        if (entityList != null && !entityList.isEmpty()) {
          Iterator<EntityLivingBase> iterator = entityList.iterator();

          while (iterator.hasNext()) {
            EntityLivingBase entityliving = iterator.next();
            double squareDistance = this.getDistanceSqToEntity(entityliving);

            if (squareDistance < 16.0D) {
              double distanceFactor = 1.0D - Math.sqrt(squareDistance) / 4.0D;

              if (entityliving == par1MovingObjectPosition.entityHit) {
                distanceFactor = 1.0D;
              }

              Iterator<PotionEffect> iterator1 = effectList.iterator();

              while (iterator1.hasNext()) {
                PotionEffect potioneffect = iterator1.next();
                int potionID = potioneffect.getPotionID();

                if (Potion.potionTypes[potionID].isInstant()) {
                  Potion.potionTypes[potionID].affectEntity(
                      this.getThrower(), entityliving, potioneffect.getAmplifier(), distanceFactor);
                } else {
                  int potionDuration = (int) (distanceFactor * potioneffect.getDuration() + 0.5D);

                  if (potionDuration > 20) {
                    entityliving.addPotionEffect(
                        new PotionEffect(potionID, potionDuration, potioneffect.getAmplifier()));
                  }
                }
              }
            }
          }
        }
      }

      this.worldObj.playAuxSFX(
          2002,
          (int) Math.round(this.posX),
          (int) Math.round(this.posY),
          (int) Math.round(this.posZ),
          potionStack.getItemDamage());
      this.setDead();
    }
  }
Ejemplo n.º 29
0
  @Override
  public void doSpellCasterEffect(EntityPlayer caster) {
    final int radius = 10;

    caster.worldObj.playSoundAtEntity(caster, "mob.enderdragon.wings", 1.0F, 1.0F);

    for (final Object obj :
        caster.worldObj.getEntitiesWithinAABBExcludingEntity(
            caster,
            AxisAlignedBB.getBoundingBox(
                caster.posX - radius,
                caster.posY - 3,
                caster.posZ - radius,
                caster.posX + radius,
                caster.posY + 3,
                caster.posZ + radius))) {
      if (obj instanceof EntityLivingBase) {
        final EntityLivingBase entity = (EntityLivingBase) obj;
        entity.attackEntityFrom(DamageSource.causeIndirectMagicDamage(caster, entity), 0.0F);

        double deltaX = entity.posX - caster.posX;
        double deltaZ;

        for (deltaZ = entity.posZ - caster.posZ;
            deltaX * deltaX + deltaZ * deltaZ < 1.0E-4D;
            deltaZ = (Math.random() - Math.random()) * 0.01D) {
          deltaX = (Math.random() - Math.random()) * 0.01D;
        }

        for (int i = 0; i < 10; i++) {
          entity.knockBack(caster, 10.0F, deltaX * -1, deltaZ * -1);
        }
      }
    }
  }
 /**
  * Current implementations of this method in child classes do not use the entry argument beside
  * ev. They just raise the damage on the stack.
  */
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLivingBase,
     EntityLivingBase par3EntityLivingBase) {
   if (tool == 4 || tool == 5) {
     NBTTagCompound tag = par1ItemStack.getTagCompound();
     this.currentCharge = tag.getInteger("CurrentCharge");
     if (this.currentCharge >= 24) {
       this.currentCharge -= 24;
       tag.setInteger("CurrentCharge", this.currentCharge);
       int extra = this.doModuleHitAdditions(par2EntityLivingBase, par3EntityLivingBase);
       par2EntityLivingBase.attackEntityFrom(
           DamageSource.magic, 20 + extra); // /2 because its steel not the best material
       return false;
     }
     return false;
   } else {
     NBTTagCompound tag = par1ItemStack.getTagCompound();
     this.currentCharge = tag.getInteger("CurrentCharge");
     if (this.currentCharge >= 48) {
       this.currentCharge -= 48;
       tag.setInteger("CurrentCharge", this.currentCharge);
       int extra = this.doModuleHitAdditions(par2EntityLivingBase, par3EntityLivingBase);
       par2EntityLivingBase.attackEntityFrom(
           DamageSource.magic, 12 + extra / 2); // /2 because its steel not the best material
       return false;
     }
     return false;
   }
 }