Skip to content

Commit

Permalink
Narration can now be cancelled on the title screen
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Fireplace committed Jul 21, 2021
1 parent 8fde763 commit fa84ac7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Change license to MPL-2.0
Add Russian translation (kyrtion)
Add Russian translation (kyrtion)
Narration can now be cancelled on the title screen
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void handleInputEvents(CallbackInfo info) {
} else if (AudiobookLogic.isReadableBook(player.getStackInHand(Hand.OFF_HAND))) {
AudiobookLogic.playBook(player.getStackInHand(Hand.OFF_HAND));
}
} else if(Audiobook.stopAudiobookKey.isPressed()) {
} else if (Audiobook.stopAudiobookKey.isPressed()) {
AudiobookLogic.stopNarration();
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/the_fireplace/audiobook/mixin/ScreenMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package the_fireplace.audiobook.mixin;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import the_fireplace.audiobook.Audiobook;
import the_fireplace.audiobook.AudiobookLogic;

@Environment(EnvType.CLIENT)
@Mixin(Screen.class)
public final class ScreenMixin {

@Inject(at = @At(value="HEAD"), method = "keyPressed")
private void onKeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
if (Audiobook.stopAudiobookKey.matchesKey(keyCode, scanCode)) {
AudiobookLogic.stopNarration();
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/audiobook.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"compatibilityLevel": "JAVA_8",
"client": [
"BookScreenMixin",
"MinecraftClientMixin"
"MinecraftClientMixin",
"ScreenMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit fa84ac7

Please sign in to comment.