Skip to content

Commit

Permalink
Release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Fireplace committed Sep 14, 2020
1 parent 412e9ba commit 55b1e86
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/main/java/the_fireplace/audiobook/AudiobookLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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 BookScreen.Contents contents) {
if(contents != null) {
List<String> 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<String> pages) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
Binary file modified src/main/resources/assets/audiobook/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 55b1e86

Please sign in to comment.