Provide custom spawn data when spawning via MultiplayerService #1399
-
Hi, I just wonder if its possible to provide custom spawn data when spawning via the multiplayer service? Now my client crashes when spawning my entity, because spawn data is not provided. Example code below // Called on server
Entity entity = spawn("card", new CardSpawnData(x, y, card.suit(), card.rank()));
getMultiplayerService().spawn(connection, entity, "card");
----
// Spawn method
@Spawns("card")
public Entity newCard(SpawnData data) {
if (!(data instanceof CardSpawnData cardSpawnData)) {
throw new IllegalArgumentException("CardSpawnData required");
}
...
}
----
// Custom spawn data
public class CardSpawnData extends SpawnData {
private Suit suit;
private Rank rank;
public CardSpawnData(double x, double y, Suit suit, Rank rank) {
super(x, y);
this.suit = suit;
this.rank = rank;
}
...
} If you have any other ideas on how to achieve this, please let me know |
Beta Was this translation helpful? Give feedback.
Answered by
NotBjoggisAtAll
Feb 1, 2025
Replies: 1 comment
-
Resolved by PR #1400 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
NotBjoggisAtAll
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Resolved by PR #1400