-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
PacketDistributor crashes when given a custom Level implementation #1669
Comments
It uses the So are you asking for the method to |
yes it should only throw if passed a non client side level. Right now it crashes for any level that does not return a ServerChunkCache |
Calling the method with a |
I am not directly doing it. I am passing a fake level around and something (from mods) is eventually calling a send packet after they check level.isClientSide which is completely reasonable. |
Could you show your relevant custom |
Based on the current context, I think the following logic is more appropriate, but I'm intrigued by this custom server level implementation which apparently also has a custom chunk source implementation behind it. public static void sendToPlayersTrackingEntity(Entity entity, CustomPacketPayload payload, CustomPacketPayload... payloads) {
if (entity.level().isClientSide) {
throw new IllegalStateException("Cannot send clientbound payloads on the client");
} else if (entity.level().getChunkSource() instanceof ServerChunkCache chunkCache) {
chunkCache.broadcast(entity, makeClientboundPacket(payload, payloads));
}
// Silently ignore custom Level implementations which may not return ServerChunkCache.
} |
This is my level impl. Just returns an empty chunk source https://github.com/MehVahdJukaar/Moonlight/blob/1.20/common/src/main/java/net/mehvahdjukaar/moonlight/core/misc/FakeLevel.java |
🚀 This issue has been resolved in NeoForge version |
Basically this.
Assumption is that a Level impl that does NOT return a ServerChunk cache (which would be hard to do for custom fake levels impls) IS a ClientLevel which is not the case.
It should instead check if level is client side and just throw of that is true.
Tested on neoforge 21.1.57
The text was updated successfully, but these errors were encountered: