Ender IO Zoo

Ender IO Zoo

962k Downloads

Documentation "enum RecipeBonusType" vs. usage in XML

7eggert opened this issue · 4 comments

commented

Issue Description:

There seem to be two ways of controlling the bonus of item processing: either e.g. exclude the balls () or directly specify it directly in the recipe (<recipe name="iron_gravel_to_crushed" energyCost="500" bonusType="chance_only" >

(I prefer the later)

I searched the code on github to find how "bonusType" gets parsed, but I couldn't find it.

  • Is bonusType supported at all?
  • If it is not, are the affected default recipes broken / in need of adjustment?
  • If it is, it needs documentation, especially for specifying other values than "chance_only"

PS: Typo in SAGMillRecipes_Core.xml: Missing string terminator:
<dumpRegistry modObjects="true/>

Affected Versions (Do not use "latest"):

EnderIO-1.10.2-3.1.183.jar
EnderCore-1.10.2-0.4.1.65-beta.jar

commented

The github search is not the best. The value is parsed, put into the job and finally used:

  protected void taskComplete() {
    IPoweredTask ct = currentTask;
    super.taskComplete();
    // run it again if the ball says so
    if (gb != null && useGrindingBall && ct != null) {
      if (ct.getBonusType() == RecipeBonusType.MULTIPLY_OUTPUT) {
        float chance = random.nextFloat();
        float mul = gb.getGrindingMultiplier() - 1;
        while (mul > 0) {
          if (chance <= mul) {
            currentTask = ct;
            super.taskComplete();
          }
          mul--;
        }
      }
    }
  }

In comparison, theis is what the grinding ball exclusion does:

  @Override
  protected IPoweredTask createTask(IMachineRecipe nextRecipe, float chance) {
    PoweredTask res;
    useGrindingBall = false;
    if (gb != null) {
      useGrindingBall = !SagMillRecipeManager.getInstance().isExcludedFromBallBonus(getRecipeInputs());
      if (useGrindingBall) {
        res = new PoweredTask(nextRecipe, chance / gb.getChanceMultiplier(), getRecipeInputs());
        res.setRequiredEnergy(res.getRequiredEnergy() * gb.getPowerMultiplier());
      } else {
        res = new PoweredTask(nextRecipe, chance, getRecipeInputs());
      }
    } else {
      res = new PoweredTask(nextRecipe, chance, getRecipeInputs());
    }
    return res;
  }

However, you are right, the value "RecipeBonusType.CHANCE_ONLY" is not used at all.

Is this broken? I have no idea, I don't claim to understand the recipe system. However, as the bonus type "NONE" is also not used by any recipe, it seems to me that the bonus type actually only has 2 values "chance only" and "multiply".

Let me write down how it works for reference:

So, if "multiply" is specified (default): The whole recipe output is duped for grindingMultiplier times (meaning you get one output per whole number and the remainder of the number is the chance for another output, e.g. 7,39 = 7 outputs and a 39% chance for an 8th). If it is set to "chance only" (or "none"), the grindingMultiplier has no effect and you only ever get one recipe output from a recipe.

If a recipe is not excluded from the grinding ball bonus: The chances for the outputs are multiplied with the chanceMuliplier. So if an output is given with a chance of e.g. 0.5 in the recipe and a grinding ball with a chance multiplier of 1.6 is used, you have a 75% (0.5*1.5) chance of getting that output. Note that here chances above 100% do not give multiple outputs, this is a hit-or-miss check. If it is excluded, the chance is used as-is and the "chance only" behavior from above is also enforced.

That is interesting. It seems that the grinding ball exclusion list---which is a relatively recent addition---is actually not needed. The multiplication of outputs can already be disabled and the higher chances are not something one usually would want to prevent.

Thanks for bringing this up, I'll have a look into making "NONE" work again and doing the same thing the exclusion list does now.

tl;dr: bonusType="chance_only" works. bonusType="none" is broken and should do what the exclusion list now does.

commented

Update: Looking at the history, it seems I was wrong. The exclusion list is the older of those 2 features. My mistake.

commented

My ¢¢: The exclusion list should just overwrite bonusType then, that will reduce the the amount of code dealing with exceptions.

commented

Nah, I just removed the exclude list. The only thing remaining is the automatic detection of "nugget", "ingot" and "block" recipes (e.g. iron ingot to iron dust).

This goes into 1.11 because it's a breaking change in the config file.