Skip to content

Commit

Permalink
Fix bug where lecterns wouldn't show book text
Browse files Browse the repository at this point in the history
  • Loading branch information
waffle-stomper committed Oct 11, 2021
1 parent 8be1cd0 commit 2b54e14
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '2.3.2'
version = '2.3.3'
group = 'wafflestomper'
archivesBaseName = '1.17.1-Ghostwriter'

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/wafflestomper/ghostwriter/Ghostwriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ public void tick(TickEvent event) {
}

LOG.debug("Replacing the current screen with a GhostwriterLecternScreen");
GhostwriterLecternScreen g = new GhostwriterLecternScreen(bookStack,
ls.getMenu(), MC.player.getInventory());
GhostwriterLecternScreen g = new GhostwriterLecternScreen(
bookStack,
ls.getMenu(),
MC.player.getInventory()
);
MC.setScreen(g);

LOG.debug("Lectern GUI swap done!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.world.inventory.LecternMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.network.chat.TextComponent;
import wafflestomper.ghostwriter.Ghostwriter;
import wafflestomper.ghostwriter.utilities.BookUtilities;
import wafflestomper.ghostwriter.gui.GhostLayer;
import wafflestomper.ghostwriter.gui.IGhostBook;
Expand Down Expand Up @@ -50,10 +51,13 @@ public void init() {
super.init();
this.ghostLayer.init();
this.updateButtonVisibility();
// I'm not sure why, but this is now necessary before the lectern will show text
this.bookChanged(true);
// This is a hack based on LecternScreen.func_214176_h()
// Books can be left open to a specific page on a lectern. This displays that page.
// Otherwise we'd just be showing the first page every time
this.setPage(this.lecternContainer.getPage());
this.setPage(Math.max(this.lecternContainer.getPage(), 0));
Ghostwriter.LOG.info("Page set to: " + this.currentPage);
}


Expand Down Expand Up @@ -83,7 +87,7 @@ public boolean isBookBeingSigned() {

@Override // From IGhostBook
public void bookChanged(boolean setModifiedFlag) {
this.cachedPage = -1;
super.bookChanged();
}


Expand Down
3 changes: 2 additions & 1 deletion update.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"homepage": "https://github.com/waffle-stomper/Ghostwriter/releases",
"promos":{
"1.17.1-latest": "2.3.2",
"1.17.1-latest": "2.3.3",
"1.16.5-recommended": "2.2.6",
"1.16.4-recommended": "2.2.9",
"1.16.3-recommended": "2.3.1",
Expand All @@ -18,6 +18,7 @@
"1.10-recommended": "1.8.5"
},
"1.17.1": {
"2.3.3": "Fix lecterns not showing book text",
"2.3.2": "Update to 1.17.1"
},
"1.16.5": {
Expand Down

0 comments on commit 2b54e14

Please sign in to comment.