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

MutableBlockPos is unnecessary and causes sporadic crashes with other mods #3

Open
linuskr opened this issue May 20, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@linuskr
Copy link

linuskr commented May 20, 2020

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 NextTickListEntrys 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).

@Thutmose
Copy link
Contributor

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...

@Thutmose
Copy link
Contributor

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

@Thutmose
Copy link
Contributor

I forgot that saying "fix" would automatically close the issue...

@Thutmose Thutmose added the bug Something isn't working label May 20, 2020
@Thutmose
Copy link
Contributor

this is fixed in the new 1.15.2 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants