Skip to content

Commit

Permalink
feat: speak current perspective when switch
Browse files Browse the repository at this point in the history
  • Loading branch information
boholder committed Aug 17, 2024
1 parent 47d0d64 commit dd48d04
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
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);
}
}
2 changes: 1 addition & 1 deletion common/src/main/resources/assets/minecraft_access/lang
Submodule lang updated 2 files
+4 −0 en_us.json
+4 −0 zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"DurabilityMixin",
"EntityAccessor",
"EyeOfEnderEntityMixin",
"GameOptionsMixin",
"HandledScreenAccessor",
"I18NAccessor",
"I18nMixin",
Expand Down

0 comments on commit dd48d04

Please sign in to comment.