/** Adds an entity to the chunk. Args: entity */
  public void addEntity(Entity par1Entity) {
    this.hasEntities = true;
    int var2 = MathHelper.floor_double(par1Entity.posX / 16.0D);
    int var3 = MathHelper.floor_double(par1Entity.posZ / 16.0D);

    if (var2 != this.xPosition || var3 != this.zPosition) {
      this.worldObj.func_98180_V().func_98232_c("Wrong location! " + par1Entity);
      Thread.dumpStack();
    }

    int var4 = MathHelper.floor_double(par1Entity.posY / 16.0D);

    if (var4 < 0) {
      var4 = 0;
    }

    if (var4 >= this.entityLists.length) {
      var4 = this.entityLists.length - 1;
    }

    par1Entity.addedToChunk = true;
    par1Entity.chunkCoordX = this.xPosition;
    par1Entity.chunkCoordY = var4;
    par1Entity.chunkCoordZ = this.zPosition;
    this.entityLists[var4].add(par1Entity);
  }
  /**
   * Gets all entities that can be assigned to the specified class. Args: entityClass, aabb,
   * listToFill
   */
  public void getEntitiesOfTypeWithinAAAB(
      Class par1Class,
      AxisAlignedBB par2AxisAlignedBB,
      List par3List,
      IEntitySelector par4IEntitySelector) {
    int var5 = MathHelper.floor_double((par2AxisAlignedBB.minY - 2.0D) / 16.0D);
    int var6 = MathHelper.floor_double((par2AxisAlignedBB.maxY + 2.0D) / 16.0D);

    if (var5 < 0) {
      var5 = 0;
    } else if (var5 >= this.entityLists.length) {
      var5 = this.entityLists.length - 1;
    }

    if (var6 >= this.entityLists.length) {
      var6 = this.entityLists.length - 1;
    } else if (var6 < 0) {
      var6 = 0;
    }

    for (int var7 = var5; var7 <= var6; ++var7) {
      List var8 = this.entityLists[var7];

      for (int var9 = 0; var9 < var8.size(); ++var9) {
        Entity var10 = (Entity) var8.get(var9);

        if (par1Class.isAssignableFrom(var10.getClass())
            && var10.boundingBox.intersectsWith(par2AxisAlignedBB)
            && (par4IEntitySelector == null || par4IEntitySelector.isEntityApplicable(var10))) {
          par3List.add(var10);
        }
      }
    }
  }
