Example #1
0
  @SideOnly(Side.CLIENT)

  /** will create the entity from the internalID the first time it is accessed */
  public Entity getMobEntity() {
    if (this.spawnedMob == null) {
      Entity var1 = EntityList.createEntityByName(this.getMobID(), (World) null);
      this.writeNBTTagsTo(var1);
      this.spawnedMob = var1;
    }

    return this.spawnedMob;
  }
Example #2
0
  @Override
  protected void onImpact(MovingObjectPosition movingobjectposition) {
    // 飛翔体の接触判定
    if (movingobjectposition.entityHit != null) {
      if (!movingobjectposition.entityHit.attackEntityFrom(
          DamageSource.causeThrownDamage(this, thrower), 0)) ;
    }
    if (eggItemStack == null) {
      return;
    }
    if (!worldObj.isRemote) {
      // 着弾時処理
      String s = mod_IME_mobEgg.getInnerEntityName(eggItemStack.getItemDamage());
      if (s.isEmpty()) {
        // 設定がない場合はランダムで対象を指定
        List<String> ll = new ArrayList<String>();
        for (Entry<String, Boolean> t : mod_IME_mobEgg.randomMap.entrySet()) {
          if (t.getValue()) {
            ll.add(t.getKey());
          }
        }
        if (ll.isEmpty()) return;
        s = ll.get(rand.nextInt(ll.size()));
      }

      // EntityListから招喚対象を抽出する
      Entity entity = EntityList.createEntityByName(s, worldObj);
      if (entity instanceof EntityLiving) {
        // 初期設定値を与える
        ((EntityLiving) entity).func_110161_a(null);
      }
      if (entity != null) {
        entity.setLocationAndAngles(posX, posY + 1.0F, posZ, rotationYaw, 0.0F);
        worldObj.spawnEntityInWorld(entity);
      }
      setDead();
    }
    for (int i = 0; i < 8; i++) {
      worldObj.spawnParticle("snowballpoof", posX, posY, posZ, 0.0D, 0.0D, 0.0D);
    }
  }
  /**
   * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses
   * this to count ticks and creates a new spawn inside its implementation.
   */
  public void updateEntity() {
    if (!anyPlayerInRange()) {
      return;
    }

    if (worldObj.isRemote) {
      double d = (float) xCoord + worldObj.rand.nextFloat();
      double d1 = (float) yCoord + worldObj.rand.nextFloat();
      double d3 = (float) zCoord + worldObj.rand.nextFloat();
      worldObj.spawnParticle("smoke", d, d1, d3, 0.0D, 0.0D, 0.0D);
      worldObj.spawnParticle("flame", d, d1, d3, 0.0D, 0.0D, 0.0D);
      yaw2 = yaw % 360D;
      yaw += 4.5454545021057129D;
    } else {
      if (delay == -1) {
        updateDelay();
      }

      if (delay > 0) {
        delay--;
        return;
      }

      for (int i = 0; i < field_70395_h; i++) {
        Entity entity = EntityList.createEntityByName(mobID, worldObj);

        if (entity == null) {
          return;
        }

        int j =
            worldObj
                .getEntitiesWithinAABB(
                    entity.getClass(),
                    AxisAlignedBB.getAABBPool()
                        .addOrModifyAABBInPool(
                            xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)
                        .expand(8D, 4D, 8D))
                .size();

        if (j >= 6) {
          updateDelay();
          return;
        }

        if (entity == null) {
          continue;
        }

        double d2 =
            (double) xCoord + (worldObj.rand.nextDouble() - worldObj.rand.nextDouble()) * 4D;
        double d4 = (yCoord + worldObj.rand.nextInt(3)) - 1;
        double d5 =
            (double) zCoord + (worldObj.rand.nextDouble() - worldObj.rand.nextDouble()) * 4D;
        EntityLiving entityliving = (entity instanceof EntityLiving) ? (EntityLiving) entity : null;
        entity.setLocationAndAngles(d2, d4, d5, worldObj.rand.nextFloat() * 360F, 0.0F);

        if (entityliving != null && !entityliving.getCanSpawnHere()) {
          continue;
        }

        func_70383_a(entity);
        worldObj.spawnEntityInWorld(entity);
        worldObj.playAuxSFX(2004, xCoord, yCoord, zCoord, 0);

        if (entityliving != null) {
          entityliving.spawnExplosionParticle();
        }

        updateDelay();
      }
    }

    super.updateEntity();
  }
Example #4
0
  /**
   * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses
   * this to count ticks and creates a new spawn inside its implementation.
   */
  public void updateEntity() {
    if (this.anyPlayerInRange()) {
      if (this.worldObj.isRemote) {
        double var1 = (double) ((float) this.xCoord + this.worldObj.rand.nextFloat());
        double var3 = (double) ((float) this.yCoord + this.worldObj.rand.nextFloat());
        double var5 = (double) ((float) this.zCoord + this.worldObj.rand.nextFloat());
        this.worldObj.spawnParticle("smoke", var1, var3, var5, 0.0D, 0.0D, 0.0D);
        this.worldObj.spawnParticle("flame", var1, var3, var5, 0.0D, 0.0D, 0.0D);

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

        this.yaw2 = this.yaw;
        this.yaw = (this.yaw + (double) (1000.0F / ((float) this.delay + 200.0F))) % 360.0D;
      } else {
        if (this.delay == -1) {
          this.updateDelay();
        }

        if (this.delay > 0) {
          --this.delay;
          return;
        }

        for (int var11 = 0; var11 < this.spawnCount; ++var11) {
          Entity var2 = EntityList.createEntityByName(this.mobID, this.worldObj);

          if (var2 == null) {
            return;
          }

          int var12 =
              this.worldObj
                  .getEntitiesWithinAABB(
                      var2.getClass(),
                      AxisAlignedBB.getAABBPool()
                          .addOrModifyAABBInPool(
                              (double) this.xCoord,
                              (double) this.yCoord,
                              (double) this.zCoord,
                              (double) (this.xCoord + 1),
                              (double) (this.yCoord + 1),
                              (double) (this.zCoord + 1))
                          .expand(
                              (double) (this.field_82348_s * 2),
                              4.0D,
                              (double) (this.field_82348_s * 2)))
                  .size();

          if (var12 >= this.field_82350_j) {
            this.updateDelay();
            return;
          }

          if (var2 != null) {
            double var4 =
                (double) this.xCoord
                    + (this.worldObj.rand.nextDouble() - this.worldObj.rand.nextDouble())
                        * (double) this.field_82348_s;
            double var6 = (double) (this.yCoord + this.worldObj.rand.nextInt(3) - 1);
            double var8 =
                (double) this.zCoord
                    + (this.worldObj.rand.nextDouble() - this.worldObj.rand.nextDouble())
                        * (double) this.field_82348_s;
            EntityLiving var10 = var2 instanceof EntityLiving ? (EntityLiving) var2 : null;
            var2.setLocationAndAngles(
                var4, var6, var8, this.worldObj.rand.nextFloat() * 360.0F, 0.0F);

            if (var10 == null || var10.getCanSpawnHere()) {
              this.writeNBTTagsTo(var2);
              this.worldObj.spawnEntityInWorld(var2);
              this.worldObj.playAuxSFX(2004, this.xCoord, this.yCoord, this.zCoord, 0);

              if (var10 != null) {
                var10.spawnExplosionParticle();
              }

              this.updateDelay();
            }
          }
        }
      }

      super.updateEntity();
    }
  }