Skip to content

Commit

Permalink
Add Level fallback to PacketHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jun 22, 2024
1 parent 57b0f4e commit 93dafb4
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ protected <P extends PacketBase> void registerActual(IPayloadRegistrar registrar

@OnlyIn(Dist.CLIENT)
public void handlePacketClient(PlayPayloadContext context, PacketBase packet) {
packet.actionClient(context.level().orElse(null), Minecraft.getInstance().player);
packet.actionClient(context.level().orElse(Minecraft.getInstance().player != null ? Minecraft.getInstance().player.level() : null), Minecraft.getInstance().player);
}

public void handlePacketServer(PlayPayloadContext context, PacketBase packet) {
packet.actionServer(context.level().orElse(null), (ServerPlayer) context.player().get());
packet.actionServer(context.level().orElse(context.player().isPresent() ? context.player().get().level() : null), (ServerPlayer) context.player().get());
}

/**
Expand Down

0 comments on commit 93dafb4

Please sign in to comment.