示例#1
0
  @Override
  protected void onCrafted(Args a) {
    if (!a.hasLocation()) {
      a.addCustomReason("Needs location!");
      return;
    }

    for (Customization c : spawn) {
      if (c.pet || c.target || (c.saddle && c.mount)) {
        if (!a.hasPlayer()) {
          a.addCustomReason("Needs player!");
          return;
        }

        break;
      }
    }

    Location l = a.location();

    if (l.getX() == l.getBlockX()) {
      l.add(0.5, 1.5, 0.5);
    }

    List<LivingEntity> toMount = null;

    for (Customization c : spawn) {
      if (c.chance < 100.0f && c.chance < (RecipeManager.random.nextFloat() * 100)) {
        continue;
      }

      List<LivingEntity> spawned = c.spawn(l, a.player());

      if (toMount != null) {
        for (int i = 0; i < Math.min(spawned.size(), toMount.size()); i++) {
          spawned.get(i).setPassenger(toMount.get(i));
        }
      }

      toMount = c.mountNext ? spawned : null;
    }
  }