mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Fixed disconnect when joining a multiplayer server
This commit is contained in:
parent
472034bf15
commit
09f76a4286
2 changed files with 9 additions and 11 deletions
|
@ -22,20 +22,12 @@ public record TraitIngredient (
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(PacketByteBuf buf) {
|
public void write(PacketByteBuf buf) {
|
||||||
min.ifPresentOrElse(m -> {
|
buf.writeOptional(min, (b, m) -> m.write(b));
|
||||||
buf.writeBoolean(true);
|
buf.writeOptional(max, (b, m) -> m.write(b));
|
||||||
m.write(buf);
|
|
||||||
}, () -> buf.writeBoolean(false));
|
|
||||||
max.ifPresentOrElse(m -> {
|
|
||||||
buf.writeBoolean(true);
|
|
||||||
m.write(buf);
|
|
||||||
}, () -> buf.writeBoolean(false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TraitIngredient fromPacket(PacketByteBuf buf) {
|
public static TraitIngredient fromPacket(PacketByteBuf buf) {
|
||||||
Optional<SpellTraits> min = Optional.empty();
|
return new TraitIngredient(SpellTraits.fromPacket(buf), SpellTraits.fromPacket(buf));
|
||||||
Optional<SpellTraits> max = Optional.empty();
|
|
||||||
return new TraitIngredient(min, max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TraitIngredient fromJson(JsonObject json) {
|
public static TraitIngredient fromJson(JsonObject json) {
|
||||||
|
|
|
@ -216,6 +216,12 @@ public final class SpellTraits implements Iterable<Map.Entry<Trait, Float>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<SpellTraits> fromPacket(PacketByteBuf buf) {
|
public static Optional<SpellTraits> fromPacket(PacketByteBuf buf) {
|
||||||
|
|
||||||
|
boolean present = buf.readBoolean();
|
||||||
|
if (!present) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
Map<Trait, Float> entries = new HashMap<>();
|
Map<Trait, Float> entries = new HashMap<>();
|
||||||
int count = buf.readInt();
|
int count = buf.readInt();
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
|
|
Loading…
Reference in a new issue