diff --git a/src/main/java/the_fireplace/audiobook/AudiobookLogic.java b/src/main/java/the_fireplace/audiobook/AudiobookLogic.java index 84d62c4..f3c95b1 100644 --- a/src/main/java/the_fireplace/audiobook/AudiobookLogic.java +++ b/src/main/java/the_fireplace/audiobook/AudiobookLogic.java @@ -10,14 +10,16 @@ public class AudiobookLogic { public static void playBook(ItemStack stack) { - playBook(stack.hasTag() && stack.getTag() != null ? BookScreen.readPages(stack.getTag()) : null); + playBook(stack.hasTag() && stack.getTag() != null ? BookScreen.Contents.create(stack) : null); } - public static void playBook(BookScreen.Contents contents) { - List pages = Lists.newArrayListWithCapacity(contents.getPageCount()); - for(int i=0;i pages = Lists.newArrayListWithCapacity(contents.getPageCount()); + for (int i = 0; i < contents.getPageCount(); i++) + pages.add(contents.getPage(i).getString()); + playBook(pages); + } } public static void playBook(@Nullable List pages) { diff --git a/src/main/java/the_fireplace/audiobook/mixin/MinecraftClientMixin.java b/src/main/java/the_fireplace/audiobook/mixin/MinecraftClientMixin.java index e2b6fb1..48fee40 100644 --- a/src/main/java/the_fireplace/audiobook/mixin/MinecraftClientMixin.java +++ b/src/main/java/the_fireplace/audiobook/mixin/MinecraftClientMixin.java @@ -3,7 +3,8 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ingame.BookScreen; import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.BookItem; +import net.minecraft.item.WritableBookItem; +import net.minecraft.item.WrittenBookItem; import net.minecraft.util.Hand; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -24,9 +25,9 @@ public abstract class MinecraftClientMixin { private void handleInputEvents(CallbackInfo info) { if(Audiobook.audiobookKey.isPressed() && player != null) { //noinspection ConstantConditions - if(player.getStackInHand(Hand.MAIN_HAND).getItem() instanceof BookItem && player.getStackInHand(Hand.MAIN_HAND).hasTag() && player.getStackInHand(Hand.MAIN_HAND).getTag().contains("pages") && !BookScreen.readPages(player.getStackInHand(Hand.MAIN_HAND).getTag()).isEmpty()) + if((player.getStackInHand(Hand.MAIN_HAND).getItem() instanceof WrittenBookItem || player.getStackInHand(Hand.MAIN_HAND).getItem() instanceof WritableBookItem) && player.getStackInHand(Hand.MAIN_HAND).hasTag() && !BookScreen.readPages(player.getStackInHand(Hand.MAIN_HAND).getTag()).isEmpty()) AudiobookLogic.playBook(player.getStackInHand(Hand.MAIN_HAND)); - else if(player.getStackInHand(Hand.OFF_HAND).getItem() instanceof BookItem) + else if(player.getStackInHand(Hand.OFF_HAND).getItem() instanceof WrittenBookItem || player.getStackInHand(Hand.OFF_HAND).getItem() instanceof WritableBookItem) AudiobookLogic.playBook(player.getStackInHand(Hand.OFF_HAND)); } else if(Audiobook.stopAudiobookKey.isPressed()) AudiobookLogic.stopNarration(); diff --git a/src/main/resources/assets/audiobook/icon.png b/src/main/resources/assets/audiobook/icon.png index 600940f..795cc34 100644 Binary files a/src/main/resources/assets/audiobook/icon.png and b/src/main/resources/assets/audiobook/icon.png differ