Beispiel #3
0
 public void func_994_a(Entity entity, AxisAlignedBB axisalignedbb, List list) {
   int i = MathHelper.func_1108_b((axisalignedbb.field_1697_b - 2D) / 16D);
   int j = MathHelper.func_1108_b((axisalignedbb.field_1702_e + 2D) / 16D);
   if (i < 0) {
     i = 0;
   }
   if (j >= field_1528_m.length) {
     j = field_1528_m.length - 1;
   }
   for (int k = i; k <= j; k++) {
     List list1 = field_1528_m[k];
     for (int l = 0; l < list1.size(); l++) {
       Entity entity1 = (Entity) list1.get(l);
       if (entity1 == entity || !entity1.field_601_au.func_1178_a(axisalignedbb)) {
         continue;
       }
       list.add(entity1);
       Entity aentity[] = entity1.func_40048_X();
       if (aentity == null) {
         continue;
       }
       for (int i1 = 0; i1 < aentity.length; i1++) {
         Entity entity2 = aentity[i1];
         if (entity2 != entity && entity2.field_601_au.func_1178_a(axisalignedbb)) {
           list.add(entity2);
         }
       }
     }
   }
 }
  public void func_76618_a(Class p_76618_1_, AxisAlignedBB p_76618_2_, List p_76618_3_) {
    int var4 = MathHelper.func_76128_c((p_76618_2_.field_72338_b - 2.0D) / 16.0D);
    int var5 = MathHelper.func_76128_c((p_76618_2_.field_72337_e + 2.0D) / 16.0D);
    if (var4 < 0) {
      var4 = 0;
    } else if (var4 >= this.field_76645_j.length) {
      var4 = this.field_76645_j.length - 1;
    }

    if (var5 >= this.field_76645_j.length) {
      var5 = this.field_76645_j.length - 1;
    } else if (var5 < 0) {
      var5 = 0;
    }

    for (int var6 = var4; var6 <= var5; ++var6) {
      List var7 = this.field_76645_j[var6];
      Iterator var8 = var7.iterator();

      while (var8.hasNext()) {
        Entity var9 = (Entity) var8.next();
        if (p_76618_1_.isAssignableFrom(var9.getClass())
            && var9.field_70121_D.func_72326_a(p_76618_2_)) {
          p_76618_3_.add(var9);
        }
      }
    }
  }
  public void func_76588_a(Entity p_76588_1_, AxisAlignedBB p_76588_2_, List p_76588_3_) {
    int var4 = MathHelper.func_76128_c((p_76588_2_.field_72338_b - 2.0D) / 16.0D);
    int var5 = MathHelper.func_76128_c((p_76588_2_.field_72337_e + 2.0D) / 16.0D);
    if (var4 < 0) {
      var4 = 0;
    }

    if (var5 >= this.field_76645_j.length) {
      var5 = this.field_76645_j.length - 1;
    }

    for (int var6 = var4; var6 <= var5; ++var6) {
      List var7 = this.field_76645_j[var6];
      Iterator var8 = var7.iterator();

      while (var8.hasNext()) {
        Entity var9 = (Entity) var8.next();
        if (var9 != p_76588_1_ && var9.field_70121_D.func_72326_a(p_76588_2_)) {
          p_76588_3_.add(var9);
          Entity[] var10 = var9.func_70021_al();
          if (var10 != null) {
            for (int var11 = 0; var11 < var10.length; ++var11) {
              var9 = var10[var11];
              if (var9 != p_76588_1_ && var9.field_70121_D.func_72326_a(p_76588_2_)) {
                p_76588_3_.add(var9);
              }
            }
          }
        }
      }
    }
  }
Beispiel #6
0
 private void entityCalc() {
   synchronized (map.watchedEntities) {
     map.watchedEntities.clear();
     if (!Spoutcraft.hasPermission("spout.plugin.minimap.showentities")) {
       return;
     }
     if (!MinimapConfig.getInstance().isShowingEntities()) {
       return;
     }
     int radius = map.renderSize / 2;
     double playerX = map.getPlayerX();
     double playerZ = map.getPlayerZ();
     for (Object ob :
         SpoutClient.getHandle()
             .theWorld
             .getEntitiesWithinAABB(
                 EntityLiving.class,
                 AxisAlignedBB.getBoundingBox(
                     playerX - radius,
                     0,
                     playerZ - radius,
                     playerX + radius,
                     256,
                     playerZ + radius))) {
       net.minecraft.src.Entity e = (net.minecraft.src.Entity) ob;
       if (!MinimapConfig.getInstance().isEntityVisible(e.getClass())) {
         continue;
       }
       WatchedEntity w = new WatchedEntity(e);
       if (w.getTexture() != null) {
         map.watchedEntities.add(w);
       }
     }
   }
 }
Beispiel #7
0
  private Entity closest(List list) {
    double d4 = 9000D;
    Entity ent = null;

    for (int i = 0; i < list.size(); i++) {
      Entity ent1 = (Entity) list.get(i);

      boolean okay = true;
      if (ent1 instanceof AM_EntityChopper) {
        okay = false;
      } else if (ent1 instanceof EntityWolf) {
        EntityWolf ew = (EntityWolf) ent1;
        okay = AutomatonUniversal.angrywolf(ew);
      }

      if (okay) {
        double d5 = ent1.getDistanceSq(posX, posY, posZ);
        if (d5 < d4) {
          d4 = d5;
          ent = ent1;
        }
      }
    }

    return ent;
  }
