forked from minecraft-access/minecraft-access
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: speak current perspective when switch
- Loading branch information
Showing
3 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
common/src/main/java/com/github/khanshoaib3/minecraft_access/mixin/GameOptionsMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.khanshoaib3.minecraft_access.mixin; | ||
|
||
import com.github.khanshoaib3.minecraft_access.MainClass; | ||
import net.minecraft.client.option.GameOptions; | ||
import net.minecraft.client.option.Perspective; | ||
import net.minecraft.client.resource.language.I18n; | ||
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.CallbackInfo; | ||
|
||
@Mixin(GameOptions.class) | ||
public class GameOptionsMixin { | ||
@Inject(method = "setPerspective", at = @At("HEAD")) | ||
void speakPerspectiveWhenSet(Perspective perspective, CallbackInfo ci) { | ||
String keyword = perspective.toString().toLowerCase(); | ||
String translated = I18n.translate("minecraft_access.perspective." + keyword); | ||
MainClass.speakWithNarrator(I18n.translate("minecraft_access.set_perspective", translated), true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters