Esempio n. 1
0
  @Override
  public Entity spawnEntityIntoClientWorld(EntityRegistration er, EntitySpawnPacket packet) {
    WorldClient wc = client.field_71441_e;

    Class<? extends Entity> cls = er.getEntityClass();

    try {
      Entity entity;
      if (er.hasCustomSpawning()) {
        entity = er.doCustomSpawning(packet);
      } else {
        entity = (Entity) (cls.getConstructor(World.class).newInstance(wc));
        int offset = packet.entityId - entity.field_70157_k;
        entity.field_70157_k = packet.entityId;
        entity.func_70012_b(
            packet.scaledX, packet.scaledY, packet.scaledZ, packet.scaledYaw, packet.scaledPitch);
        if (entity instanceof EntityLiving) {
          ((EntityLiving) entity).field_70759_as = packet.scaledHeadYaw;
        }

        Entity parts[] = entity.func_70021_al();
        if (parts != null) {
          for (int j = 0; j < parts.length; j++) {
            parts[j].field_70157_k += offset;
          }
        }
      }

      entity.field_70118_ct = packet.rawX;
      entity.field_70117_cu = packet.rawY;
      entity.field_70116_cv = packet.rawZ;

      if (entity instanceof IThrowableEntity) {
        Entity thrower =
            client.field_71439_g.field_70157_k == packet.throwerId
                ? client.field_71439_g
                : wc.func_73045_a(packet.throwerId);
        ((IThrowableEntity) entity).setThrower(thrower);
      }

      if (packet.metadata != null) {
        entity.func_70096_w().func_75687_a((List) packet.metadata);
      }

      if (packet.throwerId > 0) {
        entity.func_70016_h(packet.speedScaledX, packet.speedScaledY, packet.speedScaledZ);
      }

      if (entity instanceof IEntityAdditionalSpawnData) {
        ((IEntityAdditionalSpawnData) entity).readSpawnData(packet.dataStream);
      }

      wc.func_73027_a(packet.entityId, entity);
      return entity;
    } catch (Exception e) {
      FMLLog.log(Level.SEVERE, e, "A severe problem occurred during the spawning of an entity");
      throw Throwables.propagate(e);
    }
  }
Esempio n. 2
0
  public void func_73027_a(int p_73027_1_, Entity p_73027_2_) {
    Entity var3 = this.func_73045_a(p_73027_1_);
    if (var3 != null) {
      this.func_72900_e(var3);
    }

    this.field_73032_d.add(p_73027_2_);
    p_73027_2_.field_70157_k = p_73027_1_;
    if (!this.func_72838_d(p_73027_2_)) {
      this.field_73036_L.add(p_73027_2_);
    }

    this.field_73034_c.func_76038_a(p_73027_1_, p_73027_2_);
  }