Spectrum

Spectrum

2M Downloads

[BUG] Certain combinations of recipe+catalyst in the Crystallarieum can lead to 0 ink consumption

Robotgiggle opened this issue ยท 2 comments

commented

Describe the bug
The ink consumption per second of the Crystallarieum is calculated as follows: multiply the base ink per second of the recipe, the growth acceleration mod, and the ink consumption mod, and then cast the resulting value to an integer (as shown below).

int consumedInk = (int) (crystallarieum.currentRecipe.getInkPerSecond() * crystallarieum.currentCatalyst.growthAccelerationMod * crystallarieum.currentCatalyst.inkConsumptionMod);
Because of the cast-to-int, if the final calculated cost is less than 1, it gets truncated to 0. This results in a crystal-growing recipe which is completely free (at least in terms of ink) and doesn't even require any of the correct color of ink to be present in the Crystallarieum's internal storage.

Furthermore, while trying to determine the cause of this bug, I found a documentation issue. The line of code which converts the ink_cost_tier value from the recipe JSON into a numerical ink-per-second value (see below) comes with a comment which claims to list what the ink-per-second value for each tier should be.

int inkPerSecond = inkCostTier == 0 ? 0 : (int) Math.pow(2, inkCostTier - 1); // 0=0; 1=1; 2=4; 3=16; 4=64; 5=256)
However, the values described in that comment are not correct. They would be correct if the Math.pow() function used 4 as its base, but it doesn't โ€“ it uses 2. The correct values, when 2 is used as the base, are as follows: 0=0; 1=1; 2=2; 3=4; 4=8; 5=16;

The main issue described here (free Crystallarieum recipes) may have arisen because somebody based their math on the values in the incorrect comment, and thus assumed that it wouldn't be possible to get a final ink consumption of less than 1 when such a thing actually was possible.

To Reproduce
Add some Midnight Chips (0.25x ink consumption) into a freshly placed Crystallarieum, then drop some Nether Quartz (base ink consumption of 2) on top. Observe that the quartz bud grows to maturity despite there being no ink at all in the Crystallarieum, since the final calculated ink consumption (2 * 0.25 = 0.5) is less than 1.

Expected behavior
I'd expect that the ability to completely eliminate ink consumption with certain catalysts would be mentioned somewhere in the guidebook โ€“ or, alternatively, that such a thing should not be possible.

Minecraft version
1.20.1

Mod version
1.7.7

Screenshots
Crystallarieum containing Midnight Chips with a fully grown Quartz Cluster on top. Note that the ink storage is completely empty โ€“ I placed down this Crystallarieum and ran the recipe without ever inserting any ink.
2024-04-02_01 55 01

commented

Great find!

commented

Fixed via ec85d04