コード例 #1
0
  /**
   * Updates a villager entity with the zombie info this object is tracking.
   *
   * @param villager
   */
  public void updateVillager(EntityVillager villager) {

    // Note: I must trust that this object actually contain a zombie info. If not, the cast below
    // will fail.
    final ExtendedVillagerZombie properties = (ExtendedVillagerZombie) this.getObject();

    // Custom name
    if (this.getCustomName() != "") {
      villager.setCustomNameTag(this.getCustomName());
    }

    // Profession
    if (properties.getProfession() >= 0 && properties.getProfession() <= 4) { // vanilla professions
      villager.setProfession(properties.getProfession());
    }
  }
コード例 #2
0
  /** Updates a zombie entity with the villager info this object is tracking. */
  public void updateZombie(EntityZombie zombie, ExtendedVillagerZombie properties) {

    // Note: I must trust that this object actually contain a villager info. If not, the cast below
    // will fail.
    final Object[] extraInfo = (Object[]) this.getObject();
    final int profession = (Integer) extraInfo[0];
    final boolean isBaby = (Boolean) extraInfo[1];

    // Custom name
    if (this.getCustomName() != "") {
      zombie.setCustomNameTag(this.getCustomName());
      zombie.enablePersistence();
    }

    // Adult or child
    zombie.setChild(isBaby);

    // Profession
    if (profession >= 0 && profession <= 4) { // vanilla professions
      properties.setProfession(profession);
    } else {
      properties.setProfession(-1); // vanilla zombie villager
    }
  }