Productive Bees

Productive Bees

10M Downloads

Placing Gene Sample in crafting table with similar Honey Treat modifies the Sample (even though no crafting occurs)

mc-ganduron opened this issue ยท 2 comments

commented

productivebees-1.16.5-0.6.9.14

There's a problem adding a gene sample to a honey treat that has that type of sample already on it. If the crafting is canceled, the sample is modified.

Steps to reproduce:

  1. Create a honey treat.
  2. Apply a gene sample to the honey treat.
  3. Place that honey treat back in the crafting table with another gene sample, the same type that was applied in step 2.
  4. Cursor over the expected output honey treat.
  5. Pull out the original, input honey treat and sample (i.e., don't perform the crafting).

In step 4, the output honey treat shows the wrong gene sample percent. It doesn't add the value of the sample.
After step 5, the sample is modified. It has the original sample percent plus the honey treat sample percent. (This is the value that should have appeared in step 4.)

Video:

ProductiveBees_GeneSample.mp4
commented

Thanks a lot for the extensive testing. I'll add the fix to the next update.

commented

The problem may be in HoneyTreat.addGene. It is adding the purity value to the incoming gene, not to the HoneyTreat's existing gene (line 61 below):

public static void addGene(ItemStack stack, ItemStack gene) {
ListNBT genes = getGenes(stack);
boolean addedToExistingGene = false;
for (INBT inbt : genes) {
ItemStack insertedGene = ItemStack.of((CompoundNBT) inbt);
int purity = Gene.getPurity(insertedGene);
if (Gene.getAttributeName(insertedGene).equals(Gene.getAttributeName(gene)) && Gene.getValue(insertedGene).equals(Gene.getValue(gene))) {
purity = Math.min(100, purity + Gene.getPurity(gene));
Gene.setPurity(gene, purity);
addedToExistingGene = true;
}
}
if (!addedToExistingGene) {
CompoundNBT serializedGene = gene.serializeNBT();
genes.add(serializedGene);
}
stack.getOrCreateTag().put(GENES_KEY, genes);
}

Changing line 61's gene to insertedGene appears to fix the problem (although this video is the full extent of testing I've done):

ProductiveBees_GeneSample2.mp4