Fix Grown Tardis Item crashing the game if Valkyrien Skies is installed.#579
Fix Grown Tardis Item crashing the game if Valkyrien Skies is installed.#579Acuadragon100 wants to merge 4 commits intoWhoCraft:dev/1.20.1from
Conversation
| private boolean hasPotentialToBeRemoved = false; | ||
| private boolean placedByOtherMod = false; // We don't serialize this by design, because other mods might still create duplicates. | ||
|
|
||
| private SetupState setupData = null; |
There was a problem hiding this comment.
It has been a while since I've been in here. Interesting use of the record here. Does this need to be serialized in any way?
There was a problem hiding this comment.
I just felt that a record was a nice and compact way to keep all parameters in one place.
I did consider serialising it as well, but thought it was unnecessary considering it will only exist for a single game tick, especially since it's only used when Valkyrien Skies is installed. Also, the Grown TARDIS item is a bit of a creative-mode quality of life item, it even has infinite uses in survival mode (is this a bug?).
The main potential concern I could see is that the shell won't re-trigger the setup on it's own when right-clicked (unlike the root shell), so if the server shuts down after using the grown TARDIS item before the next game tick (very unlikely) it will create an unbreakable (even in creative mode, although it can removed with /setblock) and unusable TARDIS shell without an interior.
Serialising it would solve this, but another solution could be to just have the shell delete itself if it doesn't have a valid TARDIS_ID (which it probably should do anyway in my opinion). Let me know which approach you prefer, I'd probably serialise it if you want to future proof things for a potential survival-mode-friendly way to create a TARDIS directly without the root shell.
There was a problem hiding this comment.
Actually, on second thought I decided it would probably be best to serialise it to future-proof the mod.
This also makes it possible to create a TARDIS manually by just placing the shell block with a command, which could be useful.
03a21f6 to
8742a65
Compare
# Conflicts: # changelog.md # common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/ShellBaseBlockEntity.java
Right now, using the Grown Tardis Item (or the dev create command) while Valkyrien Skies is installed crashes the game with the following error:
Note that this does not happen when using the Root Shell.
This patch solves this by creating the dimension during the tick loop (the same way as the Root Shell does it) whenever Valkyrien Skies is installed. I decided to make this change directly in the TardisHelper::createTardis function to future-proof it, but that also means that the return value can't be used to tell if the creation was successful or not anymore (I added some optional lambdas instead). I actually wanted to remove the boolean return value entirely, but decided to leave it alone in case any addons were using it.