Beispiel #8
0
  /** create a new instance of an entity from NBT store */
  public static Entity createEntityFromNBT(NBTTagCompound par0NBTTagCompound, World par1World) {
    Entity entity = null;

    try {
      Class class1 = (Class) stringToClassMapping.get(par0NBTTagCompound.getString("id"));

      if (class1 != null) {
        entity =
            (Entity)
                class1
                    .getConstructor(new Class[] {net.minecraft.src.World.class})
                    .newInstance(new Object[] {par1World});
      }
    } catch (Exception exception) {
      exception.printStackTrace();
    }

    if (entity != null) {
      entity.readFromNBT(par0NBTTagCompound);
    } else {
      System.out.println(
          (new StringBuilder())
              .append("Skipping Entity with id ")
              .append(par0NBTTagCompound.getString("id"))
              .toString());
    }

    return entity;
  }
Beispiel #9
0
  /** Attacks all entities inside this list, dealing 5 hearts of damage. */
  private void attackEntitiesInList(List par1List) {
    for (int var2 = 0; var2 < par1List.size(); ++var2) {
      Entity var3 = (Entity) par1List.get(var2);

      if (var3 instanceof EntityLivingBase) {
        var3.attackEntityFrom(DamageSource.causeMobDamage(this), 10.0F);
      }
    }
  }
 public void handleEntityVelocity(Packet28EntityVelocity var1) {
   Entity var2 = this.getEntityByID(var1.entityId);
   if (var2 != null) {
     var2.setVelocity(
         (double) var1.motionX / 8000.0D,
         (double) var1.motionY / 8000.0D,
         (double) var1.motionZ / 8000.0D);
   }
 }
  private void ejectRiders() {
    Iterator var1 = this.mountedEntities.iterator();

    while (var1.hasNext()) {
      Entity var2 = (Entity) var1.next();
      this.riddenByEntity = var2;
      var2.mountEntity((Entity) null);
    }

    this.mountedEntities.clear();
  }
