Skip to content

Commit

Permalink
Fix crash when opening book from menu screen (but not in the test env…
Browse files Browse the repository at this point in the history
…ironment for some reason????)
  • Loading branch information
JunePrimavera committed Apr 26, 2024
1 parent cc9f075 commit 79b95e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/xyz/sillyjune/notebook/NotebookScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected void goToNextPage() {
protected void init() {
DATA = NotebookData.read("default.json");
pageIndex = 0;
this.cursorIndex = readPage(pageIndex).length();

// Add done/close button
closeButton = this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (_) -> this.close()).dimensions(this.width / 2 - 100, 196, 200, 20).build());
// Page buttons
Expand All @@ -128,6 +128,7 @@ protected void init() {
buttonLast = this.addDrawableChild(new TexturedButtonWidget(30, 30, 20, 20, LAST_BOOK_ICON, (_) -> last_book()));
buttonGo = this.addDrawableChild(new TexturedButtonWidget(55, 30, 20, 20, RENAME_BOOK_ICON, (_) -> DATA = new NotebookData(DATA.content, STR."\{this.bookNameField.getText()}.json")));
this.updatePageButtons();
this.cursorIndex = readPage(pageIndex).length();
}
// Refresh page buttons
private void updatePageButtons() {
Expand Down

0 comments on commit 79b95e1

Please sign in to comment.