Skip to content

Commit

Permalink
Fixed disconnect when joining a multiplayer server
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Jan 12, 2022
1 parent 472034b commit 09f76a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,12 @@ public boolean test(SpellTraits t) {
}

public void write(PacketByteBuf buf) {
min.ifPresentOrElse(m -> {
buf.writeBoolean(true);
m.write(buf);
}, () -> buf.writeBoolean(false));
max.ifPresentOrElse(m -> {
buf.writeBoolean(true);
m.write(buf);
}, () -> buf.writeBoolean(false));
buf.writeOptional(min, (b, m) -> m.write(b));
buf.writeOptional(max, (b, m) -> m.write(b));
}

public static TraitIngredient fromPacket(PacketByteBuf buf) {
Optional<SpellTraits> min = Optional.empty();
Optional<SpellTraits> max = Optional.empty();
return new TraitIngredient(min, max);
return new TraitIngredient(SpellTraits.fromPacket(buf), SpellTraits.fromPacket(buf));
}

public static TraitIngredient fromJson(JsonObject json) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ public static Optional<SpellTraits> fromJson(JsonObject traits) {
}

public static Optional<SpellTraits> fromPacket(PacketByteBuf buf) {

boolean present = buf.readBoolean();
if (!present) {
return Optional.empty();
}

Map<Trait, Float> entries = new HashMap<>();
int count = buf.readInt();
if (count <= 0) {
Expand Down

0 comments on commit 09f76a4

Please sign in to comment.