Beispiel #12
0
  /**
   * Will update the entity in the world if the chunk the entity is in is currently loaded or its
   * forced to update. Args: entity, forceUpdate
   */
  public void updateEntityWithOptionalForce(Entity par1Entity, boolean par2) {
    if (!this.mcServer.getCanSpawnAnimals()
        && (par1Entity instanceof EntityAnimal || par1Entity instanceof EntityWaterMob)) {
      par1Entity.setDead();
    }

    if (!this.mcServer.getCanSpawnNPCs() && par1Entity instanceof INpc) {
      par1Entity.setDead();
    }

    super.updateEntityWithOptionalForce(par1Entity, par2);
  }
 public void onLivingUpdate() {
   if (field_9324_Y > 0) {
     double d = posX + (field_9323_Z - posX) / (double) field_9324_Y;
     double d1 = posY + (field_9356_aa - posY) / (double) field_9324_Y;
     double d2 = posZ + (field_9354_ab - posZ) / (double) field_9324_Y;
     double d3;
     for (d3 = field_9352_ac - (double) rotationYaw; d3 < -180D; d3 += 360D) {}
     for (; d3 >= 180D; d3 -= 360D) {}
     rotationYaw += d3 / (double) field_9324_Y;
     rotationPitch += (field_9350_ad - (double) rotationPitch) / (double) field_9324_Y;
     field_9324_Y--;
     setPosition(d, d1, d2);
     setRotation(rotationYaw, rotationPitch);
   }
   if (func_22049_v()) {
     isJumping = false;
     moveStrafing = 0.0F;
     moveForward = 0.0F;
     randomYawVelocity = 0.0F;
   } else if (!field_9343_G) {
     updatePlayerActionState();
   }
   boolean flag = handleWaterMovement();
   boolean flag1 = handleLavaMovement();
   if (isJumping) {
     if (flag) {
       motionY += 0.039999999105930328D;
     } else if (flag1) {
       motionY += 0.039999999105930328D;
     } else if (onGround) {
       jump();
     }
   }
   moveStrafing *= 0.98F;
   moveForward *= 0.98F;
   randomYawVelocity *= 0.9F;
   moveEntityWithHeading(moveStrafing, moveForward);
   if (this.health > 0) {
     List list =
         worldObj.getEntitiesWithinAABBExcludingEntity(
             this, boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
     if (list != null && list.size() > 0) {
       for (int i = 0; i < list.size(); i++) {
         Entity entity = (Entity) list.get(i);
         if (entity.canBePushed()) {
           entity.applyEntityCollision(this);
         }
       }
     }
   }
 }
 public void handleEntity(Packet30Entity var1) {
   Entity var2 = this.getEntityByID(var1.entityId);
   if (var2 != null) {
     var2.serverPosX += var1.xPosition;
     var2.serverPosY += var1.yPosition;
     var2.serverPosZ += var1.zPosition;
     double var3 = (double) var2.serverPosX / 32.0D;
     double var5 = (double) var2.serverPosY / 32.0D;
     double var7 = (double) var2.serverPosZ / 32.0D;
     float var9 = var1.rotating ? (float) (var1.yaw * 360) / 256.0F : var2.rotationYaw;
     float var10 = var1.rotating ? (float) (var1.pitch * 360) / 256.0F : var2.rotationPitch;
     var2.setPositionAndRotation2(var3, var5, var7, var9, var10, 3);
   }
 }
 public void handleEntityTeleport(Packet34EntityTeleport var1) {
   Entity var2 = this.getEntityByID(var1.entityId);
   if (var2 != null) {
     var2.serverPosX = var1.xPosition;
     var2.serverPosY = var1.yPosition;
     var2.serverPosZ = var1.zPosition;
     double var3 = (double) var2.serverPosX / 32.0D;
     double var5 = (double) var2.serverPosY / 32.0D + 0.015625D;
     double var7 = (double) var2.serverPosZ / 32.0D;
     float var9 = (float) (var1.yaw * 360) / 256.0F;
     float var10 = (float) (var1.pitch * 360) / 256.0F;
     var2.setPositionAndRotation2(var3, var5, var7, var9, var10, 3);
   }
 }
  public static boolean func_48440_a(
      World par0World, int par1, double par2, double par4, double par6) {
    if (!EntityList.entityEggs.containsKey(Integer.valueOf(par1))) {
      return false;
    } else {
      Entity var8 = EntityList.createEntityByID(par1, par0World);
      if (var8 != null) {
        var8.setLocationAndAngles(par2, par4, par6, par0World.rand.nextFloat() * 360.0F, 0.0F);
        par0World.spawnEntityInWorld(var8);
        ((EntityLiving) var8).playLivingSound();
      }

      return var8 != null;
    }
  }
  public void func_70383_a(Entity par1Entity) {
    if (field_70391_e != null) {
      NBTTagCompound nbttagcompound = new NBTTagCompound();
      par1Entity.addEntityID(nbttagcompound);
      NBTBase nbtbase;

      for (Iterator iterator = field_70391_e.getTags().iterator();
          iterator.hasNext();
          nbttagcompound.setTag(nbtbase.getName(), nbtbase.copy())) {
        nbtbase = (NBTBase) iterator.next();
      }

      par1Entity.readFromNBT(nbttagcompound);
    }
  }
Beispiel #18
0
  private Entity closestSlime(List list) {
    double d4 = 9000D;
    Entity ent = null;

    for (int i = 0; i < list.size(); i++) {
      Entity ent1 = (Entity) list.get(i);

      double d5 = ent1.getDistanceSq(posX, posY, posZ);
      if (d5 < d4) {
        d4 = d5;
        ent = ent1;
      }
    }

    return ent;
  }
Beispiel #19
0
  /** Applies a velocity to each of the entities pushing them away from each other. Args: entity */
  public void applyEntityCollision(Entity par1Entity) {
    if (par1Entity.riddenByEntity == this || par1Entity.ridingEntity == this) {
      return;
    }

    double d = par1Entity.posX - posX;
    double d1 = par1Entity.posZ - posZ;
    double d2 = MathHelper.abs_max(d, d1);

    if (d2 >= 0.01D) {
      d2 = MathHelper.sqrt_double(d2);
      d /= d2;
      d1 /= d2;
      double d3 = 1.0D / d2;

      if (d3 > 1.0D) {
        d3 = 1.0D;
      }

      d *= d3;
      d1 *= d3;
      d *= 0.05D;
      d1 *= 0.05D;
      d *= 1.0F - entityCollisionReduction;
      d1 *= 1.0F - entityCollisionReduction;
      addVelocity(-d, 0.0D, -d1);
      par1Entity.addVelocity(d, 0.0D, d1);
    }
  }
 protected boolean func_70816_c(Entity p_70816_1_) {
   Vec3 var2 =
       Vec3.func_72437_a()
           .func_72345_a(
               this.field_70165_t - p_70816_1_.field_70165_t,
               this.field_70121_D.field_72338_b
                   + (double) (this.field_70131_O / 2.0F)
                   - p_70816_1_.field_70163_u
                   + (double) p_70816_1_.func_70047_e(),
               this.field_70161_v - p_70816_1_.field_70161_v);
   var2 = var2.func_72432_b();
   double var3 = 16.0D;
   double var5 =
       this.field_70165_t
           + (this.field_70146_Z.nextDouble() - 0.5D) * 8.0D
           - var2.field_72450_a * var3;
   double var7 =
       this.field_70163_u
           + (double) (this.field_70146_Z.nextInt(16) - 8)
           - var2.field_72448_b * var3;
   double var9 =
       this.field_70161_v
           + (this.field_70146_Z.nextDouble() - 0.5D) * 8.0D
           - var2.field_72449_c * var3;
   return this.func_70825_j(var5, var7, var9);
 }
  public void writeNBTTagsTo(Entity par1Entity) {
    if (this.spawnerTags != null) {
      NBTTagCompound var2 = new NBTTagCompound();
      par1Entity.addEntityID(var2);
      Iterator var3 = this.spawnerTags.getTags().iterator();

      while (var3.hasNext()) {
        NBTBase var4 = (NBTBase) var3.next();
        var2.setTag(var4.getName(), var4.copy());
      }

      par1Entity.readFromNBT(var2);
    } else if (par1Entity instanceof EntityLiving && par1Entity.worldObj != null) {
      ((EntityLiving) par1Entity).initCreature();
    }
  }
 public boolean canEntityBeSeen(Entity entity) {
   return worldObj.rayTraceBlocks(
           Vec3D.createVector(posX, posY + (double) getEyeHeight(), posZ),
           Vec3D.createVector(
               entity.posX, entity.posY + (double) entity.getEyeHeight(), entity.posZ))
       == null;
 }
Beispiel #23
0
 public boolean attackEntityfrom(DamageSource par1DamageSource, int par2) {
   Entity entity = par1DamageSource.getEntity();
   fearSource = par1DamageSource.getEntity();
   // System.out.println("yep");
   if (entity.getClass() == getClass() && (((EntityAnimalTFC) entity).rutting)) {
     setAttackTarget((EntityLiving) entity);
     if (getHealth() <= getMaxHealth() / 4) {
       ((EntityAnimalTFC) getAttackTarget()).ruttVictor = true;
     }
   }
   if (isChild()
       && parent.children.contains(this)
       && par1DamageSource.getEntity() instanceof EntityLiving) {
     parent.setAttackTarget((EntityLiving) par1DamageSource.getEntity());
   }
   return super.attackEntityFrom(par1DamageSource, par2);
 }
  /**
   * Fills the given list of all entities that intersect within the given bounding box that aren't
   * the passed entity Args: entity, aabb, listToFill
   */
  public void getEntitiesWithinAABBForEntity(
      Entity par1Entity,
      AxisAlignedBB par2AxisAlignedBB,
      List par3List,
      IEntitySelector par4IEntitySelector) {
    int var5 = MathHelper.floor_double((par2AxisAlignedBB.minY - 2.0D) / 16.0D);
    int var6 = MathHelper.floor_double((par2AxisAlignedBB.maxY + 2.0D) / 16.0D);

    if (var5 < 0) {
      var5 = 0;
      var6 = Math.max(var5, var6);
    }

    if (var6 >= this.entityLists.length) {
      var6 = this.entityLists.length - 1;
      var5 = Math.min(var5, var6);
    }

    for (int var7 = var5; var7 <= var6; ++var7) {
      List var8 = this.entityLists[var7];

      for (int var9 = 0; var9 < var8.size(); ++var9) {
        Entity var10 = (Entity) var8.get(var9);

        if (var10 != par1Entity
            && var10.boundingBox.intersectsWith(par2AxisAlignedBB)
            && (par4IEntitySelector == null || par4IEntitySelector.isEntityApplicable(var10))) {
          par3List.add(var10);
          Entity[] var11 = var10.getParts();

          if (var11 != null) {
            for (int var12 = 0; var12 < var11.length; ++var12) {
              var10 = var11[var12];

              if (var10 != par1Entity
                  && var10.boundingBox.intersectsWith(par2AxisAlignedBB)
                  && (par4IEntitySelector == null
                      || par4IEntitySelector.isEntityApplicable(var10))) {
                par3List.add(var10);
              }
            }
          }
        }
      }
    }
  }
Beispiel #25
0
 public boolean eject() {
   if (!isEmpty()) {
     handle.riddenByEntity.ridingEntity = null;
     handle.riddenByEntity = null;
     return true;
   }
   return false;
 }
Beispiel #26
0
  public void removeAllEntities() {
    this.loadedEntityList.removeAll(this.unloadedEntityList);

    int var1;
    Entity var2;
    int var3;
    int var4;
    for (var1 = 0; var1 < this.unloadedEntityList.size(); ++var1) {
      var2 = (Entity) this.unloadedEntityList.get(var1);
      var3 = var2.chunkCoordX;
      var4 = var2.chunkCoordZ;
      if (var2.addedToChunk && this.chunkExists(var3, var4)) {
        this.getChunkFromChunkCoords(var3, var4).removeEntity(var2);
      }
    }

    for (var1 = 0; var1 < this.unloadedEntityList.size(); ++var1) {
      this.releaseEntitySkin((Entity) this.unloadedEntityList.get(var1));
    }

    this.unloadedEntityList.clear();

    for (var1 = 0; var1 < this.loadedEntityList.size(); ++var1) {
      var2 = (Entity) this.loadedEntityList.get(var1);
      if (var2.ridingEntity != null) {
        if (!var2.ridingEntity.isDead && var2.ridingEntity.riddenByEntity == var2) {
          continue;
        }

        var2.ridingEntity.riddenByEntity = null;
        var2.ridingEntity = null;
      }

      if (var2.isDead) {
        var3 = var2.chunkCoordX;
        var4 = var2.chunkCoordZ;
        if (var2.addedToChunk && this.chunkExists(var3, var4)) {
          this.getChunkFromChunkCoords(var3, var4).removeEntity(var2);
        }

        this.loadedEntityList.remove(var1--);
        this.releaseEntitySkin(var2);
      }
    }
  }
Beispiel #27
0
  public void func_73022_a() {
    this.field_72996_f.removeAll(this.field_72997_g);

    int var1;
    Entity var2;
    int var3;
    int var4;
    for (var1 = 0; var1 < this.field_72997_g.size(); ++var1) {
      var2 = (Entity) this.field_72997_g.get(var1);
      var3 = var2.field_70176_ah;
      var4 = var2.field_70164_aj;
      if (var2.field_70175_ag && this.func_72916_c(var3, var4)) {
        this.func_72964_e(var3, var4).func_76622_b(var2);
      }
    }

    for (var1 = 0; var1 < this.field_72997_g.size(); ++var1) {
      this.func_72847_b((Entity) this.field_72997_g.get(var1));
    }

    this.field_72997_g.clear();

    for (var1 = 0; var1 < this.field_72996_f.size(); ++var1) {
      var2 = (Entity) this.field_72996_f.get(var1);
      if (var2.field_70154_o != null) {
        if (!var2.field_70154_o.field_70128_L && var2.field_70154_o.field_70153_n == var2) {
          continue;
        }

        var2.field_70154_o.field_70153_n = null;
        var2.field_70154_o = null;
      }

      if (var2.field_70128_L) {
        var3 = var2.field_70176_ah;
        var4 = var2.field_70164_aj;
        if (var2.field_70175_ag && this.func_72916_c(var3, var4)) {
          this.func_72964_e(var3, var4).func_76622_b(var2);
        }

        this.field_72996_f.remove(var1--);
        this.func_72847_b(var2);
      }
    }
  }
 public void attemptMount(Entity var1) {
   if (var1 != null
       && !(var1 instanceof EntityElevator)
       && !this.collideEntity(var1)
       && var1.ridingEntity == null) {
     var1.mountEntity(this);
     this.mountedEntities.add(var1);
   }
 }
Beispiel #29
0
  /** Pushes all entities inside the list away from the enderdragon. */
  private void collideWithEntities(List par1List) {
    double var2 =
        (this.dragonPartBody.boundingBox.minX + this.dragonPartBody.boundingBox.maxX) / 2.0D;
    double var4 =
        (this.dragonPartBody.boundingBox.minZ + this.dragonPartBody.boundingBox.maxZ) / 2.0D;
    Iterator var6 = par1List.iterator();

    while (var6.hasNext()) {
      Entity var7 = (Entity) var6.next();

      if (var7 instanceof EntityLivingBase) {
        double var8 = var7.posX - var2;
        double var10 = var7.posZ - var4;
        double var12 = var8 * var8 + var10 * var10;
        var7.addVelocity(var8 / var12 * 4.0D, 0.20000000298023224D, var10 / var12 * 4.0D);
      }
    }
  }
Beispiel #30
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.delayBeforeCanPickup > 0) {
      --this.delayBeforeCanPickup;
    }

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= 0.03999999910593033D;

    if (this.worldObj.getBlockMaterial(
            MathHelper.floor_double(this.posX),
            MathHelper.floor_double(this.posY),
            MathHelper.floor_double(this.posZ))
        == Material.lava) {
      this.motionY = 0.20000000298023224D;
      this.motionX = (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
      this.motionZ = (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
      this.worldObj.playSoundAtEntity(
          this, "random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F);
    }

    this.pushOutOfBlocks(
        this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ);
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    float var1 = 0.98F;

    if (this.onGround) {
      var1 = 0.58800006F;
      int var2 =
          this.worldObj.getBlockId(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.boundingBox.minY) - 1,
              MathHelper.floor_double(this.posZ));

      if (var2 > 0) {
        var1 = Block.blocksList[var2].slipperiness * 0.98F;
      }
    }

    this.motionX *= (double) var1;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= (double) var1;

    if (this.onGround) {
      this.motionY *= -0.5D;
    }

    ++this.age;

    if (this.age >= 6000) {
      this.setDead();
    }
  }