diff --git a/src/main/java/jerozgen/languagereload/LanguageReload.java b/src/main/java/jerozgen/languagereload/LanguageReload.java index 4925114..42905d8 100644 --- a/src/main/java/jerozgen/languagereload/LanguageReload.java +++ b/src/main/java/jerozgen/languagereload/LanguageReload.java @@ -35,28 +35,29 @@ public static void reloadLanguages() { // Update book and advancements screens if (client.currentScreen instanceof BookScreen bookScreen) { - ((BookScreenAccessor) bookScreen).setCachedPageIndex(-1); + ((BookScreenAccessor) bookScreen).languagereload_setCachedPageIndex(-1); } else if (client.currentScreen instanceof AdvancementsScreen advancementsScreen) { - ((IAdvancementsScreen) advancementsScreen).recreateWidgets(); + ((IAdvancementsScreen) advancementsScreen).languagereload_recreateWidgets(); } // Update signs if (client.world == null) return; var chunkManager = (ClientChunkManagerAccessor) client.world.getChunkManager(); - var chunks = ((ClientChunkMapAccessor) chunkManager.getChunks()).getChunks(); + var chunks = ((ClientChunkMapAccessor) chunkManager.languagereload_getChunks()).languagereload_getChunks(); for (int i = 0; i < chunks.length(); i++) { var chunk = chunks.get(i); if (chunk == null) continue; for (var blockEntity : chunk.getBlockEntities().values()) { if (!(blockEntity instanceof SignBlockEntity sign)) continue; - ((SignBlockEntityAccessor) sign).setTextsBeingEdited(null); + ((SignBlockEntityAccessor) sign).languagereload_setTextsBeingEdited(null); } } } public static void reloadSearch() { var client = MinecraftClient.getInstance(); - ((MinecraftClientAccessor) client).getSearchManager().reload(client.getResourceManager()); + var searchManager = ((MinecraftClientAccessor) client).languagereload_getSearchManager(); + searchManager.reload(client.getResourceManager()); } public static void setLanguage(String language, LinkedList fallbacks) { diff --git a/src/main/java/jerozgen/languagereload/access/IAdvancementsScreen.java b/src/main/java/jerozgen/languagereload/access/IAdvancementsScreen.java index 6e59217..3b1959b 100644 --- a/src/main/java/jerozgen/languagereload/access/IAdvancementsScreen.java +++ b/src/main/java/jerozgen/languagereload/access/IAdvancementsScreen.java @@ -5,5 +5,5 @@ @Environment(EnvType.CLIENT) public interface IAdvancementsScreen { - void recreateWidgets(); + void languagereload_recreateWidgets(); } diff --git a/src/main/java/jerozgen/languagereload/access/IAdvancementsTab.java b/src/main/java/jerozgen/languagereload/access/IAdvancementsTab.java index 4a38414..0081e62 100644 --- a/src/main/java/jerozgen/languagereload/access/IAdvancementsTab.java +++ b/src/main/java/jerozgen/languagereload/access/IAdvancementsTab.java @@ -5,5 +5,5 @@ @Environment(EnvType.CLIENT) public interface IAdvancementsTab { - void recreateWidgets(); + void languagereload_recreateWidgets(); } diff --git a/src/main/java/jerozgen/languagereload/access/ILanguageOptionsScreen.java b/src/main/java/jerozgen/languagereload/access/ILanguageOptionsScreen.java index 3116f08..835a587 100644 --- a/src/main/java/jerozgen/languagereload/access/ILanguageOptionsScreen.java +++ b/src/main/java/jerozgen/languagereload/access/ILanguageOptionsScreen.java @@ -3,5 +3,5 @@ import jerozgen.languagereload.gui.LanguageEntry; public interface ILanguageOptionsScreen { - void focusEntry(LanguageEntry entry); + void languagereload_focusEntry(LanguageEntry entry); } diff --git a/src/main/java/jerozgen/languagereload/access/ITranslationStorage.java b/src/main/java/jerozgen/languagereload/access/ITranslationStorage.java index a91d36f..2dbba8c 100644 --- a/src/main/java/jerozgen/languagereload/access/ITranslationStorage.java +++ b/src/main/java/jerozgen/languagereload/access/ITranslationStorage.java @@ -6,7 +6,7 @@ @Environment(EnvType.CLIENT) public interface ITranslationStorage { - @Nullable String getTargetLanguage(); + @Nullable String languagereload_getTargetLanguage(); - void setTargetLanguage(@Nullable String value); + void languagereload_setTargetLanguage(@Nullable String value); } diff --git a/src/main/java/jerozgen/languagereload/gui/LanguageListWidget.java b/src/main/java/jerozgen/languagereload/gui/LanguageListWidget.java index 9364425..b74aab8 100644 --- a/src/main/java/jerozgen/languagereload/gui/LanguageListWidget.java +++ b/src/main/java/jerozgen/languagereload/gui/LanguageListWidget.java @@ -46,7 +46,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (keyCode == GLFW_KEY_SPACE || keyCode == GLFW_KEY_ENTER) { selectedEntry.toggle(); this.setFocused(null); - ((ILanguageOptionsScreen) screen).focusEntry(selectedEntry); + ((ILanguageOptionsScreen) screen).languagereload_focusEntry(selectedEntry); return true; } @@ -81,7 +81,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { return true; } - return ((EntryListWidgetAccessor) this).isScrolling(); + return ((EntryListWidgetAccessor) this).languagereload_isScrolling(); } @Override diff --git a/src/main/java/jerozgen/languagereload/mixin/AdvancementTabMixin.java b/src/main/java/jerozgen/languagereload/mixin/AdvancementTabMixin.java index 7bf32aa..5c2bcb6 100644 --- a/src/main/java/jerozgen/languagereload/mixin/AdvancementTabMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/AdvancementTabMixin.java @@ -19,17 +19,17 @@ public abstract class AdvancementTabMixin extends DrawableHelper implements IAdv @Shadow @Final private Map widgets; @Override - public void recreateWidgets() { + public void languagereload_recreateWidgets() { widgets.replaceAll((advancement, widget) -> { var newWidget = new AdvancementWidget( - ((AdvancementWidgetAccessor) widget).getTab(), + ((AdvancementWidgetAccessor) widget).languagereload_getTab(), client, advancement, Objects.requireNonNull(advancement.getDisplay()) ); - newWidget.setProgress(((AdvancementWidgetAccessor) widget).getProgress()); - ((AdvancementWidgetAccessor) newWidget).setParent(((AdvancementWidgetAccessor) widget).getParent()); - ((AdvancementWidgetAccessor) newWidget).setChildren(((AdvancementWidgetAccessor) widget).getChildren()); + newWidget.setProgress(((AdvancementWidgetAccessor) widget).languagereload_getProgress()); + ((AdvancementWidgetAccessor) newWidget).languagereload_setParent(((AdvancementWidgetAccessor) widget).languagereload_getParent()); + ((AdvancementWidgetAccessor) newWidget).languagereload_setChildren(((AdvancementWidgetAccessor) widget).languagereload_getChildren()); return newWidget; }); } diff --git a/src/main/java/jerozgen/languagereload/mixin/AdvancementWidgetAccessor.java b/src/main/java/jerozgen/languagereload/mixin/AdvancementWidgetAccessor.java index c4023e8..ecc650d 100644 --- a/src/main/java/jerozgen/languagereload/mixin/AdvancementWidgetAccessor.java +++ b/src/main/java/jerozgen/languagereload/mixin/AdvancementWidgetAccessor.java @@ -11,22 +11,22 @@ @Mixin(AdvancementWidget.class) public interface AdvancementWidgetAccessor { - @Accessor - AdvancementTab getTab(); + @Accessor("tab") + AdvancementTab languagereload_getTab(); - @Accessor - AdvancementProgress getProgress(); + @Accessor("progress") + AdvancementProgress languagereload_getProgress(); - @Accessor - AdvancementWidget getParent(); + @Accessor("parent") + AdvancementWidget languagereload_getParent(); - @Accessor - void setParent(AdvancementWidget parent); + @Accessor("parent") + void languagereload_setParent(AdvancementWidget parent); - @Accessor - List getChildren(); + @Accessor("children") + List languagereload_getChildren(); @Mutable - @Accessor - void setChildren(List children); + @Accessor("children") + void languagereload_setChildren(List children); } diff --git a/src/main/java/jerozgen/languagereload/mixin/AdvancementsScreenMixin.java b/src/main/java/jerozgen/languagereload/mixin/AdvancementsScreenMixin.java index cf10410..54e08a8 100644 --- a/src/main/java/jerozgen/languagereload/mixin/AdvancementsScreenMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/AdvancementsScreenMixin.java @@ -23,9 +23,9 @@ protected AdvancementsScreenMixin(Text title) { } @Override - public void recreateWidgets() { + public void languagereload_recreateWidgets() { for (var advancementTab : tabs.values()) { - ((IAdvancementsTab) advancementTab).recreateWidgets(); + ((IAdvancementsTab) advancementTab).languagereload_recreateWidgets(); } } } diff --git a/src/main/java/jerozgen/languagereload/mixin/BookScreenAccessor.java b/src/main/java/jerozgen/languagereload/mixin/BookScreenAccessor.java index f8f6960..728838f 100644 --- a/src/main/java/jerozgen/languagereload/mixin/BookScreenAccessor.java +++ b/src/main/java/jerozgen/languagereload/mixin/BookScreenAccessor.java @@ -6,6 +6,6 @@ @Mixin(BookScreen.class) public interface BookScreenAccessor { - @Accessor - void setCachedPageIndex(int cachedPageIndex); + @Accessor("cachedPageIndex") + void languagereload_setCachedPageIndex(int cachedPageIndex); } diff --git a/src/main/java/jerozgen/languagereload/mixin/ClientChunkManagerAccessor.java b/src/main/java/jerozgen/languagereload/mixin/ClientChunkManagerAccessor.java index 34d4c2f..97f64bc 100644 --- a/src/main/java/jerozgen/languagereload/mixin/ClientChunkManagerAccessor.java +++ b/src/main/java/jerozgen/languagereload/mixin/ClientChunkManagerAccessor.java @@ -6,6 +6,6 @@ @Mixin(ClientChunkManager.class) public interface ClientChunkManagerAccessor { - @Accessor - ClientChunkManager.ClientChunkMap getChunks(); + @Accessor("chunks") + ClientChunkManager.ClientChunkMap languagereload_getChunks(); } diff --git a/src/main/java/jerozgen/languagereload/mixin/ClientChunkMapAccessor.java b/src/main/java/jerozgen/languagereload/mixin/ClientChunkMapAccessor.java index 6b83320..c30df21 100644 --- a/src/main/java/jerozgen/languagereload/mixin/ClientChunkMapAccessor.java +++ b/src/main/java/jerozgen/languagereload/mixin/ClientChunkMapAccessor.java @@ -9,6 +9,6 @@ @Mixin(ClientChunkManager.ClientChunkMap.class) public interface ClientChunkMapAccessor { - @Accessor - AtomicReferenceArray getChunks(); + @Accessor("chunks") + AtomicReferenceArray languagereload_getChunks(); } diff --git a/src/main/java/jerozgen/languagereload/mixin/EntryListWidgetAccessor.java b/src/main/java/jerozgen/languagereload/mixin/EntryListWidgetAccessor.java index 17ccf3d..87915d8 100644 --- a/src/main/java/jerozgen/languagereload/mixin/EntryListWidgetAccessor.java +++ b/src/main/java/jerozgen/languagereload/mixin/EntryListWidgetAccessor.java @@ -6,6 +6,6 @@ @Mixin(EntryListWidget.class) public interface EntryListWidgetAccessor { - @Accessor - boolean isScrolling(); + @Accessor("scrolling") + boolean languagereload_isScrolling(); } diff --git a/src/main/java/jerozgen/languagereload/mixin/KeyboardMixin.java b/src/main/java/jerozgen/languagereload/mixin/KeyboardMixin.java index 69c7269..3264588 100644 --- a/src/main/java/jerozgen/languagereload/mixin/KeyboardMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/KeyboardMixin.java @@ -13,6 +13,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -32,6 +33,7 @@ public abstract class KeyboardMixin { @Shadow protected abstract void debugError(String key, Object... args); + @Unique private void processLanguageReloadKeys() { if (Screen.hasShiftDown()) { var config = Config.getInstance(); diff --git a/src/main/java/jerozgen/languagereload/mixin/LanguageOptionsScreenMixin.java b/src/main/java/jerozgen/languagereload/mixin/LanguageOptionsScreenMixin.java index b580ce7..c1e3fa2 100644 --- a/src/main/java/jerozgen/languagereload/mixin/LanguageOptionsScreenMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/LanguageOptionsScreenMixin.java @@ -17,6 +17,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -28,12 +29,12 @@ public abstract class LanguageOptionsScreenMixin extends GameOptionsScreen implements ILanguageOptionsScreen { @Shadow @Final private static Text LANGUAGE_WARNING_TEXT; - private LanguageListWidget availableLanguageList; - private LanguageListWidget selectedLanguageList; - private TextFieldWidget searchBox; - private final LinkedList selectedLanguages = new LinkedList<>(); - private final Map languageEntries = new LinkedHashMap<>(); - private LockedLanguageEntry defaultLanguageEntry; + @Unique private LanguageListWidget availableLanguageList; + @Unique private LanguageListWidget selectedLanguageList; + @Unique private TextFieldWidget searchBox; + @Unique private final LinkedList selectedLanguages = new LinkedList<>(); + @Unique private final Map languageEntries = new LinkedHashMap<>(); + @Unique private LockedLanguageEntry defaultLanguageEntry; LanguageOptionsScreenMixin(Screen parent, GameOptions options, Text title) { super(parent, options, title); @@ -86,6 +87,7 @@ public void setFocused(boolean focused) { ci.cancel(); } + @Unique private void onDone(ButtonWidget button) { if (client == null) return; client.setScreen(parent); @@ -101,7 +103,7 @@ private void onDone(ButtonWidget button) { } @Override - public void focusEntry(LanguageEntry entry) { + public void languagereload_focusEntry(LanguageEntry entry) { ((AlwaysSelectedEntryListWidgetAccessor) availableLanguageList).setInFocus(false); ((AlwaysSelectedEntryListWidgetAccessor) selectedLanguageList).setInFocus(false); entry.getParent().setSelected(entry); @@ -109,12 +111,14 @@ public void focusEntry(LanguageEntry entry) { setFocused(entry.getParent()); } - public void focusSearch() { + @Unique + private void focusSearch() { ((AlwaysSelectedEntryListWidgetAccessor) availableLanguageList).setInFocus(false); ((AlwaysSelectedEntryListWidgetAccessor) selectedLanguageList).setInFocus(false); setFocused(searchBox); } + @Unique private void refresh() { refreshList(selectedLanguageList, Stream.concat( selectedLanguages.stream().map(languageEntries::get).filter(Objects::nonNull), @@ -129,6 +133,7 @@ private void refresh() { })); } + @Unique private void refreshList(LanguageListWidget list, Stream entries) { var selectedEntry = list.getSelectedOrNull(); list.setSelected(null); diff --git a/src/main/java/jerozgen/languagereload/mixin/MinecraftClientAccessor.java b/src/main/java/jerozgen/languagereload/mixin/MinecraftClientAccessor.java index ca2d72c..7beacea 100644 --- a/src/main/java/jerozgen/languagereload/mixin/MinecraftClientAccessor.java +++ b/src/main/java/jerozgen/languagereload/mixin/MinecraftClientAccessor.java @@ -7,6 +7,6 @@ @Mixin(MinecraftClient.class) public interface MinecraftClientAccessor { - @Accessor - SearchManager getSearchManager(); + @Accessor("searchManager") + SearchManager languagereload_getSearchManager(); } diff --git a/src/main/java/jerozgen/languagereload/mixin/MinecraftClientMixin.java b/src/main/java/jerozgen/languagereload/mixin/MinecraftClientMixin.java index 00fe953..d2f1230 100644 --- a/src/main/java/jerozgen/languagereload/mixin/MinecraftClientMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/MinecraftClientMixin.java @@ -29,13 +29,13 @@ private static String addFallbackTranslationsToSearchTooltips(Text text) { var stringBuilder = new StringBuilder(text.getString()); for (String fallbackCode : Config.getInstance().fallbacks) { - ((ITranslationStorage) translationStorage).setTargetLanguage(fallbackCode); + ((ITranslationStorage) translationStorage).languagereload_setTargetLanguage(fallbackCode); stringBuilder.append('\n').append(text.getString()); } - ((ITranslationStorage) translationStorage).setTargetLanguage(Language.DEFAULT_LANGUAGE); + ((ITranslationStorage) translationStorage).languagereload_setTargetLanguage(Language.DEFAULT_LANGUAGE); stringBuilder.append('\n').append(text.getString()); - ((ITranslationStorage) translationStorage).setTargetLanguage(null); + ((ITranslationStorage) translationStorage).languagereload_setTargetLanguage(null); return stringBuilder.toString(); } } diff --git a/src/main/java/jerozgen/languagereload/mixin/SignBlockEntityAccessor.java b/src/main/java/jerozgen/languagereload/mixin/SignBlockEntityAccessor.java index c7e42a8..84be0d2 100644 --- a/src/main/java/jerozgen/languagereload/mixin/SignBlockEntityAccessor.java +++ b/src/main/java/jerozgen/languagereload/mixin/SignBlockEntityAccessor.java @@ -7,6 +7,6 @@ @Mixin(SignBlockEntity.class) public interface SignBlockEntityAccessor { - @Accessor - void setTextsBeingEdited(OrderedText[] textsBeingEdited); + @Accessor("textsBeingEdited") + void languagereload_setTextsBeingEdited(OrderedText[] textsBeingEdited); } diff --git a/src/main/java/jerozgen/languagereload/mixin/TranslatableTextContentMixin.java b/src/main/java/jerozgen/languagereload/mixin/TranslatableTextContentMixin.java index acc1e70..2e7559d 100644 --- a/src/main/java/jerozgen/languagereload/mixin/TranslatableTextContentMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/TranslatableTextContentMixin.java @@ -14,6 +14,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -25,9 +26,9 @@ @Mixin(TranslatableTextContent.class) abstract class TranslatableTextContentMixin implements TextContent { - private @Nullable String previousTargetLanguage; - private final Map> separateTranslationsCache = Maps.newHashMap(); - private @Nullable List savedTranslations; + @Unique private @Nullable String previousTargetLanguage; + @Unique private final Map> separateTranslationsCache = Maps.newHashMap(); + @Unique private @Nullable List savedTranslations; @Shadow @Final private String key; @Shadow private @Nullable Language languageCache; @@ -39,7 +40,7 @@ void onUpdateTranslations(CallbackInfo ci) { if (!Config.getInstance().multilingualItemSearch) return; if (!(languageCache instanceof TranslationStorage)) return; - var targetLanguage = ((ITranslationStorage) languageCache).getTargetLanguage(); + var targetLanguage = ((ITranslationStorage) languageCache).languagereload_getTargetLanguage(); if (Objects.equals(previousTargetLanguage, targetLanguage)) return; if (targetLanguage == null) { diff --git a/src/main/java/jerozgen/languagereload/mixin/TranslationStorageMixin.java b/src/main/java/jerozgen/languagereload/mixin/TranslationStorageMixin.java index c19b6bc..ac93750 100644 --- a/src/main/java/jerozgen/languagereload/mixin/TranslationStorageMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/TranslationStorageMixin.java @@ -9,6 +9,7 @@ import net.minecraft.util.Language; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; @@ -22,9 +23,9 @@ @Mixin(TranslationStorage.class) abstract class TranslationStorageMixin extends Language implements ITranslationStorage { - private @Nullable String targetLanguage; - private static Map> separateTranslationsOnLoad; - private Map> separateTranslations; + @Unique private @Nullable String targetLanguage; + @Unique private static Map> separateTranslationsOnLoad; + @Unique private Map> separateTranslations; @Inject(method = "", at = @At("RETURN")) void onConstructed(Map translations, boolean rightToLeft, CallbackInfo ci) { @@ -62,12 +63,12 @@ void onGet(String key, CallbackInfoReturnable cir) { } @Override - public @Nullable String getTargetLanguage() { + public @Nullable String languagereload_getTargetLanguage() { return targetLanguage; } @Override - public void setTargetLanguage(@Nullable String value) { + public void languagereload_setTargetLanguage(@Nullable String value) { targetLanguage = value; } }