Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Botania Runic Altar restarts crafting after completion (with no items), and crashes if you attempt to complete the blank recipe with a dispenser #6528

Open
CaptainFord opened this issue Dec 30, 2024 · 3 comments

Comments

@CaptainFord
Copy link

CaptainFord commented Dec 30, 2024

Modpack

FTB Interactions Remastered

Modpack version

1.10.0

Launcher

FTB App

Has the pack been modified

Yes

Log Files

Original Log: https://mclo.gs/J3KwkF5
Creative Recreation: https://mclo.gs/Mr3qsX7

Describe the bug

#6319 seems to be directly related, but is missing these details:

Immediately after right-clicking the runic altar with the Wand of the Forest, the altar seems to immediately start charging a new copy of the recipe. Mana spreaders fire, and the number of times they fire seems to consistently match the recipe that just completed crafting (I haven't counted, but there's an obvious difference between Air Runes and Charging Runes, for example). But no items are in the altar. It emits the same redstone signals as normal, and in my case, caused the redstone automation to automatically attempt to complete the recipe, crashing my game, and possibly because I had the dispenser with the wand on a timer, it also crashed my game every time I try to load it as well.

I am notably still able to right-click to add ingredients to the altar and this DOES reset the state of the altar, making it usable again and stopping the blank craft. If you miss this window the altar becomes completely unusable and will probably crash. However, it turns out that if you attempt to complete this blank craft, nothing happens, UNLESS you put the Wand of the Forest in a dispenser and activate that with a living rock on the altar. That will crash your game, but you may be able to load back in.

I added Spark and LagGoggles to my game to help me diagnose lag issues (orbital miner was causing 40 second lag spikes), but the runic altar worked perfectly plenty of times with those mods installed. I removed LagGoggles anyway to see if it would help, and it has not, I can reliably reproduce this bug with at least the Dislocator, Air Rune and Speed Rune recipes in my world every time. It happens in at least two different dimensions and locations.

I am not sure if I used the runic altar since updating to 1.10.0 aside from this, but I think I did quite extensively when upgrading my blood altars. In any case, I'm not sure what has changed exactly since it was last working, but it is quite annoying that I can't automate it anymore (wait, I can, I just have to break and place the altar after every cycle. And if that ever fails, my save is permanently borked. Oh boy.)

For what it's worth, I am noticing that the amount of time it takes to charge the altar for the blank recipes matches the recipe it just completed. So it is not, at least, doing a lookup and finding some blank recipe, because otherwise it would initialize to a specific mana value and not keep the same one. It seems like it is just not resetting state correctly.

I reproduced the bug in a brand new save. Now I'll close the game, remove Spark, and see if I can reproduce it in creative again.

Yep.

At this point I am not loading any mods from outside the pack and the bug is still present. I'm not sure if I should still file this as the pack being modified or not, as it no longer is.

Frankly, I have no idea how this doesn't happen for anyone else.

Video of the bug: https://youtu.be/Qv3k00rRJtg
My save file is 700MB compressed.

Steps to reproduce

  1. Add items to a runic altar to start a craft.
  2. Fill the runic altar with mana until it finishes.
  3. Add a livingrock and right-click the altar with a Wand of the Forest.
  4. Bug occurs immediate - Sound of a craft starting is played and the mana spreaders immediately begin firing again with an empty recipe.

Expected behaviour

The Runic Altar should reset to the unused state after completing a craft.

Screenshots

No response

Additional information

No response

@CaptainFord CaptainFord changed the title Botania Runic Altar restarts crafting after completion, and crashes if you attempt to complete the recipe Botania Runic Altar restarts crafting after completion, and crashes if you attempt to complete the blank recipe with a dispenser Dec 30, 2024
@CaptainFord CaptainFord changed the title Botania Runic Altar restarts crafting after completion, and crashes if you attempt to complete the blank recipe with a dispenser Botania Runic Altar restarts crafting after completion (with no items), and crashes if you attempt to complete the blank recipe with a dispenser Jan 2, 2025
@CaptainFord
Copy link
Author

I've done some investigation of the code based on: https://github.com/VazkiiMods/Botania/blob/1.12-final/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java

And that version lists itself as r363, but Interactions is using r364.4, so I guess there's been some changes that aren't in the 1.12-final build, which I'm not exactly surprised by.

But from what I can see in the code, the behavior I'm seeing should be impossible.

For the altar to continue accepting mana, manaToGet must be >0.
But manaToGet is reset to zero every tick if currentRecipe is null.
But currentRecipe isn't rechecked if it's not null, so if it's never cleared or is somehow set again (by say, an invocation of update() updateRecipe() between when currentRecipe is set to null and before the first item in the inventory is removed) that would explain why it charges up and allows you to attempt to complete a blank recipe
But if the recipe isn't null, it actually would work normally and just make a free copy of the item, but instead it throws a NullPointerException on line 248 (which is just int mana = recipe.getManaUsage(); in r363) and crashes, so currentRecipe must actually be null.
But if currentRecipe were null, then on the first tick update after completing crafting, manaToGet would be reset to zero, ending the mana reception and fixing the state of the altar, because manaToGet being >0 is what determines the block's state
So maybe the Runic Altar is being ticked at all! But if that were true, the comparator state wouldn't be getting updated!

Without the crash, there would be a clear and obvious state the tile entity would have to be in to exhibit the behavior I'm observing: currentRecipe still being set.
But the only way to get a crash on the line int mana = recipe.getManaUsage(); is for currentRecipe to be null. And if that is the case, the only way for manaToGet to never be reset for zero is for it to stop ticking. But it definitely still sticks.

What's more, though, is the strangeness of it persisting between save and quits. I need to look into how it is saved and loaded, but if it's just the write and read NBT data, then it doesn't save the recipe, but just the mana and mana target. This makes sense because in the normal case there would be items in the block to restore the recipe from, but when there aren't any, how does it remember the recipe?

... what is happening?

Even if I assume the code has changed and the line number is inaccurate, I don't see any obvious way to get a NullPointerException out of it unless the recipe is null.

So, um, that's as much as I can contribute without getting a dev repo going, and I don't quite understand how to do that.

@CaptainFord
Copy link
Author

CaptainFord commented Jan 3, 2025

Wait, hold on, am I crazy? currentRecipe never gets set! It actually searches all recipes every single tick! JEEZE. (In r363, at least).

This sounds absolutely horrific to debug if it really has only happened to two players. I guess I have to downgrade my version now and see if it still happens.

@CaptainFord
Copy link
Author

Well, just wanted to add I downgraded and tested if the bug did indeed appear in 1.9.0, and yes, it did. If I downgrade to 1.1.0, 1.6.0 or 1.7.0, this bug disappears and the Runic Altar behaves as it supposed to. In version 1.9.0 and 1.10.0 it exhibits the bug I have described so far. Hopefully that helps to narrow it down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant