MutableBlockPos is unnecessary and causes sporadic crashes with other mods
linuskr opened this issue ยท 4 comments
After many hours of debugging i managed to trace a java.lang.IllegalStateException: TickNextTick list out of synch
server crash back to this mod's MutableBlockPos and (probably) dynamic trees (and possibly random patches?).
This Exception is thrown when pendingTickListEntriesTreeSet
and pendingTickListEntriesHashSet
differ. This seems to be caused by NextTickListEntry
s not being removed from the HashSet if their .position
is an instance of MutableBlockPos
. I don't know why this happens, it might be related to an issue with equals
and compareTo
as described here.
Vanilla also has a MutableBlockPos
class, with one difference: Vanilla's BlockPos
provides a method toImmutable()
, which for the normal BlockPos
is implemented as a simple return this;
. In the vanilla MutableBlockPos
though this method is overriden with return new BlockPos(this);
. Because NextTickListEntry.<init>
calls toImmutable
, all positions should be normal BlockPos
, but because thut.api.maths.Vector3$MutableBlockPos
doesn't override toImmutable
, it uses the identity inherited from BlockPos
instead.
I managed to fix this for me by adding a check in pendingTickListEntriesHashSet#add
and, if the position is not an instance of BlockPos
, replacing it using reflection.
Since i am on 1.12.2 and this repo only has the source for more recent versions i can't build a fix, but as vanilla minecraft now provides a MutableBlockPos
it should be relatively simple to remove ThutCore's MutableBlockPos
(or at least override toImmutable
).
this is fixed for the next 1.15.2 update, that was some really old stuff that I forgot to update, from before vanilla had an easily accessible immutable block pos...
you can find the obsolete 1.12.2 code here if you did want to make the change on your end: https://github.com/Thutmose/Thut/tree/1.12.x