Portable Temperature Regulator Stops Working
aelfwyne opened this issue ยท 10 comments
Been using TAN with ToughExpansion for months without issue.
Suddenly, I've found that my Portable Temperature Regulator is no longer working. Taking frost damage with the regulator right there in my inventory like normal. Regulator is fully charged, and I'm not in any kind of extreme biome. Just at my base where I haven't had issues ever before. /tan tempinfo does not show that the regulator is functioning. Only choice is to log out when this starts happening. Second time it's happened in several days - I'm not sure if it had started working again, or if the season merely changed so I didn't notice it not working again until today.
Similar issue.
temperature regulator stopped working. Meanwhile, it rapidly consumes energy when worn.
I have no clue what could be causing this. Without being able to replicate the bug, I cannot fix it.
I've looked at NBT tag of the item, and it had a NBT tag startTime with somewhat big value, and it does not change.
Then I've looked into ItemTempRegulator.java code, and I've had a following assumption:
startTime did not reset to -1 at some point of time (possibly, at logout), and then condtiion
if (ModGlobals.TIMER >= startTime + 1000L) {
fails, and it doing constantly
setEnergyStored(stack, getEnergyStored(stack) - 100);
Then I've been experimenting with this (died meanwhile), and got my temp to 14 (there was a night), and startTime was reset to -1! So it works again.
I've reproduced the bug - you need to catch the moment when startTime is not equal -1 and exit the game, then reenter it. Then regulator stops working until either of:
- Your temperature is 14
- Enough time is passed since beginning of the game so the internal timer is greater than startTime value.
I may propose two variants of fixing this:
- Instead of set startTime to current ModGlobals.TIMER value, and then compare it to +1000, set startTime to 1000 and decrement it every tick until it's equal to -1.
- Add explicit fix somewhere
if (ModGlobals.TIMER < startTime) { setTime(stack, ModGlobals.TIMER); }
I would prefer 1, however I'm not sure about how it all works, never wrote MC mod :-)
sounds good :) thanks for putting in the work to pin point this issue..i'll get it build and on curse asap
Thank you for such quick response!
Also TileTempRegulator.java have the same logic, then it should be fixed too (maybe extract common part of temp regulating algorithm from these classes?).
@skupr would you be able to join me on discord for a bit of testing? I've decided to change some of the core functionality (although, in theory, it should pretty much appear the same on the player end)..I'd just like to have your opinion on the changes. https://discord.gg/9J7yhUP