Edit lifespan changes health too (#122) (#127)

Co-authored-by: Marlo Greisser <[email protected]>
This commit is contained in:
boubou19andMarlo Greisser authored and GitHub committed 2026-11-19 05:42:13 +01:00
1 parent 54a2bbe488
commit 48540be626
2 files changed
+14

No files matched your search

@@ -39,6 +39,13 @@ public class Inoculator {
NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
if (gene.getChromosome() == EnumBeeChromosome.LIFESPAN && gene.getSpeciesRoot() instanceof IBeeRoot beeRoot) {
int lifespan = beeRoot.getMember(target).getGenome().getLifespan();
beeNBT.setInteger(
"Health",
Math.max(0, beeNBT.getInteger("Health") + lifespan - beeNBT.getInteger("MaxH")));
beeNBT.setInteger("MaxH", lifespan);
}
target.setTagCompound(beeNBT);
}
}
@@ -37,6 +37,13 @@ public class Splicer {
NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
if (gene.getChromosome() == EnumBeeChromosome.LIFESPAN && gene.getSpeciesRoot() instanceof IBeeRoot beeRoot) {
int lifespan = beeRoot.getMember(target).getGenome().getLifespan();
beeNBT.setInteger(
"Health",
Math.max(0, beeNBT.getInteger("Health") + lifespan - beeNBT.getInteger("MaxH")));
beeNBT.setInteger("MaxH", lifespan);
}
target.setTagCompound(beeNBT);
}
}