Skip to content

Commit

Permalink
1.20.4 NeoForge networking fixes (#729)
Browse files Browse the repository at this point in the history
* Update NeoForge

* Localize the NeoForge networking errors

* Fix Open Book message on NeoForge disconnecting players
  • Loading branch information
Mrbysco authored Feb 26, 2024
1 parent 0e43b26 commit b328454
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion NeoForge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ runs {
}

dependencies {
implementation "net.neoforged:neoforge:20.4.124-beta"
implementation "net.neoforged:neoforge:20.4.173"
implementation project(":Xplat")

compileOnly "mezz.jei:jei-1.20.4-common-api:17.0.0.30"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ public record NeoForgeMessageOpenBookGui(ResourceLocation book, @Nullable Resour
public static final ResourceLocation ID = new ResourceLocation(PatchouliAPI.MOD_ID, "open_book");

public NeoForgeMessageOpenBookGui(FriendlyByteBuf buf) {
this(buf.readResourceLocation(), ResourceLocation.tryParse(buf.readUtf()), buf.readVarInt());
this(buf.readResourceLocation(), getEntry(buf), buf.readVarInt());
}

private static ResourceLocation getEntry(FriendlyByteBuf buf) {
String entry = buf.readUtf();
return entry.isEmpty() ? null : new ResourceLocation(entry);
}

public void write(FriendlyByteBuf buf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void handleData(final NeoForgeMessageOpenBookGui data, final PlayPayloadC
})
.exceptionally(e -> {
// Handle exception
context.packetHandler().disconnect(Component.translatable("patchouli.networking.failed", e.getMessage()));
context.packetHandler().disconnect(Component.translatable("patchouli.networking.open_book.failed", e.getMessage()));
return null;
});
}
Expand All @@ -31,7 +31,7 @@ public void handleData(final NeoForgeMessageReloadBookContents data, final PlayP
})
.exceptionally(e -> {
// Handle exception
context.packetHandler().disconnect(Component.translatable("patchouli.networking.failed", e.getMessage()));
context.packetHandler().disconnect(Component.translatable("patchouli.networking.reload_contents.failed", e.getMessage()));
return null;
});
}
Expand Down
5 changes: 4 additions & 1 deletion Xplat/src/main/resources/assets/patchouli/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,8 @@
"patchouli.gui.lexicon.button.visualize.info": "(Click again to clear)",
"patchouli.gui.lexicon.button.history": "History",
"patchouli.gui.lexicon.button.mark_all_read": "Mark all as read",
"patchouli.gui.lexicon.button.mark_category_read": "Mark this category as read"
"patchouli.gui.lexicon.button.mark_category_read": "Mark this category as read",

"patchouli.networking.open_book.failed": "Failed to open book %s",
"patchouli.networking.reload_contents.invalid": "Failed to reload contents %S"
}

0 comments on commit b328454

Please sign in to comment.