Open Parties and Claims

Open Parties and Claims

25M Downloads

ServerLevelHelper getServerLevel is nullable yet you dont null check

MehVahdJukaar opened this issue ยท 4 comments

commented

public static ServerLevel getServerLevel(Level level){//simply casting to ServerLevel doesn't work with wrappers that override Level (like in the case of Create deployers using buckets)

In bucket use event you are not checking if the level returned by that method is null

Happens in 1.20 forge

a log where that happens https://mclo.gs/RzqjtC7

This causes a crash btw.

I think issue is here but there's an off chance that it might be somewhere else. incase lmk

commented

Returning a non-null server is only part of the problem here. OPAC assumes that a non-null getServer() guarantees being on the server thread, which is wrong in rare cases like this, and I'm going to fix that. If getServer() was null, then the crashing code would not be reached. But null-checking the result of getServerLevel is necessary too, as something like this, where the dimension key isn't usable, can still be a problem even on the server thread.

commented

I think I just somehow didn't expect a bucket to be used by an entity with a non-null getServer() at a fake level with a dimension key for a non-existent dimension. It's obvious right now I should have though.
All of this happening on the render thread made me realize another issue that would occur even after I fix this which I'll fix as well.

commented

hmm that's odd my entity should return a not null server. There was a short lived bug here that wasn't the case. I'll have to check they weren't using that version

commented

Entity returns forge hooks.getcurrentserver()