From 10bcd408b1b6e030ba43b3664b1fec8d7c182c5e Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Tue, 24 Dec 2024 17:16:44 +0100 Subject: [PATCH] Add visuals fabric mod, add loading cycle entrypoint for addons --- api-legacy/build.gradle | 2 + .../fixes/data/ItemRegistryDiff.java | 44 ++++++++++++ api/build.gradle | 1 + .../viafabricplus/api/ViaFabricPlusBase.java | 3 +- .../ViaFabricPlusLoadEntrypoint.java | 36 ++++++++++ .../api/events/LoadingCycleCallback.java | 5 -- .../viafabricplus/screen/VFPScreen.java | 4 +- build.gradle | 2 +- settings.gradle | 2 +- .../viafabricplus/ViaFabricPlusImpl.java | 11 ++- .../viaversion/viafabricplus/base/Events.java | 2 +- .../features/FeaturesLoading.java | 11 --- .../injection/mixin/base/MixinMain.java | 4 -- ...ltiplayerServerListWidget_ServerEntry.java | 61 ++++++++++++++++ .../MixinBookEditScreen.java | 2 +- .../MixinClientPlayerInteractionManager.java | 8 --- .../MixinClientPlayNetworkHandler.java | 6 -- .../MixinAbstractSignEditScreen.java | 2 +- .../MixinItemPacketRewriter1_14.java | 2 +- .../minecraft/entity/MixinLivingEntity.java | 28 -------- .../minecraft/entity/MixinPlayerEntity.java | 12 ---- .../viafabricplus/save/SaveManager.java | 1 - .../viafabricplus/save/impl/SettingsSave.java | 4 ++ .../settings/SettingsManager.java | 3 +- .../resources/viafabricplus.accesswidener | 16 +---- src/main/resources/viafabricplus.mixins.json | 58 +++++---------- visuals/build.gradle | 30 ++++++++ visuals/gradle.properties | 1 + .../visuals/ViaFabricPlusVisuals.java | 58 +++++++++++++++ .../armor_hud/ArmorHudEmulation1_8.java | 11 ++- .../GridItemSelectionScreen.java | 10 +-- .../BuiltinEmptyGlyph1_12_2.java | 4 +- .../LanguageUtil.java | 2 +- .../RenderableGlyphDiff.java | 6 +- .../UnicodeFontFix1_12_2.java | 10 +-- .../v1_7_tab_list_style/LegacyTabList.java | 2 +- .../injection/access}/IPlayerListEntry.java | 2 +- .../injection/access}/IPlayerListHud.java | 2 +- .../MixinCreativeInventoryScreen.java | 6 +- .../MixinBipedEntityModel.java | 16 +---- ...ltiplayerServerListWidget_ServerEntry.java | 36 +++------- .../MixinDownloadingTerrainScreen.java | 4 +- .../MixinGameModeSelectionScreen.java | 12 ++-- ...ModeSelectionScreen_GameModeSelection.java | 10 +-- .../MixinFontStorage.java | 8 +-- .../MixinLanguageManager.java | 8 +-- .../hud_element_changes}/MixinChatHud.java | 4 +- .../hud_element_changes}/MixinChatScreen.java | 4 +- .../MixinClientPlayerInteractionManager.java | 41 +++++++++++ .../hud_element_changes/MixinInGameHud.java | 4 +- .../mixin}/instant_sneaking/MixinCamera.java | 4 +- .../mixin/oof_sound/MixinPlayerEntity.java | 48 +++++++++++++ .../MixinItemRenderer.java | 4 +- .../MixinBipedEntityModel.java | 43 +++++++++++ .../player_rotations/MixinLivingEntity.java | 68 ++++++++++++++++++ .../MixinCommandBlockScreen.java | 4 +- .../MixinGameMenuScreen.java | 24 +++---- .../MixinJigsawBlockScreen.java | 12 ++-- .../MixinScreen.java | 4 +- .../MixinStructureBlockScreen_1.java | 6 +- .../MixinClientPlayNetworkHandler.java | 41 +++++++++++ .../MixinHeldItemRenderer.java | 4 +- .../MixinClientPlayNetworkHandler.java | 6 +- .../MixinPlayerListEntry.java | 6 +- .../MixinPlayerListHud.java | 8 +-- .../MixinVillagerClothingFeatureRenderer.java | 4 +- .../visuals/settings}/VisualSettings.java | 2 +- .../assets/viafabricplus-visuals}/sounds.json | 0 .../sounds/oof_hurt.ogg | Bin visuals/src/main/resources/fabric.mod.json | 57 +++++++++++++++ .../viafabricplus-visuals.accesswidener | 16 +++++ .../viafabricplus-visuals.mixins.json | 41 +++++++++++ 72 files changed, 745 insertions(+), 278 deletions(-) create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java create mode 100644 api/src/main/java/com/viaversion/viafabricplus/api/entrypoint/ViaFabricPlusLoadEntrypoint.java rename {src => api/src}/main/java/com/viaversion/viafabricplus/screen/VFPScreen.java (98%) create mode 100644 src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinMultiplayerServerListWidget_ServerEntry.java rename src/main/java/com/viaversion/viafabricplus/injection/mixin/features/{ui => }/book_edit_page_limitations/MixinBookEditScreen.java (95%) rename src/main/java/com/viaversion/viafabricplus/injection/mixin/features/{ui => }/sign_editor_reach/MixinAbstractSignEditScreen.java (96%) rename src/main/java/com/viaversion/viafabricplus/injection/mixin/features/{ui => }/triple_chests/MixinItemPacketRewriter1_14.java (98%) create mode 100644 visuals/build.gradle create mode 100644 visuals/gradle.properties create mode 100644 visuals/src/main/java/com/viaversion/viafabricplus/visuals/ViaFabricPlusVisuals.java rename {src/main/java/com/viaversion/viafabricplus/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/features}/armor_hud/ArmorHudEmulation1_8.java (88%) rename {src/main/java/com/viaversion/viafabricplus/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/features}/classic_creative_menu/GridItemSelectionScreen.java (95%) rename {src/main/java/com/viaversion/viafabricplus => visuals/src/main/java/com/viaversion/viafabricplus/visuals}/features/filter_non_existing_characters/BuiltinEmptyGlyph1_12_2.java (92%) rename {src/main/java/com/viaversion/viafabricplus => visuals/src/main/java/com/viaversion/viafabricplus/visuals}/features/filter_non_existing_characters/LanguageUtil.java (94%) rename {src/main/java/com/viaversion/viafabricplus => visuals/src/main/java/com/viaversion/viafabricplus/visuals}/features/filter_non_existing_characters/RenderableGlyphDiff.java (99%) rename {src/main/java/com/viaversion/viafabricplus => visuals/src/main/java/com/viaversion/viafabricplus/visuals}/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java (87%) rename {src/main/java/com/viaversion/viafabricplus/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/features}/v1_7_tab_list_style/LegacyTabList.java (93%) rename {src/main/java/com/viaversion/viafabricplus/injection/access/v1_7_tab_list_style => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/access}/IPlayerListEntry.java (93%) rename {src/main/java/com/viaversion/viafabricplus/injection/access/v1_7_tab_list_style => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/access}/IPlayerListHud.java (93%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/classic_creative_menu/MixinCreativeInventoryScreen.java (86%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/classic_walking_animation}/MixinBipedEntityModel.java (81%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/disable_server_pinging/MixinMultiplayerServerListWidget_ServerEntry.java (76%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/downloading_terrain_transitions/MixinDownloadingTerrainScreen.java (92%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/filter_game_mode_selections/MixinGameModeSelectionScreen.java (83%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/filter_game_mode_selections/MixinGameModeSelectionScreen_GameModeSelection.java (85%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/filter_non_existing_characters/MixinFontStorage.java (92%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/filter_non_existing_characters/MixinLanguageManager.java (80%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/legacy_chat_signatures => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes}/MixinChatHud.java (91%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/legacy_chat_signatures => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes}/MixinChatScreen.java (91%) create mode 100644 visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinClientPlayerInteractionManager.java rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/hud_element_changes/MixinInGameHud.java (97%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/instant_sneaking/MixinCamera.java (92%) create mode 100644 visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/oof_sound/MixinPlayerEntity.java rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/missing_model => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/petrified_oak_slab_model}/MixinItemRenderer.java (93%) create mode 100644 visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/player_rotations/MixinBipedEntityModel.java create mode 100644 visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/player_rotations/MixinLivingEntity.java rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/remove_newer_screen_features/MixinCommandBlockScreen.java (93%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/remove_newer_screen_features/MixinGameMenuScreen.java (86%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/remove_newer_screen_features/MixinJigsawBlockScreen.java (87%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/remove_newer_screen_features/MixinScreen.java (94%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/remove_newer_screen_features/MixinStructureBlockScreen_1.java (88%) create mode 100644 visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/secure_chat_warning/MixinClientPlayNetworkHandler.java rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/v1_7_tilt => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_item_tilt}/MixinHeldItemRenderer.java (97%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/v1_7_tab_list_style/MixinClientPlayNetworkHandler.java (87%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/v1_7_tab_list_style/MixinPlayerListEntry.java (84%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin}/v1_7_tab_list_style/MixinPlayerListHud.java (92%) rename {src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity => visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/villager_profession}/MixinVillagerClothingFeatureRenderer.java (93%) rename {src/main/java/com/viaversion/viafabricplus/settings/impl => visuals/src/main/java/com/viaversion/viafabricplus/visuals/settings}/VisualSettings.java (99%) rename {src/main/resources/assets/viafabricplus => visuals/src/main/resources/assets/viafabricplus-visuals}/sounds.json (100%) rename {src/main/resources/assets/viafabricplus => visuals/src/main/resources/assets/viafabricplus-visuals}/sounds/oof_hurt.ogg (100%) create mode 100644 visuals/src/main/resources/fabric.mod.json create mode 100644 visuals/src/main/resources/viafabricplus-visuals.accesswidener create mode 100644 visuals/src/main/resources/viafabricplus-visuals.mixins.json diff --git a/api-legacy/build.gradle b/api-legacy/build.gradle index 7d81dd7c..bba74679 100644 --- a/api-legacy/build.gradle +++ b/api-legacy/build.gradle @@ -4,5 +4,7 @@ plugins { dependencies { compileOnly project(":viafabricplus-api") + + // They don't matter and are only used to compile against compileOnly "com.viaversion:viaversion-common:5.2.1-SNAPSHOT" } \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java new file mode 100644 index 00000000..2a7578fa --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java @@ -0,0 +1,44 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.fixes.data; + +import com.viaversion.viafabricplus.ViaFabricPlus; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import net.minecraft.item.Item; + +/** + * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. + */ +@Deprecated +public class ItemRegistryDiff { + + @Deprecated + public static boolean keepItem(final Item item) { + return ViaFabricPlus.getImpl().itemExistsInConnection(item); + } + + @Deprecated + public static boolean contains(final Item item, final ProtocolVersion version) { + return ViaFabricPlus.getImpl().itemExists(item, version); + } + +} diff --git a/api/build.gradle b/api/build.gradle index 2d54ab52..6d2e94a8 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -3,6 +3,7 @@ plugins { } dependencies { + // They don't matter and are only used to compile against compileOnly "com.viaversion:viaversion-common:5.2.1-SNAPSHOT" compileOnly ("net.raphimc:ViaLoader:3.0.4") { exclude group: "com.google.guava", module: "guava" diff --git a/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java b/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java index 9db44d4e..686b6c37 100644 --- a/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java @@ -139,7 +139,8 @@ public interface ViaFabricPlusBase { void registerOnChangeProtocolVersionCallback(final ChangeProtocolVersionCallback callback); /** - * Register a callback for the loading cycle which covers most of the loading process of the mod. + * Register a callback for the loading cycle which covers most of the loading process of the mod. Intended to be used + * inside {@link com.viaversion.viafabricplus.api.entrypoint.ViaFabricPlusLoadEntrypoint} implementations. * * @param callback the callback */ diff --git a/api/src/main/java/com/viaversion/viafabricplus/api/entrypoint/ViaFabricPlusLoadEntrypoint.java b/api/src/main/java/com/viaversion/viafabricplus/api/entrypoint/ViaFabricPlusLoadEntrypoint.java new file mode 100644 index 00000000..7aaa45e0 --- /dev/null +++ b/api/src/main/java/com/viaversion/viafabricplus/api/entrypoint/ViaFabricPlusLoadEntrypoint.java @@ -0,0 +1,36 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.viaversion.viafabricplus.api.entrypoint; + +import com.viaversion.viafabricplus.api.ViaFabricPlusBase; + +/** + * Entrypoint called before the ViaFabricPlus loading cycle starts. To be used by addons to register their own callbacks. + *

+ * See {@link com.viaversion.viafabricplus.api.events.LoadingCycleCallback} for more information. + */ +@FunctionalInterface +public interface ViaFabricPlusLoadEntrypoint { + + void onPlatformLoad(final ViaFabricPlusBase platform); + +} diff --git a/api/src/main/java/com/viaversion/viafabricplus/api/events/LoadingCycleCallback.java b/api/src/main/java/com/viaversion/viafabricplus/api/events/LoadingCycleCallback.java index 024abb5c..66435554 100644 --- a/api/src/main/java/com/viaversion/viafabricplus/api/events/LoadingCycleCallback.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/events/LoadingCycleCallback.java @@ -28,11 +28,6 @@ public interface LoadingCycleCallback { enum LoadingCycle { - /** - * Earliest stage before ViaFabricPlus loads anything. - */ - INITIAL_LOAD, - /** * Before the settings are loaded. */ diff --git a/src/main/java/com/viaversion/viafabricplus/screen/VFPScreen.java b/api/src/main/java/com/viaversion/viafabricplus/screen/VFPScreen.java similarity index 98% rename from src/main/java/com/viaversion/viafabricplus/screen/VFPScreen.java rename to api/src/main/java/com/viaversion/viafabricplus/screen/VFPScreen.java index dc6fb256..9207a3f9 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/VFPScreen.java +++ b/api/src/main/java/com/viaversion/viafabricplus/screen/VFPScreen.java @@ -21,7 +21,7 @@ package com.viaversion.viafabricplus.screen; -import com.viaversion.viafabricplus.ViaFabricPlusImpl; +import com.viaversion.viafabricplus.ViaFabricPlus; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ConfirmLinkScreen; @@ -233,7 +233,7 @@ public class VFPScreen extends Screen { * @param next The screen which should be opened after the error screen is closed */ public static void showErrorScreen(final Text title, final Throwable throwable, final Screen next) { - ViaFabricPlusImpl.INSTANCE.logger().error("Something went wrong!", throwable); + ViaFabricPlus.getImpl().logger().error("Something went wrong!", throwable); final MinecraftClient client = MinecraftClient.getInstance(); client.execute(() -> client.setScreen(new NoticeScreen(() -> client.setScreen(next), title, Text.translatable("base.viafabricplus.something_went_wrong").append("\n" + throwable.getMessage()), Text.translatable("base.viafabricplus.cancel"), false))); diff --git a/build.gradle b/build.gradle index ab1bd40c..015dc66f 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ dependencies { // Manually include to ignore dependencies include implementation(project(path: ":viafabricplus-api", configuration: "namedElements")) - include implementation(project(path: ":viafabricplus-visual-changes", configuration: "namedElements")) + include implementation(project(path: ":viafabricplus-visuals", configuration: "namedElements")) // Will be removed in future versions include implementation(project(":viafabricplus-api-legacy")) diff --git a/settings.gradle b/settings.gradle index 112f981b..bd24408d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,7 +15,7 @@ includeBuild("build-logic") setupViaSubproject("api") setupViaSubproject("api-legacy") setupViaSubproject("generator-tools") -setupViaSubproject("visual-changes") +setupViaSubproject("visuals") void setupViaSubproject(String name) { var pName = "viafabricplus-" + name diff --git a/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java b/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java index aa8b72c4..99684d3e 100644 --- a/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java +++ b/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java @@ -21,17 +21,19 @@ package com.viaversion.viafabricplus; +import com.viaversion.viafabricplus.api.entrypoint.ViaFabricPlusLoadEntrypoint; import com.viaversion.viafabricplus.api.events.ChangeProtocolVersionCallback; -import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.api.ViaFabricPlusBase; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.api.settings.SettingGroup; +import com.viaversion.viafabricplus.base.Events; +import com.viaversion.viafabricplus.base.overriding_jars.ClassLoaderPriorityUtil; import com.viaversion.viafabricplus.features.item.filter_creative_tabs.ItemRegistryDiff; import com.viaversion.viafabricplus.features.item.negative_items.NegativeItemUtil; import com.viaversion.viafabricplus.injection.access.base.IClientConnection; import com.viaversion.viafabricplus.injection.access.base.IServerInfo; import com.viaversion.viafabricplus.protocoltranslator.translator.ItemTranslator; import com.viaversion.viafabricplus.util.ChatUtil; -import com.viaversion.viafabricplus.base.Events; import com.viaversion.viafabricplus.base.sync_tasks.SyncTasks; import com.viaversion.viafabricplus.save.SaveManager; import com.viaversion.viafabricplus.screen.impl.ProtocolSelectionScreen; @@ -102,6 +104,9 @@ public final class ViaFabricPlusImpl implements ViaFabricPlusBase { public void init() { ViaFabricPlus.init(this); + FabricLoader.getInstance().getEntrypointContainers("viafabricplus", ViaFabricPlusLoadEntrypoint.class).forEach(container -> { + container.getEntrypoint().onPlatformLoad(this); + }); // Create the directory if it doesn't exist if (!Files.exists(path)) { @@ -133,6 +138,7 @@ public final class ViaFabricPlusImpl implements ViaFabricPlusBase { loadingFuture.join(); SaveManager.INSTANCE.postInit(); }); + Events.LOADING_CYCLE.invoker().onLoadCycle(LoadingCycleCallback.LoadingCycle.FINAL_LOAD); } // -------------------------------------------------------------------------------------------- @@ -262,4 +268,5 @@ public final class ViaFabricPlusImpl implements ViaFabricPlusBase { public int getStackCount(ItemStack stack) { return NegativeItemUtil.getCount(stack); } + } diff --git a/src/main/java/com/viaversion/viafabricplus/base/Events.java b/src/main/java/com/viaversion/viafabricplus/base/Events.java index 490db21b..c54588f3 100644 --- a/src/main/java/com/viaversion/viafabricplus/base/Events.java +++ b/src/main/java/com/viaversion/viafabricplus/base/Events.java @@ -40,4 +40,4 @@ public final class Events { } }); -} +} \ No newline at end of file diff --git a/src/main/java/com/viaversion/viafabricplus/features/FeaturesLoading.java b/src/main/java/com/viaversion/viafabricplus/features/FeaturesLoading.java index 7a57009c..1444fc05 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/FeaturesLoading.java +++ b/src/main/java/com/viaversion/viafabricplus/features/FeaturesLoading.java @@ -23,22 +23,17 @@ package com.viaversion.viafabricplus.features; import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.base.Events; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; import com.viaversion.viafabricplus.features.block.CollisionShapes; import com.viaversion.viafabricplus.features.cpe_extensions.CPEAdditions; import com.viaversion.viafabricplus.features.footstep_particle.FootStepParticle1_12_2; import com.viaversion.viafabricplus.features.networking.resource_pack_header.ResourcePackHeaderDiff; import com.viaversion.viafabricplus.features.recipe_emulation.Recipes1_11_2; -import com.viaversion.viafabricplus.features.filter_non_existing_characters.UnicodeFontFix1_12_2; -import com.viaversion.viafabricplus.features.ui.armor_hud.ArmorHudEmulation1_8; -import com.viaversion.viafabricplus.features.ui.classic_creative_menu.GridItemSelectionScreen; import com.viaversion.viafabricplus.features.entity.EntityDimensionDiff; import com.viaversion.viafabricplus.features.entity.enchantment_attributes.EnchantmentAttributesEmulation1_20_6; import com.viaversion.viafabricplus.base.sync_tasks.DataCustomPayload; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.minecraft.client.MinecraftClient; import net.raphimc.viaaprilfools.api.AprilFoolsProtocolVersion; -import net.raphimc.vialegacy.api.LegacyProtocolVersion; public final class FeaturesLoading { @@ -46,24 +41,18 @@ public final class FeaturesLoading { ResourcePackHeaderDiff.init(); CPEAdditions.init(); DataCustomPayload.init(); - UnicodeFontFix1_12_2.init(); FootStepParticle1_12_2.init(); Events.LOADING_CYCLE.register(cycle -> { if (cycle == LoadingCycleCallback.LoadingCycle.POST_GAME_LOAD) { EntityDimensionDiff.init(); EnchantmentAttributesEmulation1_20_6.init(); - ArmorHudEmulation1_8.init(); } }); Events.CHANGE_PROTOCOL_VERSION.register((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> { - VisualSettings.INSTANCE.filterNonExistingGlyphs.onValueChanged(); CollisionShapes.reloadBlockShapes(); - if (newVersion.olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) { - GridItemSelectionScreen.INSTANCE.itemGrid = null; - } if (newVersion.olderThanOrEqualTo(ProtocolVersion.v1_11_1)) { Recipes1_11_2.reset(); } diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/MixinMain.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/MixinMain.java index 3ac369cf..2fb838d9 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/MixinMain.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/MixinMain.java @@ -22,8 +22,6 @@ package com.viaversion.viafabricplus.injection.mixin.base; import com.viaversion.viafabricplus.ViaFabricPlusImpl; -import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; -import com.viaversion.viafabricplus.base.Events; import net.minecraft.client.main.Main; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -35,9 +33,7 @@ public abstract class MixinMain { @Inject(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Util;startTimerHack()V")) private static void bootstrap(CallbackInfo ci) { - Events.LOADING_CYCLE.invoker().onLoadCycle(LoadingCycleCallback.LoadingCycle.INITIAL_LOAD); ViaFabricPlusImpl.INSTANCE.init(); - Events.LOADING_CYCLE.invoker().onLoadCycle(LoadingCycleCallback.LoadingCycle.FINAL_LOAD); } } diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinMultiplayerServerListWidget_ServerEntry.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinMultiplayerServerListWidget_ServerEntry.java new file mode 100644 index 00000000..5766c903 --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinMultiplayerServerListWidget_ServerEntry.java @@ -0,0 +1,61 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.viaversion.viafabricplus.injection.mixin.base.ui; + +import com.google.common.collect.Lists; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.viaversion.viafabricplus.injection.access.base.IServerInfo; +import com.viaversion.viafabricplus.settings.impl.GeneralSettings; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; +import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget; +import net.minecraft.client.network.ServerInfo; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.ArrayList; +import java.util.List; + +@Mixin(MultiplayerServerListWidget.ServerEntry.class) +public abstract class MixinMultiplayerServerListWidget_ServerEntry { + + @Shadow @Final private ServerInfo server; + + @WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Lnet/minecraft/text/Text;)V")) + private void drawTranslatingState(MultiplayerScreen instance, Text text, Operation original) { + final List tooltips = new ArrayList<>(); + tooltips.add(text); + if (GeneralSettings.INSTANCE.showAdvertisedServerVersion.getValue()) { + final ProtocolVersion version = ((IServerInfo) server).viaFabricPlus$translatingVersion(); + if (version != null) { + tooltips.add(Text.translatable("base.viafabricplus.via_translates_to", version.getName() + " (" + version.getOriginalVersion() + ")")); + tooltips.add(Text.translatable("base.viafabricplus.server_version", server.version.getString() + " (" + server.protocolVersion + ")")); + } + } + instance.setTooltip(Lists.transform(tooltips, Text::asOrderedText)); + } + +} \ No newline at end of file diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/book_edit_page_limitations/MixinBookEditScreen.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/book_edit_page_limitations/MixinBookEditScreen.java similarity index 95% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/book_edit_page_limitations/MixinBookEditScreen.java rename to src/main/java/com/viaversion/viafabricplus/injection/mixin/features/book_edit_page_limitations/MixinBookEditScreen.java index 5dbb2b47..24f1b0bc 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/book_edit_page_limitations/MixinBookEditScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/book_edit_page_limitations/MixinBookEditScreen.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.book_edit_page_limitations; +package com.viaversion.viafabricplus.injection.mixin.features.book_edit_page_limitations; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/interaction/MixinClientPlayerInteractionManager.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/interaction/MixinClientPlayerInteractionManager.java index c27d79c9..0de3dd21 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/interaction/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/interaction/MixinClientPlayerInteractionManager.java @@ -36,7 +36,6 @@ import com.viaversion.viafabricplus.injection.access.IScreenHandler; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; import com.viaversion.viafabricplus.protocoltranslator.impl.provider.viaversion.ViaFabricPlusHandItemProvider; import com.viaversion.viafabricplus.protocoltranslator.translator.ItemTranslator; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.SnowBlock; @@ -326,13 +325,6 @@ public abstract class MixinClientPlayerInteractionManager implements IClientPlay } } - @Inject(method = "hasExperienceBar", at = @At("HEAD"), cancellable = true) - private void removeExperienceBar(CallbackInfoReturnable cir) { - if (VisualSettings.INSTANCE.hideModernHUDElements.isEnabled()) { - cir.setReturnValue(false); - } - } - @Unique private boolean viaFabricPlus$extinguishFire(BlockPos blockPos, final Direction direction) { blockPos = blockPos.offset(direction); diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/packet_handling_changes/MixinClientPlayNetworkHandler.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/packet_handling_changes/MixinClientPlayNetworkHandler.java index 4a78bf1f..92b3ca4f 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/packet_handling_changes/MixinClientPlayNetworkHandler.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/packet_handling_changes/MixinClientPlayNetworkHandler.java @@ -25,7 +25,6 @@ import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import com.llamalad7.mixinextras.sugar.Local; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.DownloadingTerrainScreen; @@ -214,11 +213,6 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH } } - @Redirect(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;isSecureChatEnforced()Z")) - private boolean removeSecureChatWarning(ClientPlayNetworkHandler instance) { - return isSecureChatEnforced() || VisualSettings.INSTANCE.disableSecureChatWarning.isEnabled(); - } - @SuppressWarnings({"InvalidInjectorMethodSignature"}) @ModifyConstant(method = "onEntityPassengersSet", constant = @Constant(classValue = AbstractBoatEntity.class)) private Class dontChangeYawWhenMountingBoats(Object entity, Class boatClass) { diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/sign_editor_reach/MixinAbstractSignEditScreen.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/sign_editor_reach/MixinAbstractSignEditScreen.java similarity index 96% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/sign_editor_reach/MixinAbstractSignEditScreen.java rename to src/main/java/com/viaversion/viafabricplus/injection/mixin/features/sign_editor_reach/MixinAbstractSignEditScreen.java index f85dc11e..3130f76d 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/sign_editor_reach/MixinAbstractSignEditScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/sign_editor_reach/MixinAbstractSignEditScreen.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.sign_editor_reach; +package com.viaversion.viafabricplus.injection.mixin.features.sign_editor_reach; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/triple_chests/MixinItemPacketRewriter1_14.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/triple_chests/MixinItemPacketRewriter1_14.java similarity index 98% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/triple_chests/MixinItemPacketRewriter1_14.java rename to src/main/java/com/viaversion/viafabricplus/injection/mixin/features/triple_chests/MixinItemPacketRewriter1_14.java index 73a902e0..587528b5 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/triple_chests/MixinItemPacketRewriter1_14.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/triple_chests/MixinItemPacketRewriter1_14.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.triple_chests; +package com.viaversion.viafabricplus.injection.mixin.features.triple_chests; import com.llamalad7.mixinextras.sugar.Local; import com.viaversion.viafabricplus.base.sync_tasks.SyncTasks; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinLivingEntity.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinLivingEntity.java index 1a34e306..59c50f5c 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinLivingEntity.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinLivingEntity.java @@ -25,8 +25,6 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viafabricplus.features.entity.riding_offsets.EntityRidingOffsetsPre1_20_2; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.settings.impl.DebugSettings; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; import net.minecraft.block.BlockState; import net.minecraft.block.TrapdoorBlock; import net.minecraft.entity.*; @@ -73,9 +71,6 @@ public abstract class MixinLivingEntity extends Entity { @Shadow public abstract boolean hasStatusEffect(RegistryEntry effect); - @Shadow - public float bodyYaw; - public MixinLivingEntity(EntityType type, World world) { super(type, world); } @@ -98,20 +93,6 @@ public abstract class MixinLivingEntity extends Entity { } } - @Redirect(method = "turnHead", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(F)F")) - private float changeBodyRotationInterpolation(float g) { - if (VisualSettings.INSTANCE.changeBodyRotationInterpolation.isEnabled()) { - g = MathHelper.clamp(g, -75.0F, 75.0F); - this.bodyYaw = this.getYaw() - g; - if (Math.abs(g) > 50.0F) { - this.bodyYaw += g * 0.2F; - } - return Float.MIN_VALUE; // Causes the if to always fail - } else { - return Math.abs(g); - } - } - @Inject(method = "tickCramming", at = @At("HEAD"), cancellable = true) private void preventEntityPush(CallbackInfo ci) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { @@ -218,15 +199,6 @@ public abstract class MixinLivingEntity extends Entity { } } - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;abs(F)F")) - private float alwaysRotateWhenWalkingBackwards(float value) { - if (VisualSettings.INSTANCE.sidewaysBackwardsRunning.isEnabled()) { - return 0F; - } else { - return MathHelper.abs(value); - } - } - @Inject(method = "getPreferredEquipmentSlot", at = @At("HEAD"), cancellable = true) private void removeShieldSlotPreference(ItemStack stack, CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_9_3) && stack.isOf(Items.SHIELD)) { diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinPlayerEntity.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinPlayerEntity.java index 07a28f95..caa9946c 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinPlayerEntity.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinPlayerEntity.java @@ -26,11 +26,9 @@ import com.llamalad7.mixinextras.sugar.Local; import com.llamalad7.mixinextras.sugar.ref.LocalFloatRef; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; import net.minecraft.block.BlockState; import net.minecraft.entity.*; import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerAbilities; @@ -74,9 +72,6 @@ public abstract class MixinPlayerEntity extends LivingEntity { private static final EntityDimensions viaFabricPlus$sneaking_dimensions_v1_8 = EntityDimensions.changing(0.6F, 1.8F).withEyeHeight(1.54F). withAttachments(EntityAttachments.builder().add(EntityAttachmentType.VEHICLE, PlayerEntity.VEHICLE_ATTACHMENT_POS)); - @Unique - private static final SoundEvent viaFabricPlus$oof_hurt = SoundEvent.of(Identifier.of("viafabricplus", "oof.hurt")); - @Unique public boolean viaFabricPlus$isSprinting; @@ -237,11 +232,4 @@ public abstract class MixinPlayerEntity extends LivingEntity { } } - @Inject(method = "getHurtSound", at = @At("HEAD"), cancellable = true) - private void replaceSound(DamageSource source, CallbackInfoReturnable cir) { - if (VisualSettings.INSTANCE.replaceHurtSoundWithOOFSound.isEnabled()) { - cir.setReturnValue(viaFabricPlus$oof_hurt); - } - } - } diff --git a/src/main/java/com/viaversion/viafabricplus/save/SaveManager.java b/src/main/java/com/viaversion/viafabricplus/save/SaveManager.java index 2203d541..398c96b7 100644 --- a/src/main/java/com/viaversion/viafabricplus/save/SaveManager.java +++ b/src/main/java/com/viaversion/viafabricplus/save/SaveManager.java @@ -25,7 +25,6 @@ import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.base.Events; import com.viaversion.viafabricplus.save.impl.AccountsSave; import com.viaversion.viafabricplus.save.impl.SettingsSave; -import com.viaversion.viafabricplus.settings.SettingsManager; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/com/viaversion/viafabricplus/save/impl/SettingsSave.java b/src/main/java/com/viaversion/viafabricplus/save/impl/SettingsSave.java index 60938ed6..fec20c2e 100644 --- a/src/main/java/com/viaversion/viafabricplus/save/impl/SettingsSave.java +++ b/src/main/java/com/viaversion/viafabricplus/save/impl/SettingsSave.java @@ -60,6 +60,10 @@ public final class SettingsSave extends AbstractSave { final String translationKey = ChatUtil.uncoverTranslationKey(group.getName()); final JsonObject groupObject = object.getAsJsonObject(AbstractSetting.mapTranslationKey(translationKey)); + if (groupObject == null) { + continue; + } + for (AbstractSetting setting : group.getSettings()) { if (groupObject.has(setting.getTranslationKey())) { setting.read(groupObject); diff --git a/src/main/java/com/viaversion/viafabricplus/settings/SettingsManager.java b/src/main/java/com/viaversion/viafabricplus/settings/SettingsManager.java index 254b0cf9..037c0fbc 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/SettingsManager.java +++ b/src/main/java/com/viaversion/viafabricplus/settings/SettingsManager.java @@ -22,8 +22,8 @@ package com.viaversion.viafabricplus.settings; import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; -import com.viaversion.viafabricplus.base.Events; import com.viaversion.viafabricplus.api.settings.SettingGroup; +import com.viaversion.viafabricplus.base.Events; import com.viaversion.viafabricplus.settings.impl.*; import java.util.ArrayList; @@ -43,7 +43,6 @@ public final class SettingsManager { GeneralSettings.INSTANCE, BedrockSettings.INSTANCE, AuthenticationSettings.INSTANCE, - VisualSettings.INSTANCE, DebugSettings.INSTANCE ); diff --git a/src/main/resources/viafabricplus.accesswidener b/src/main/resources/viafabricplus.accesswidener index 14aca464..059ad4c9 100644 --- a/src/main/resources/viafabricplus.accesswidener +++ b/src/main/resources/viafabricplus.accesswidener @@ -1,36 +1,24 @@ accessWidener v1 named accessible field net/minecraft/network/ClientConnection channel Lio/netty/channel/Channel; -accessible field net/minecraft/client/MinecraftClient fontManager Lnet/minecraft/client/font/FontManager; accessible field net/minecraft/client/network/AllowedAddressResolver redirectResolver Lnet/minecraft/client/network/RedirectResolver; -accessible field net/minecraft/client/font/FontManager fontStorages Ljava/util/Map; accessible field net/minecraft/client/gui/screen/GameMenuScreen exitButton Lnet/minecraft/client/gui/widget/ButtonWidget; -accessible field net/minecraft/client/font/FontStorage$GlyphPair MISSING Lnet/minecraft/client/font/FontStorage$GlyphPair; accessible field net/minecraft/network/ClientConnection packetSizeLogger Lnet/minecraft/network/handler/PacketSizeLogger; accessible field net/minecraft/entity/boss/dragon/EnderDragonEntity body Lnet/minecraft/entity/boss/dragon/EnderDragonPart; accessible field net/minecraft/entity/passive/AbstractHorseEntity lastAngryAnimationProgress F -accessible field net/minecraft/client/font/FontStorage bakedGlyphCache Lnet/minecraft/client/font/GlyphContainer; accessible field net/minecraft/entity/vehicle/AbstractBoatEntity yawVelocity F -accessible field net/minecraft/client/font/FontStorage glyphCache Lnet/minecraft/client/font/GlyphContainer; accessible field net/minecraft/entity/EntityType dimensions Lnet/minecraft/entity/EntityDimensions; accessible field net/minecraft/block/AbstractBlock velocityMultiplier F -accessible field net/minecraft/client/gui/screen/world/WorldIcon UNKNOWN_SERVER_ID Lnet/minecraft/util/Identifier; -accessible field net/minecraft/client/gui/widget/TexturedButtonWidget textures Lnet/minecraft/client/gui/screen/ButtonTextures; accessible field net/minecraft/client/gui/screen/option/ControlsListWidget$KeyBindingEntry RESET_TEXT Lnet/minecraft/text/Text; -accessible field net/minecraft/client/gui/screen/multiplayer/SocialInteractionsScreen TITLE Lnet/minecraft/text/Text; -accessible field net/minecraft/client/resource/language/TranslationStorage translations Ljava/util/Map; accessible method net/minecraft/screen/GenericContainerScreenHandler (Lnet/minecraft/screen/ScreenHandlerType;ILnet/minecraft/entity/player/PlayerInventory;I)V -accessible method net/minecraft/client/font/FontStorage$GlyphPair (Lnet/minecraft/client/font/Glyph;Lnet/minecraft/client/font/Glyph;)V accessible method net/minecraft/entity/passive/CamelEntity getPassengerAttachmentY (ZFLnet/minecraft/entity/EntityDimensions;F)D accessible method net/minecraft/entity/vehicle/AbstractBoatEntity getMaxPassengers ()I accessible method net/minecraft/client/gui/screen/multiplayer/ConnectScreen setStatus (Lnet/minecraft/text/Text;)V accessible method net/minecraft/item/BlockItem getPlacementState (Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/block/BlockState; accessible method net/minecraft/block/AbstractBlock getPickStack (Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Z)Lnet/minecraft/item/ItemStack; -accessible class net/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection -accessible class net/minecraft/client/font/FontStorage$GlyphPair -accessible class net/minecraft/client/font/TextRenderer$Drawer - mutable field net/minecraft/entity/EntityType dimensions Lnet/minecraft/entity/EntityDimensions; mutable field net/minecraft/block/AbstractBlock velocityMultiplier F + +accessible class net/minecraft/client/font/TextRenderer$Drawer \ No newline at end of file diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index ff387415..fb9bd59a 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -31,6 +31,7 @@ "base.ui.MixinDirectConnectScreen", "base.ui.MixinDownloadingTerrainScreen", "base.ui.MixinMultiplayerScreen", + "base.ui.MixinMultiplayerServerListWidget_ServerEntry", "compat.classic4j.MixinCCAuthenticationResponse", "compat.classic4j.MixinTextFieldWidget", "compat.fabricapi.MixinClientRegistrySyncHandler", @@ -75,6 +76,7 @@ "features.block.interactions.MixinNoteBlock", "features.block.mining_calculations.MixinAbstractBlock", "features.block.mining_calculations.MixinAbstractBlock_AbstractBlockState", + "features.book_edit_page_limitations.MixinBookEditScreen", "features.classic_world_height.MixinBuiltChunk", "features.classic_world_height.MixinEntityPacketRewriter1_17", "features.classic_world_height.MixinWorldPacketRewriter1_16_2", @@ -84,6 +86,7 @@ "features.cpe_extensions.MixinProtocolc0_30cpeToc0_28_30", "features.cpe_extensions.MixinWeatherRendering", "features.entity.allow_duplicated_uuids.MixinEntityIndex", + "features.entity.enchantment_attributes.MixinLivingEntity", "features.entity.interactions.MixinAbstractClientPlayerEntity", "features.entity.interactions.MixinAbstractHorseEntity", "features.entity.interactions.MixinAnimalEntity", @@ -95,11 +98,14 @@ "features.entity.interactions.MixinCreeperEntity", "features.entity.interactions.MixinMobEntity", "features.entity.interactions.MixinMooshroomEntity", + "features.entity.interactions.MixinSquidEntity", + "features.entity.interactions.MixinWolfEntity", "features.entity.interactions.MixinZombieVillagerEntity", "features.entity.metadata_handling.MixinCommonBoss", "features.entity.metadata_handling.MixinEntityPacketRewriter1_15", "features.entity.metadata_handling.MixinEntityPacketRewriter1_9", "features.entity.metadata_handling.MixinEntityTracker1_9", + "features.entity.pose.MixinOtherClientPlayerEntity", "features.entity.riding_offsets.MixinCamelEntity", "features.entity.v1_8_boat.MixinAbstractBoatEntity", "features.entity.v1_8_boat.MixinEntityModels", @@ -107,20 +113,23 @@ "features.execute_inputs_sync.MixinKeyboard", "features.execute_inputs_sync.MixinMinecraftClient", "features.execute_inputs_sync.MixinMouse", - "features.filter_non_existing_characters.MixinFontStorage", - "features.filter_non_existing_characters.MixinLanguageManager", "features.footstep_particle.MixinMappingDataBase", "features.footstep_particle.MixinParticleIdMappings1_13", "features.footstep_particle.MixinParticleMappings", "features.footstep_particle.MixinRegistrySyncManager", - "features.instant_sneaking.MixinCamera", "features.interaction.MixinBlockItemPacketRewriter1_21_4", "features.interaction.MixinClientPlayerInteractionManager", "features.interaction.MixinEntityPacketRewriter1_20_5", "features.interaction.MixinItemPacketRewriter1_17", "features.interaction.MixinItemPlacementContext", "features.interaction.MixinMinecraftClient", + "features.interaction.MixinScreenHandler", "features.interaction.MixinWorldPacketRewriter1_19", + "features.interaction.inventory_clicking.MixinAbstractFurnaceScreenHandler", + "features.interaction.inventory_clicking.MixinBrewingStandScreenHandler_FuelSlot", + "features.interaction.inventory_clicking.MixinCraftingScreenHandler", + "features.interaction.inventory_clicking.MixinPlayerScreenHandler", + "features.interaction.merchant_emulation.MixinMerchantScreenHandler", "features.item.MixinItemEntity", "features.item.attributes.MixinItemPacketRewriter1_9", "features.item.cooldown.MixinItemCooldownManager", @@ -141,10 +150,8 @@ "features.item.interactions.MixinShovelItem", "features.item.interactions.MixinSwordItem", "features.item.mining_speeds.MixinBlockItemPacketRewriter1_20_5", - "features.item.missing_model.MixinItemRenderer", "features.item.negative_items.MixinDrawContext", "features.item.tooltip_changes.MixinItemStack", - "features.item.v1_7_tilt.MixinHeldItemRenderer", "features.legacy_skin_loading.MixinPlayerListEntry", "features.legacy_tab_completions.MixinAbstractCommandBlockScreen", "features.legacy_tab_completions.MixinChatInputSuggestor", @@ -160,6 +167,7 @@ "features.movement.block.MixinHoneyBlock", "features.movement.block.MixinSoulSandBlock", "features.movement.elytra.MixinFireworkRocketItem", + "features.movement.entity.MixinSkeletonHorseEntity", "features.movement.item.MixinEnderEyeItem", "features.movement.levitation_value.MixinStatusEffectInstance", "features.networking.config_state_fixes.MixinClientConfigurationNetworkHandler", @@ -169,8 +177,6 @@ "features.networking.config_state_fixes.MixinProtocol1_20To1_20_2", "features.networking.downloading_terrain_handling.MixinClientPlayNetworkHandler", "features.networking.downloading_terrain_handling.MixinDownloadingTerrainScreen", - "features.networking.legacy_chat_signatures.MixinChatHud", - "features.networking.legacy_chat_signatures.MixinChatScreen", "features.networking.legacy_chat_signatures.MixinConnectScreen_1", "features.networking.legacy_chat_signatures.MixinKeyPairResponse", "features.networking.legacy_chat_signatures.MixinPlayerPublicKey_PublicKeyData", @@ -199,26 +205,11 @@ "features.recipe_emulation.MixinEntityPacketRewriter1_12", "features.recipe_emulation.MixinPlayerScreenHandler", "features.run_command_action_handling.MixinScreen", + "features.sign_editor_reach.MixinAbstractSignEditScreen", "features.strike_through_offset.MixinTextRenderer_Drawer", "features.swinging.MixinInventoryTracker1_16", "features.swinging.MixinMinecraftClient", - "features.ui.book_edit_page_limitations.MixinBookEditScreen", - "features.ui.classic_creative_menu.MixinCreativeInventoryScreen", - "features.ui.disable_server_pinging.MixinMultiplayerServerListWidget_ServerEntry", - "features.ui.downloading_terrain_transitions.MixinDownloadingTerrainScreen", - "features.ui.filter_game_mode_selections.MixinGameModeSelectionScreen", - "features.ui.filter_game_mode_selections.MixinGameModeSelectionScreen_GameModeSelection", - "features.ui.hud_element_changes.MixinInGameHud", - "features.ui.remove_newer_screen_features.MixinCommandBlockScreen", - "features.ui.remove_newer_screen_features.MixinGameMenuScreen", - "features.ui.remove_newer_screen_features.MixinJigsawBlockScreen", - "features.ui.remove_newer_screen_features.MixinScreen", - "features.ui.remove_newer_screen_features.MixinStructureBlockScreen_1", - "features.ui.sign_editor_reach.MixinAbstractSignEditScreen", - "features.ui.triple_chests.MixinItemPacketRewriter1_14", - "features.ui.v1_7_tab_list_style.MixinClientPlayNetworkHandler", - "features.ui.v1_7_tab_list_style.MixinPlayerListEntry", - "features.ui.v1_7_tab_list_style.MixinPlayerListHud", + "features.triple_chests.MixinItemPacketRewriter1_14", "features.world.always_tick_entities.MixinClientWorld", "features.world.always_tick_entities.MixinEntity", "features.world.disable_sequencing.MixinClientWorld", @@ -228,31 +219,16 @@ "integration.viabedrock.MixinJoinPackets", "integration.vialegacy.MixinViaLegacyConfig", "old.minecraft.MixinMinecraftClient", - "old.minecraft.entity.MixinBipedEntityModel", "old.minecraft.entity.MixinClientPlayerEntity", "old.minecraft.entity.MixinEntity", "old.minecraft.entity.MixinLivingEntity", - "features.entity.pose.MixinOtherClientPlayerEntity", "old.minecraft.entity.MixinPlayerEntity", - "old.minecraft.entity.MixinPlayerEntityRenderer", - "features.movement.entity.MixinSkeletonHorseEntity", - "features.entity.interactions.MixinSquidEntity", - "old.minecraft.entity.MixinVillagerClothingFeatureRenderer", - "features.entity.interactions.MixinWolfEntity", - "features.interaction.inventory_clicking.MixinAbstractFurnaceScreenHandler", - "features.interaction.inventory_clicking.MixinBrewingStandScreenHandler_FuelSlot", - "features.interaction.inventory_clicking.MixinCraftingScreenHandler", - "features.interaction.merchant_emulation.MixinMerchantScreenHandler", - "features.interaction.inventory_clicking.MixinPlayerScreenHandler", - "features.interaction.MixinScreenHandler" + "old.minecraft.entity.MixinPlayerEntityRenderer" ], "injectors": { "defaultRequire": 1 }, "overwrites": { "requireAnnotations": true - }, - "mixins": [ - "features.entity.enchantment_attributes.MixinLivingEntity" - ] + } } diff --git a/visuals/build.gradle b/visuals/build.gradle new file mode 100644 index 00000000..09c482fa --- /dev/null +++ b/visuals/build.gradle @@ -0,0 +1,30 @@ +plugins { + id "vfp.base-conventions" +} + +loom { + accessWidenerPath = file("src/main/resources/viafabricplus-visuals.accesswidener") +} + +dependencies { + compileOnly project(":viafabricplus-api") + modCompileOnly fabricApi.module("fabric-api-base", project.fabric_api_version) + modCompileOnly fabricApi.module("fabric-lifecycle-events-v1", project.fabric_api_version) + + // They don't matter and are only used to compile against + compileOnly "com.viaversion:viaversion-common:5.2.1-SNAPSHOT" + compileOnly ("net.raphimc:ViaLoader:3.0.4") { + exclude group: "com.google.guava", module: "guava" + exclude group: "org.slf4j", module: "slf4j-api" + } + compileOnly "net.raphimc:ViaLegacy:3.0.7-SNAPSHOT" +} + +processResources { + filesMatching("fabric.mod.json") { + expand( + "version": project.version, + "description": project.description + ) + } +} \ No newline at end of file diff --git a/visuals/gradle.properties b/visuals/gradle.properties new file mode 100644 index 00000000..22803cfd --- /dev/null +++ b/visuals/gradle.properties @@ -0,0 +1 @@ +maven_description=Additional mod for ViaFabricPlus to add visual-only changes. \ No newline at end of file diff --git a/visuals/src/main/java/com/viaversion/viafabricplus/visuals/ViaFabricPlusVisuals.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/ViaFabricPlusVisuals.java new file mode 100644 index 00000000..4bf095a4 --- /dev/null +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/ViaFabricPlusVisuals.java @@ -0,0 +1,58 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.viaversion.viafabricplus.visuals; + +import com.viaversion.viafabricplus.api.ViaFabricPlusBase; +import com.viaversion.viafabricplus.api.entrypoint.ViaFabricPlusLoadEntrypoint; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; +import com.viaversion.viafabricplus.visuals.features.filter_non_existing_characters.UnicodeFontFix1_12_2; +import com.viaversion.viafabricplus.visuals.features.armor_hud.ArmorHudEmulation1_8; +import com.viaversion.viafabricplus.visuals.features.classic_creative_menu.GridItemSelectionScreen; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; +import net.minecraft.client.MinecraftClient; +import net.raphimc.vialegacy.api.LegacyProtocolVersion; + +public class ViaFabricPlusVisuals implements ViaFabricPlusLoadEntrypoint { + + @Override + public void onPlatformLoad(ViaFabricPlusBase platform) { + UnicodeFontFix1_12_2.init(); + + platform.registerLoadingCycleCallback(cycle -> { + if (cycle == LoadingCycleCallback.LoadingCycle.POST_SETTINGS_LOAD) { + platform.addSettingGroup(VisualSettings.INSTANCE); + } + if (cycle == LoadingCycleCallback.LoadingCycle.POST_GAME_LOAD) { + ArmorHudEmulation1_8.init(); + } + }); + + platform.registerOnChangeProtocolVersionCallback((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> { + VisualSettings.INSTANCE.filterNonExistingGlyphs.onValueChanged(); + + if (newVersion.olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) { + GridItemSelectionScreen.INSTANCE.itemGrid = null; + } + })); + } + +} diff --git a/src/main/java/com/viaversion/viafabricplus/features/ui/armor_hud/ArmorHudEmulation1_8.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/armor_hud/ArmorHudEmulation1_8.java similarity index 88% rename from src/main/java/com/viaversion/viafabricplus/features/ui/armor_hud/ArmorHudEmulation1_8.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/armor_hud/ArmorHudEmulation1_8.java index df182e0d..e0da6973 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/ui/armor_hud/ArmorHudEmulation1_8.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/armor_hud/ArmorHudEmulation1_8.java @@ -19,17 +19,16 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.features.ui.armor_hud; +package com.viaversion.viafabricplus.visuals.features.armor_hud; +import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.data.ArmorTypes1_8; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9; -import com.viaversion.viafabricplus.ViaFabricPlusImpl; -import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.item.ItemStack; @@ -50,12 +49,12 @@ public final class ArmorHudEmulation1_8 { } if (MinecraftClient.getInstance().player != null) { - final UserConnection userConnection = ProtocolTranslator.getPlayNetworkUserConnection(); + final UserConnection userConnection = ViaFabricPlus.getImpl().getPlayNetworkUserConnection(); if (userConnection != null) { try { sendArmorUpdate(userConnection); } catch (Throwable t) { - ViaFabricPlusImpl.INSTANCE.logger().error("Error sending armor update", t); + ViaFabricPlus.getImpl().logger().error("Error sending armor update", t); } } } else { diff --git a/src/main/java/com/viaversion/viafabricplus/features/ui/classic_creative_menu/GridItemSelectionScreen.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/classic_creative_menu/GridItemSelectionScreen.java similarity index 95% rename from src/main/java/com/viaversion/viafabricplus/features/ui/classic_creative_menu/GridItemSelectionScreen.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/classic_creative_menu/GridItemSelectionScreen.java index 90b9be93..45185207 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/ui/classic_creative_menu/GridItemSelectionScreen.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/classic_creative_menu/GridItemSelectionScreen.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.features.ui.classic_creative_menu; +package com.viaversion.viafabricplus.visuals.features.classic_creative_menu; -import com.viaversion.viafabricplus.features.item.filter_creative_tabs.ItemRegistryDiff; +import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viafabricplus.screen.VFPScreen; import net.minecraft.client.gui.DrawContext; import net.minecraft.item.Item; @@ -59,8 +59,10 @@ public final class GridItemSelectionScreen extends VFPScreen { final List allowedItems = new ArrayList<>(); // Calculate all visible items for (Item item : Registries.ITEM) { - if (item == Items.AIR || !item.getRequiredFeatures().contains(FeatureFlags.VANILLA)) continue; - if (ItemRegistryDiff.keepItem(item)) { + if (item == Items.AIR || !item.getRequiredFeatures().contains(FeatureFlags.VANILLA)) { + continue; + } + if (ViaFabricPlus.getImpl().itemExistsInConnection(item)) { allowedItems.add(item); } } diff --git a/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/BuiltinEmptyGlyph1_12_2.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/BuiltinEmptyGlyph1_12_2.java similarity index 92% rename from src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/BuiltinEmptyGlyph1_12_2.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/BuiltinEmptyGlyph1_12_2.java index ad9ff30c..fb7e580a 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/BuiltinEmptyGlyph1_12_2.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/BuiltinEmptyGlyph1_12_2.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.features.filter_non_existing_characters; +package com.viaversion.viafabricplus.visuals.features.filter_non_existing_characters; -import com.viaversion.viafabricplus.injection.mixin.features.filter_non_existing_characters.MixinFontStorage; +import com.viaversion.viafabricplus.visuals.injection.mixin.filter_non_existing_characters.MixinFontStorage; import net.minecraft.client.font.BakedGlyph; import net.minecraft.client.font.Glyph; import net.minecraft.client.font.RenderableGlyph; diff --git a/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/LanguageUtil.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/LanguageUtil.java similarity index 94% rename from src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/LanguageUtil.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/LanguageUtil.java index b61f1d8a..1c1fb18a 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/LanguageUtil.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/LanguageUtil.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.features.filter_non_existing_characters; +package com.viaversion.viafabricplus.visuals.features.filter_non_existing_characters; import java.util.Map; diff --git a/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/RenderableGlyphDiff.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/RenderableGlyphDiff.java similarity index 99% rename from src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/RenderableGlyphDiff.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/RenderableGlyphDiff.java index 8dbfe96e..4f4aa28c 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/RenderableGlyphDiff.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/RenderableGlyphDiff.java @@ -19,10 +19,10 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.features.filter_non_existing_characters; +package com.viaversion.viafabricplus.visuals.features.filter_non_existing_characters; +import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.IntConsumer; @@ -977,7 +977,7 @@ public final class RenderableGlyphDiff { * @return true if the given code point is renderable in the current version of the game */ public static boolean isGlyphRenderable(final int codePoint) { - final ProtocolVersion targetVersion = ProtocolTranslator.getTargetVersion(); + final ProtocolVersion targetVersion = ViaFabricPlus.getImpl().getTargetVersion(); if (targetVersion.newerThanOrEqualTo(v1_20)) { // 1.20 switched to using Unihex as a main font return !RENDERABLE_GLYPH_DIFF.containsKey(codePoint) || targetVersion.newerThanOrEqualTo(RENDERABLE_GLYPH_DIFF.get(codePoint)); diff --git a/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java similarity index 87% rename from src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java index e07bcc11..99f024b0 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java @@ -19,11 +19,11 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.features.filter_non_existing_characters; +package com.viaversion.viafabricplus.visuals.features.filter_non_existing_characters; -import com.viaversion.viafabricplus.base.Events; +import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.SimpleOption; @@ -40,7 +40,9 @@ public final class UnicodeFontFix1_12_2 { private static Runnable task = null; static { - Events.CHANGE_PROTOCOL_VERSION.register((oldVersion, newVersion) -> updateUnicodeFontOverride(newVersion)); + ViaFabricPlus.getImpl().registerOnChangeProtocolVersionCallback((oldVersion, newVersion) -> { + updateUnicodeFontOverride(newVersion); + }); ClientTickEvents.START_CLIENT_TICK.register(client -> { // Prevent usages of RenderSystem.recordRenderCall() diff --git a/src/main/java/com/viaversion/viafabricplus/features/ui/v1_7_tab_list_style/LegacyTabList.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/v1_7_tab_list_style/LegacyTabList.java similarity index 93% rename from src/main/java/com/viaversion/viafabricplus/features/ui/v1_7_tab_list_style/LegacyTabList.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/v1_7_tab_list_style/LegacyTabList.java index d75f99a8..b36607e7 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/ui/v1_7_tab_list_style/LegacyTabList.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/features/v1_7_tab_list_style/LegacyTabList.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.features.ui.v1_7_tab_list_style; +package com.viaversion.viafabricplus.visuals.features.v1_7_tab_list_style; public final class LegacyTabList { diff --git a/src/main/java/com/viaversion/viafabricplus/injection/access/v1_7_tab_list_style/IPlayerListEntry.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/access/IPlayerListEntry.java similarity index 93% rename from src/main/java/com/viaversion/viafabricplus/injection/access/v1_7_tab_list_style/IPlayerListEntry.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/access/IPlayerListEntry.java index 1e508f91..36e1f23c 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/access/v1_7_tab_list_style/IPlayerListEntry.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/access/IPlayerListEntry.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.access.v1_7_tab_list_style; +package com.viaversion.viafabricplus.visuals.injection.access; public interface IPlayerListEntry { diff --git a/src/main/java/com/viaversion/viafabricplus/injection/access/v1_7_tab_list_style/IPlayerListHud.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/access/IPlayerListHud.java similarity index 93% rename from src/main/java/com/viaversion/viafabricplus/injection/access/v1_7_tab_list_style/IPlayerListHud.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/access/IPlayerListHud.java index be7968ea..c1af7a9f 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/access/v1_7_tab_list_style/IPlayerListHud.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/access/IPlayerListHud.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.access.v1_7_tab_list_style; +package com.viaversion.viafabricplus.visuals.injection.access; public interface IPlayerListHud { diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/classic_creative_menu/MixinCreativeInventoryScreen.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/classic_creative_menu/MixinCreativeInventoryScreen.java similarity index 86% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/classic_creative_menu/MixinCreativeInventoryScreen.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/classic_creative_menu/MixinCreativeInventoryScreen.java index a7193562..ee360fc9 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/classic_creative_menu/MixinCreativeInventoryScreen.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/classic_creative_menu/MixinCreativeInventoryScreen.java @@ -19,10 +19,10 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.classic_creative_menu; +package com.viaversion.viafabricplus.visuals.injection.mixin.classic_creative_menu; -import com.viaversion.viafabricplus.features.ui.classic_creative_menu.GridItemSelectionScreen; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.features.classic_creative_menu.GridItemSelectionScreen; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinBipedEntityModel.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/classic_walking_animation/MixinBipedEntityModel.java similarity index 81% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinBipedEntityModel.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/classic_walking_animation/MixinBipedEntityModel.java index 7689682b..ee8417bc 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinBipedEntityModel.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/classic_walking_animation/MixinBipedEntityModel.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.old.minecraft.entity; +package com.viaversion.viafabricplus.visuals.injection.mixin.classic_walking_animation; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.entity.model.BipedEntityModel; import net.minecraft.client.render.entity.state.BipedEntityRenderState; @@ -31,7 +31,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(BipedEntityModel.class) @@ -45,15 +44,6 @@ public abstract class MixinBipedEntityModel { @Final public ModelPart leftArm; - @Redirect(method = "positionBlockingArm", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F")) - private float preventArmFollowingThirdPersonRotation(float value, float min, float max) { - if (VisualSettings.INSTANCE.lockBlockingArmRotation.isEnabled()) { - return 0.0F; - } else { - return MathHelper.clamp(value, min, max); - } - } - @Inject(method = "setAngles(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/model/ModelPart;roll:F", ordinal = 1, shift = At.Shift.AFTER)) private void addOldWalkAnimation(T bipedEntityRenderState, CallbackInfo ci) { if (VisualSettings.INSTANCE.oldWalkingAnimation.isEnabled()) { @@ -68,4 +58,4 @@ public abstract class MixinBipedEntityModel { } } -} +} \ No newline at end of file diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/disable_server_pinging/MixinMultiplayerServerListWidget_ServerEntry.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/disable_server_pinging/MixinMultiplayerServerListWidget_ServerEntry.java similarity index 76% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/disable_server_pinging/MixinMultiplayerServerListWidget_ServerEntry.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/disable_server_pinging/MixinMultiplayerServerListWidget_ServerEntry.java index 320db4af..0380a473 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/disable_server_pinging/MixinMultiplayerServerListWidget_ServerEntry.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/disable_server_pinging/MixinMultiplayerServerListWidget_ServerEntry.java @@ -19,15 +19,12 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.disable_server_pinging; +package com.viaversion.viafabricplus.visuals.injection.mixin.disable_server_pinging; -import com.google.common.collect.Lists; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.injection.access.base.IServerInfo; -import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.settings.impl.GeneralSettings; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; @@ -44,12 +41,11 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; -import java.util.ArrayList; import java.util.List; import java.util.concurrent.ThreadPoolExecutor; import java.util.function.Function; -@Mixin(MultiplayerServerListWidget.ServerEntry.class) +@Mixin(value = MultiplayerServerListWidget.ServerEntry.class, priority = 1001) // Apply after the mixin in the main project public abstract class MixinMultiplayerServerListWidget_ServerEntry { @Shadow @@ -66,8 +62,10 @@ public abstract class MixinMultiplayerServerListWidget_ServerEntry { @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/ThreadPoolExecutor;submit(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;")) private boolean disableServerPinging(ThreadPoolExecutor instance, Runnable runnable) { - ProtocolVersion version = ((IServerInfo) server).viaFabricPlus$forcedVersion(); - if (version == null) version = ProtocolTranslator.getTargetVersion(); + ProtocolVersion version = ViaFabricPlus.getImpl().getServerVersion(server); + if (version == null) { + version = ViaFabricPlus.getImpl().getTargetVersion(); + } viaFabricPlus$disableServerPinging = VisualSettings.INSTANCE.disableServerPinging.isEnabled(version); if (viaFabricPlus$disableServerPinging) { @@ -121,21 +119,9 @@ public abstract class MixinMultiplayerServerListWidget_ServerEntry { } } - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Lnet/minecraft/text/Text;)V")) - private void drawTranslatingState(MultiplayerScreen instance, Text text) { - if (viaFabricPlus$disableServerPinging) { // Remove ping bar tooltip - return; - } - final List tooltips = new ArrayList<>(); - tooltips.add(text); - if (GeneralSettings.INSTANCE.showAdvertisedServerVersion.getValue()) { - final ProtocolVersion version = ((IServerInfo) server).viaFabricPlus$translatingVersion(); - if (version != null) { - tooltips.add(Text.translatable("base.viafabricplus.via_translates_to", version.getName() + " (" + version.getOriginalVersion() + ")")); - tooltips.add(Text.translatable("base.viafabricplus.server_version", server.version.getString() + " (" + server.protocolVersion + ")")); - } - } - instance.setTooltip(Lists.transform(tooltips, Text::asOrderedText)); + @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Lnet/minecraft/text/Text;)V")) + private boolean disableServerPinging(MultiplayerScreen instance, Text text) { + return !viaFabricPlus$disableServerPinging; // Remove ping bar tooltip } } diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/downloading_terrain_transitions/MixinDownloadingTerrainScreen.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/downloading_terrain_transitions/MixinDownloadingTerrainScreen.java similarity index 92% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/downloading_terrain_transitions/MixinDownloadingTerrainScreen.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/downloading_terrain_transitions/MixinDownloadingTerrainScreen.java index 0d76a42c..02191583 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/downloading_terrain_transitions/MixinDownloadingTerrainScreen.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/downloading_terrain_transitions/MixinDownloadingTerrainScreen.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.downloading_terrain_transitions; +package com.viaversion.viafabricplus.visuals.injection.mixin.downloading_terrain_transitions; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.gui.screen.DownloadingTerrainScreen; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/filter_game_mode_selections/MixinGameModeSelectionScreen.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_game_mode_selections/MixinGameModeSelectionScreen.java similarity index 83% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/filter_game_mode_selections/MixinGameModeSelectionScreen.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_game_mode_selections/MixinGameModeSelectionScreen.java index 63adc0bd..1f5c72e5 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/filter_game_mode_selections/MixinGameModeSelectionScreen.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_game_mode_selections/MixinGameModeSelectionScreen.java @@ -19,10 +19,10 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.filter_game_mode_selections; +package com.viaversion.viafabricplus.visuals.injection.mixin.filter_game_mode_selections; +import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.client.gui.screen.GameModeSelectionScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; @@ -54,11 +54,11 @@ public abstract class MixinGameModeSelectionScreen extends Screen { @Inject(method = "", at = @At("RETURN")) private void fixUIWidth(CallbackInfo ci) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { final List selections = new ArrayList<>(Arrays.stream(GameModeSelectionScreen.GameModeSelection.values()).toList()); selections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR); - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { selections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE); } @@ -69,7 +69,7 @@ public abstract class MixinGameModeSelectionScreen extends Screen { @Redirect(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;VALUES:[Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;")) private GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { return viaFabricPlus$unwrappedGameModes; } else { return GameModeSelectionScreen.GameModeSelection.values(); @@ -78,7 +78,7 @@ public abstract class MixinGameModeSelectionScreen extends Screen { @Inject(method = "init", at = @At("HEAD")) private void disableInClassic(CallbackInfo ci) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) { // survival mode was added in a1.0.15 + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) { // survival mode was added in a1.0.15 this.close(); } } diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/filter_game_mode_selections/MixinGameModeSelectionScreen_GameModeSelection.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_game_mode_selections/MixinGameModeSelectionScreen_GameModeSelection.java similarity index 85% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/filter_game_mode_selections/MixinGameModeSelectionScreen_GameModeSelection.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_game_mode_selections/MixinGameModeSelectionScreen_GameModeSelection.java index 62626460..f1411db6 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/filter_game_mode_selections/MixinGameModeSelectionScreen_GameModeSelection.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_game_mode_selections/MixinGameModeSelectionScreen_GameModeSelection.java @@ -19,10 +19,10 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.filter_game_mode_selections; +package com.viaversion.viafabricplus.visuals.injection.mixin.filter_game_mode_selections; +import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.GameModeSelectionScreen; import net.raphimc.vialegacy.api.LegacyProtocolVersion; @@ -47,11 +47,11 @@ public abstract class MixinGameModeSelectionScreen_GameModeSelection { @Inject(method = "next", at = @At("HEAD"), cancellable = true) private void unwrapGameModes(CallbackInfoReturnable cir) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { switch ((GameModeSelectionScreen.GameModeSelection) (Object) this) { case CREATIVE -> cir.setReturnValue(SURVIVAL); case SURVIVAL -> { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { cir.setReturnValue(CREATIVE); } else { cir.setReturnValue(GameModeSelectionScreen.GameModeSelection.ADVENTURE); @@ -64,7 +64,7 @@ public abstract class MixinGameModeSelectionScreen_GameModeSelection { @Inject(method = "getCommand", at = @At("HEAD"), cancellable = true) private void oldCommand(CallbackInfoReturnable cir) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { cir.setReturnValue( "gamemode " + MinecraftClient.getInstance().getSession().getUsername() + ' ' + switch (((Enum) (Object) this).ordinal()) { case 0, 3 -> 1; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/filter_non_existing_characters/MixinFontStorage.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_non_existing_characters/MixinFontStorage.java similarity index 92% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/filter_non_existing_characters/MixinFontStorage.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_non_existing_characters/MixinFontStorage.java index e8bf832e..8ff2275a 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/filter_non_existing_characters/MixinFontStorage.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_non_existing_characters/MixinFontStorage.java @@ -19,11 +19,11 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.filter_non_existing_characters; +package com.viaversion.viafabricplus.visuals.injection.mixin.filter_non_existing_characters; -import com.viaversion.viafabricplus.features.filter_non_existing_characters.RenderableGlyphDiff; -import com.viaversion.viafabricplus.features.filter_non_existing_characters.BuiltinEmptyGlyph1_12_2; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.features.filter_non_existing_characters.RenderableGlyphDiff; +import com.viaversion.viafabricplus.visuals.features.filter_non_existing_characters.BuiltinEmptyGlyph1_12_2; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.*; import net.minecraft.util.Identifier; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/filter_non_existing_characters/MixinLanguageManager.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_non_existing_characters/MixinLanguageManager.java similarity index 80% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/filter_non_existing_characters/MixinLanguageManager.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_non_existing_characters/MixinLanguageManager.java index c07e84f4..3e19f1e4 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/filter_non_existing_characters/MixinLanguageManager.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/filter_non_existing_characters/MixinLanguageManager.java @@ -19,10 +19,10 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.filter_non_existing_characters; +package com.viaversion.viafabricplus.visuals.injection.mixin.filter_non_existing_characters; -import com.viaversion.viafabricplus.features.filter_non_existing_characters.UnicodeFontFix1_12_2; -import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import com.viaversion.viafabricplus.ViaFabricPlus; +import com.viaversion.viafabricplus.visuals.features.filter_non_existing_characters.UnicodeFontFix1_12_2; import net.minecraft.client.resource.language.LanguageManager; import net.minecraft.resource.ResourceManager; import org.spongepowered.asm.mixin.Mixin; @@ -35,7 +35,7 @@ public abstract class MixinLanguageManager { @Inject(method = "reload", at = @At("RETURN")) private void updateUnicodeFontOverride(ResourceManager manager, CallbackInfo ci) { - UnicodeFontFix1_12_2.updateUnicodeFontOverride(ProtocolTranslator.getTargetVersion()); + UnicodeFontFix1_12_2.updateUnicodeFontOverride(ViaFabricPlus.getImpl().getTargetVersion()); } } diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/legacy_chat_signatures/MixinChatHud.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinChatHud.java similarity index 91% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/legacy_chat_signatures/MixinChatHud.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinChatHud.java index 4c0a6aca..3a0b90b3 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/legacy_chat_signatures/MixinChatHud.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinChatHud.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.networking.legacy_chat_signatures; +package com.viaversion.viafabricplus.visuals.injection.mixin.hud_element_changes; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.MessageIndicator; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/legacy_chat_signatures/MixinChatScreen.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinChatScreen.java similarity index 91% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/legacy_chat_signatures/MixinChatScreen.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinChatScreen.java index 439974e2..a0912a6e 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/networking/legacy_chat_signatures/MixinChatScreen.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinChatScreen.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.networking.legacy_chat_signatures; +package com.viaversion.viafabricplus.visuals.injection.mixin.hud_element_changes; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.MessageIndicator; import net.minecraft.client.gui.screen.ChatScreen; diff --git a/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinClientPlayerInteractionManager.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinClientPlayerInteractionManager.java new file mode 100644 index 00000000..e3815e75 --- /dev/null +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinClientPlayerInteractionManager.java @@ -0,0 +1,41 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.viaversion.viafabricplus.visuals.injection.mixin.hud_element_changes; + +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; +import net.minecraft.client.network.ClientPlayerInteractionManager; +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; + +@Mixin(ClientPlayerInteractionManager.class) +public abstract class MixinClientPlayerInteractionManager { + + @Inject(method = "hasExperienceBar", at = @At("HEAD"), cancellable = true) + private void removeExperienceBar(CallbackInfoReturnable cir) { + if (VisualSettings.INSTANCE.hideModernHUDElements.isEnabled()) { + cir.setReturnValue(false); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/hud_element_changes/MixinInGameHud.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinInGameHud.java similarity index 97% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/hud_element_changes/MixinInGameHud.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinInGameHud.java index ff0ce131..38c229de 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/hud_element_changes/MixinInGameHud.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/hud_element_changes/MixinInGameHud.java @@ -19,14 +19,14 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.hud_element_changes; +package com.viaversion.viafabricplus.visuals.injection.mixin.hud_element_changes; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/instant_sneaking/MixinCamera.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/instant_sneaking/MixinCamera.java similarity index 92% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/instant_sneaking/MixinCamera.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/instant_sneaking/MixinCamera.java index 8a1612de..f4750c82 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/instant_sneaking/MixinCamera.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/instant_sneaking/MixinCamera.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.instant_sneaking; +package com.viaversion.viafabricplus.visuals.injection.mixin.instant_sneaking; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.render.Camera; import net.minecraft.entity.Entity; import org.spongepowered.asm.mixin.Mixin; diff --git a/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/oof_sound/MixinPlayerEntity.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/oof_sound/MixinPlayerEntity.java new file mode 100644 index 00000000..00bd928a --- /dev/null +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/oof_sound/MixinPlayerEntity.java @@ -0,0 +1,48 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.viaversion.viafabricplus.visuals.injection.mixin.oof_sound; + +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.sound.SoundEvent; +import net.minecraft.util.Identifier; +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.callback.CallbackInfoReturnable; + +@Mixin(PlayerEntity.class) +public abstract class MixinPlayerEntity { + + @Unique + private static final SoundEvent viaFabricPlus$oof_hurt = SoundEvent.of(Identifier.of("viafabricplus-visuals", "oof.hurt")); + + @Inject(method = "getHurtSound", at = @At("HEAD"), cancellable = true) + private void replaceSound(DamageSource source, CallbackInfoReturnable cir) { + if (VisualSettings.INSTANCE.replaceHurtSoundWithOOFSound.isEnabled()) { + cir.setReturnValue(viaFabricPlus$oof_hurt); + } + } + +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/missing_model/MixinItemRenderer.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/petrified_oak_slab_model/MixinItemRenderer.java similarity index 93% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/missing_model/MixinItemRenderer.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/petrified_oak_slab_model/MixinItemRenderer.java index 0b4f9ca8..9e263f26 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/missing_model/MixinItemRenderer.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/petrified_oak_slab_model/MixinItemRenderer.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.item.missing_model; +package com.viaversion.viafabricplus.visuals.injection.mixin.petrified_oak_slab_model; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.item.ItemModelManager; import net.minecraft.component.ComponentType; import net.minecraft.item.ItemStack; diff --git a/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/player_rotations/MixinBipedEntityModel.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/player_rotations/MixinBipedEntityModel.java new file mode 100644 index 00000000..c2de57ae --- /dev/null +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/player_rotations/MixinBipedEntityModel.java @@ -0,0 +1,43 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.viaversion.viafabricplus.visuals.injection.mixin.player_rotations; + +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; +import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.util.math.MathHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(BipedEntityModel.class) +public abstract class MixinBipedEntityModel { + + @Redirect(method = "positionBlockingArm", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F")) + private float preventArmFollowingThirdPersonRotation(float value, float min, float max) { + if (VisualSettings.INSTANCE.lockBlockingArmRotation.isEnabled()) { + return 0.0F; + } else { + return MathHelper.clamp(value, min, max); + } + } + +} diff --git a/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/player_rotations/MixinLivingEntity.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/player_rotations/MixinLivingEntity.java new file mode 100644 index 00000000..33fe0f71 --- /dev/null +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/player_rotations/MixinLivingEntity.java @@ -0,0 +1,68 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.viaversion.viafabricplus.visuals.injection.mixin.player_rotations; + +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(LivingEntity.class) +public abstract class MixinLivingEntity extends Entity { + + @Shadow + public float bodyYaw; + + public MixinLivingEntity(EntityType type, World world) { + super(type, world); + } + + @Redirect(method = "turnHead", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(F)F")) + private float changeBodyRotationInterpolation(float g) { + if (VisualSettings.INSTANCE.changeBodyRotationInterpolation.isEnabled()) { + g = MathHelper.clamp(g, -75.0F, 75.0F); + this.bodyYaw = this.getYaw() - g; + if (Math.abs(g) > 50.0F) { + this.bodyYaw += g * 0.2F; + } + return Float.MIN_VALUE; // Causes the if to always fail + } else { + return Math.abs(g); + } + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;abs(F)F")) + private float alwaysRotateWhenWalkingBackwards(float value) { + if (VisualSettings.INSTANCE.sidewaysBackwardsRunning.isEnabled()) { + return 0F; + } else { + return MathHelper.abs(value); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinCommandBlockScreen.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinCommandBlockScreen.java similarity index 93% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinCommandBlockScreen.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinCommandBlockScreen.java index 878a99e2..eb7be5a2 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinCommandBlockScreen.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinCommandBlockScreen.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.remove_newer_screen_features; +package com.viaversion.viafabricplus.visuals.injection.mixin.remove_newer_screen_features; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.block.entity.CommandBlockBlockEntity; import net.minecraft.client.gui.screen.ingame.CommandBlockScreen; import net.minecraft.client.gui.widget.CyclingButtonWidget; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinGameMenuScreen.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinGameMenuScreen.java similarity index 86% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinGameMenuScreen.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinGameMenuScreen.java index ff0b0a78..a900699f 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinGameMenuScreen.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinGameMenuScreen.java @@ -19,14 +19,14 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.remove_newer_screen_features; +package com.viaversion.viafabricplus.visuals.injection.mixin.remove_newer_screen_features; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.gui.Element; import net.minecraft.client.gui.screen.GameMenuScreen; import net.minecraft.client.gui.screen.OpenToLanScreen; @@ -97,18 +97,18 @@ public abstract class MixinGameMenuScreen extends Screen { private ButtonWidget replaceButtons(GameMenuScreen instance, Text text, Supplier screenSupplier, Operation original) { if (VisualSettings.INSTANCE.changeGameMenuScreenLayout.getIndex() == 0) { // Player reporting -> share to lan - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19) && text.equals(PLAYER_REPORTING_TEXT)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19) && text.equals(PLAYER_REPORTING_TEXT)) { final ButtonWidget button = ButtonWidget.builder(SHARE_TO_LAN_TEXT, buttonWidget -> new OpenToLanScreen(instance)).width(NORMAL_BUTTON_WIDTH).build(); button.active = false; return button; } // Advancements -> disconnect - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_4tob1_4_1) && text.equals(ADVANCEMENTS_TEXT)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_4tob1_4_1) && text.equals(ADVANCEMENTS_TEXT)) { return ButtonWidget.builder(ScreenTexts.DISCONNECT, viaFabricPlus$disconnectSupplier).width(viaFabricPlus$disconnectButtonWidth).build(); } } else if (VisualSettings.INSTANCE.changeGameMenuScreenLayout.getIndex() == 1) { // Player reporting -> Social interactions - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19) && text.equals(PLAYER_REPORTING_TEXT)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19) && text.equals(PLAYER_REPORTING_TEXT)) { return createButton(SocialInteractionsScreen.TITLE, () -> new SocialInteractionsScreen(instance)); } } @@ -117,7 +117,7 @@ public abstract class MixinGameMenuScreen extends Screen { @WrapWithCondition(method = "initWidgets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/GameMenuScreen;addFeedbackAndBugsButtons(Lnet/minecraft/client/gui/screen/Screen;Lnet/minecraft/client/gui/widget/GridWidget$Adder;)V"), require = 0) private boolean removeFeedbackAndBugsButtons(Screen parentScreen, GridWidget.Adder gridAdder) { - return VisualSettings.INSTANCE.changeGameMenuScreenLayout.getIndex() != 0 || ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_13_2); + return VisualSettings.INSTANCE.changeGameMenuScreenLayout.getIndex() != 0 || ViaFabricPlus.getImpl().getTargetVersion().newerThan(ProtocolVersion.v1_13_2); } @Inject(method = "initWidgets", at = @At("RETURN")) @@ -129,7 +129,7 @@ public abstract class MixinGameMenuScreen extends Screen { final Consumer moveDown = buttonWidget -> buttonWidget.setY(buttonWidget.getY() + ButtonWidget.DEFAULT_HEIGHT); // Move all buttons below feebdack/bug down since they are removed - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { viaFabricPlus$applyTo(OPTIONS_TEXT, moveDown); viaFabricPlus$applyTo(SHARE_TO_LAN_TEXT, moveDown); viaFabricPlus$applyTo(ScreenTexts.DISCONNECT, moveDown); @@ -142,7 +142,7 @@ public abstract class MixinGameMenuScreen extends Screen { } // Make options button wider since lan is removed - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { viaFabricPlus$applyTo(OPTIONS_TEXT, buttonWidget -> { buttonWidget.setX(returnToGame.getX()); buttonWidget.setWidth(returnToGame.getWidth()); @@ -150,7 +150,7 @@ public abstract class MixinGameMenuScreen extends Screen { } // Make space between return to game and options, put disconnect button below options - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_4tob1_4_1)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_4tob1_4_1)) { viaFabricPlus$applyTo(OPTIONS_TEXT, moveDown); viaFabricPlus$applyTo(ScreenTexts.DISCONNECT, buttonWidget -> { // Magical offset which would be calculated by the grid system, nothing we can do about it @@ -167,12 +167,12 @@ public abstract class MixinGameMenuScreen extends Screen { // Mods could add other widgets as well if (widget instanceof ButtonWidget button) { // Remove buttons and track their width/press action for later, mods might be injecting into them - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { if (button.getMessage().equals(SHARE_TO_LAN_TEXT)) { return false; } } - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_4tob1_4_1)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_4tob1_4_1)) { if (button.getMessage().equals(STATS_TEXT)) { return false; } else if (button.getMessage().equals(ScreenTexts.DISCONNECT)) { diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinJigsawBlockScreen.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinJigsawBlockScreen.java similarity index 87% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinJigsawBlockScreen.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinJigsawBlockScreen.java index 9f752fb4..ba956eda 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinJigsawBlockScreen.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinJigsawBlockScreen.java @@ -19,11 +19,11 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.remove_newer_screen_features; +package com.viaversion.viafabricplus.visuals.injection.mixin.remove_newer_screen_features; +import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.block.entity.JigsawBlockEntity; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; @@ -65,11 +65,11 @@ public abstract class MixinJigsawBlockScreen extends Screen { if (!VisualSettings.INSTANCE.hideModernJigsawScreenFeatures.getValue()) { return; } - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_2)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_2)) { selectionPriorityField.active = false; placementPriorityField.active = false; } - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) { nameField.active = false; jointRotationButton.active = false; int index = children().indexOf(jointRotationButton); @@ -81,7 +81,7 @@ public abstract class MixinJigsawBlockScreen extends Screen { @Inject(method = "render", at = @At("HEAD")) private void copyText(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { - if (VisualSettings.INSTANCE.hideModernJigsawScreenFeatures.getValue() && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) { + if (VisualSettings.INSTANCE.hideModernJigsawScreenFeatures.getValue() && ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) { nameField.setText(targetField.getText()); } } diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinScreen.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinScreen.java similarity index 94% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinScreen.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinScreen.java index 27af591e..35092fdf 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinScreen.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinScreen.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.remove_newer_screen_features; +package com.viaversion.viafabricplus.visuals.injection.mixin.remove_newer_screen_features; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.Drawable; import net.minecraft.client.gui.Element; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinStructureBlockScreen_1.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinStructureBlockScreen_1.java similarity index 88% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinStructureBlockScreen_1.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinStructureBlockScreen_1.java index f84612d6..86b1fc34 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/remove_newer_screen_features/MixinStructureBlockScreen_1.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/remove_newer_screen_features/MixinStructureBlockScreen_1.java @@ -19,10 +19,10 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.remove_newer_screen_features; +package com.viaversion.viafabricplus.visuals.injection.mixin.remove_newer_screen_features; +import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.text.Text; @@ -40,7 +40,7 @@ public abstract class MixinStructureBlockScreen_1 extends TextFieldWidget { @Inject(method = "charTyped(CI)Z", at = @At("HEAD"), cancellable = true) private void removeValidation(char chr, int keyCode, CallbackInfoReturnable ci) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { ci.setReturnValue(super.charTyped(chr, keyCode)); } } diff --git a/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/secure_chat_warning/MixinClientPlayNetworkHandler.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/secure_chat_warning/MixinClientPlayNetworkHandler.java new file mode 100644 index 00000000..a35c05bb --- /dev/null +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/secure_chat_warning/MixinClientPlayNetworkHandler.java @@ -0,0 +1,41 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.viaversion.viafabricplus.visuals.injection.mixin.secure_chat_warning; + +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(ClientPlayNetworkHandler.class) +public abstract class MixinClientPlayNetworkHandler { + + @Shadow protected abstract boolean isSecureChatEnforced(); + + @Redirect(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;isSecureChatEnforced()Z")) + private boolean removeSecureChatWarning(ClientPlayNetworkHandler instance) { + return isSecureChatEnforced() || VisualSettings.INSTANCE.disableSecureChatWarning.isEnabled(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/v1_7_tilt/MixinHeldItemRenderer.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_item_tilt/MixinHeldItemRenderer.java similarity index 97% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/v1_7_tilt/MixinHeldItemRenderer.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_item_tilt/MixinHeldItemRenderer.java index 7381e799..8161fe8c 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/v1_7_tilt/MixinHeldItemRenderer.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_item_tilt/MixinHeldItemRenderer.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.item.v1_7_tilt; +package com.viaversion.viafabricplus.visuals.injection.mixin.v1_7_item_tilt; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.HeldItemRenderer; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/v1_7_tab_list_style/MixinClientPlayNetworkHandler.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_tab_list_style/MixinClientPlayNetworkHandler.java similarity index 87% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/v1_7_tab_list_style/MixinClientPlayNetworkHandler.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_tab_list_style/MixinClientPlayNetworkHandler.java index 287f314b..4bcb1f76 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/v1_7_tab_list_style/MixinClientPlayNetworkHandler.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_tab_list_style/MixinClientPlayNetworkHandler.java @@ -19,10 +19,10 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.v1_7_tab_list_style; +package com.viaversion.viafabricplus.visuals.injection.mixin.v1_7_tab_list_style; -import com.viaversion.viafabricplus.features.ui.v1_7_tab_list_style.LegacyTabList; -import com.viaversion.viafabricplus.injection.access.v1_7_tab_list_style.IPlayerListHud; +import com.viaversion.viafabricplus.visuals.features.v1_7_tab_list_style.LegacyTabList; +import com.viaversion.viafabricplus.visuals.injection.access.IPlayerListHud; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/v1_7_tab_list_style/MixinPlayerListEntry.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_tab_list_style/MixinPlayerListEntry.java similarity index 84% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/v1_7_tab_list_style/MixinPlayerListEntry.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_tab_list_style/MixinPlayerListEntry.java index 7bae0e28..adf99efd 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/v1_7_tab_list_style/MixinPlayerListEntry.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_tab_list_style/MixinPlayerListEntry.java @@ -19,10 +19,10 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.v1_7_tab_list_style; +package com.viaversion.viafabricplus.visuals.injection.mixin.v1_7_tab_list_style; -import com.viaversion.viafabricplus.features.ui.v1_7_tab_list_style.LegacyTabList; -import com.viaversion.viafabricplus.injection.access.v1_7_tab_list_style.IPlayerListEntry; +import com.viaversion.viafabricplus.visuals.features.v1_7_tab_list_style.LegacyTabList; +import com.viaversion.viafabricplus.visuals.injection.access.IPlayerListEntry; import net.minecraft.client.network.PlayerListEntry; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/v1_7_tab_list_style/MixinPlayerListHud.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_tab_list_style/MixinPlayerListHud.java similarity index 92% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/v1_7_tab_list_style/MixinPlayerListHud.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_tab_list_style/MixinPlayerListHud.java index c9c47cbb..279e17d3 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/v1_7_tab_list_style/MixinPlayerListHud.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/v1_7_tab_list_style/MixinPlayerListHud.java @@ -19,12 +19,12 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.features.ui.v1_7_tab_list_style; +package com.viaversion.viafabricplus.visuals.injection.mixin.v1_7_tab_list_style; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.viaversion.viafabricplus.injection.access.v1_7_tab_list_style.IPlayerListEntry; -import com.viaversion.viafabricplus.injection.access.v1_7_tab_list_style.IPlayerListHud; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.injection.access.IPlayerListEntry; +import com.viaversion.viafabricplus.visuals.injection.access.IPlayerListHud; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.network.PlayerListEntry; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinVillagerClothingFeatureRenderer.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/villager_profession/MixinVillagerClothingFeatureRenderer.java similarity index 93% rename from src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinVillagerClothingFeatureRenderer.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/villager_profession/MixinVillagerClothingFeatureRenderer.java index 4845c184..919c341a 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/old/minecraft/entity/MixinVillagerClothingFeatureRenderer.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/injection/mixin/villager_profession/MixinVillagerClothingFeatureRenderer.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.injection.mixin.old.minecraft.entity; +package com.viaversion.viafabricplus.visuals.injection.mixin.villager_profession; -import com.viaversion.viafabricplus.settings.impl.VisualSettings; +import com.viaversion.viafabricplus.visuals.settings.VisualSettings; import net.minecraft.client.render.entity.feature.VillagerClothingFeatureRenderer; import net.minecraft.village.VillagerData; import net.minecraft.village.VillagerProfession; diff --git a/src/main/java/com/viaversion/viafabricplus/settings/impl/VisualSettings.java b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/settings/VisualSettings.java similarity index 99% rename from src/main/java/com/viaversion/viafabricplus/settings/impl/VisualSettings.java rename to visuals/src/main/java/com/viaversion/viafabricplus/visuals/settings/VisualSettings.java index fe03fb38..31ff0dc4 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/impl/VisualSettings.java +++ b/visuals/src/main/java/com/viaversion/viafabricplus/visuals/settings/VisualSettings.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.settings.impl; +package com.viaversion.viafabricplus.visuals.settings; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viafabricplus.api.settings.type.BooleanSetting; diff --git a/src/main/resources/assets/viafabricplus/sounds.json b/visuals/src/main/resources/assets/viafabricplus-visuals/sounds.json similarity index 100% rename from src/main/resources/assets/viafabricplus/sounds.json rename to visuals/src/main/resources/assets/viafabricplus-visuals/sounds.json diff --git a/src/main/resources/assets/viafabricplus/sounds/oof_hurt.ogg b/visuals/src/main/resources/assets/viafabricplus-visuals/sounds/oof_hurt.ogg similarity index 100% rename from src/main/resources/assets/viafabricplus/sounds/oof_hurt.ogg rename to visuals/src/main/resources/assets/viafabricplus-visuals/sounds/oof_hurt.ogg diff --git a/visuals/src/main/resources/fabric.mod.json b/visuals/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..84e48dcd --- /dev/null +++ b/visuals/src/main/resources/fabric.mod.json @@ -0,0 +1,57 @@ +{ + "schemaVersion": 1, + "id": "viafabricplus-visuals", + "version": "${version}", + "name": "ViaFabricPlus Visuals", + "description": "${description}", + "authors": [ + { + "name": "FlorianMichael/EnZaXD", + "contact": { + "email": "florian.michael07@gmail.com", + "homepage": "https://github.com/FlorianMichael" + } + }, + { + "name": "RK_01", + "contact": { + "homepage": "https://github.com/RaphiMC" + } + } + ], + "contributors": [ + "allinkdev", + "lowercasebtw", + { + "name": "GitHub contributors", + "contact": { + "homepage": "https://github.com/ViaVersion/ViaFabricPlus/graphs/contributors" + } + } + ], + "contact": { + "homepage": "https://florianmichael.de/", + "sources": "https://github.com/ViaVersion/ViaFabricPlus", + "issues": "https://github.com/ViaVersion/ViaFabricPlus/issues", + "email": "florian.michael07@gmail.com" + }, + "license": "GPL-v3", + "environment": "client", + "entrypoints": { + "viafabricplus": [ + "com.viaversion.viafabricplus.visuals.ViaFabricPlusVisuals" + ] + }, + "mixins": [ + "viafabricplus-visuals.mixins.json" + ], + "accessWidener": "viafabricplus-visuals.accesswidener", + "depends": { + "viafabricplus": ">=4.0.0" + }, + "custom": { + "modmenu": { + "parent": "viafabricplus" + } + } +} diff --git a/visuals/src/main/resources/viafabricplus-visuals.accesswidener b/visuals/src/main/resources/viafabricplus-visuals.accesswidener new file mode 100644 index 00000000..b5c43dce --- /dev/null +++ b/visuals/src/main/resources/viafabricplus-visuals.accesswidener @@ -0,0 +1,16 @@ +accessWidener v1 named + +accessible field net/minecraft/client/MinecraftClient fontManager Lnet/minecraft/client/font/FontManager; +accessible field net/minecraft/client/font/FontManager fontStorages Ljava/util/Map; +accessible field net/minecraft/client/font/FontStorage bakedGlyphCache Lnet/minecraft/client/font/GlyphContainer; +accessible field net/minecraft/client/font/FontStorage glyphCache Lnet/minecraft/client/font/GlyphContainer; +accessible field net/minecraft/client/resource/language/TranslationStorage translations Ljava/util/Map; +accessible field net/minecraft/client/gui/screen/multiplayer/SocialInteractionsScreen TITLE Lnet/minecraft/text/Text; +accessible field net/minecraft/client/gui/screen/world/WorldIcon UNKNOWN_SERVER_ID Lnet/minecraft/util/Identifier; +accessible field net/minecraft/client/font/FontStorage$GlyphPair MISSING Lnet/minecraft/client/font/FontStorage$GlyphPair; +accessible field net/minecraft/client/gui/widget/TexturedButtonWidget textures Lnet/minecraft/client/gui/screen/ButtonTextures; + +accessible method net/minecraft/client/font/FontStorage$GlyphPair (Lnet/minecraft/client/font/Glyph;Lnet/minecraft/client/font/Glyph;)V + +accessible class net/minecraft/client/font/FontStorage$GlyphPair +accessible class net/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection diff --git a/visuals/src/main/resources/viafabricplus-visuals.mixins.json b/visuals/src/main/resources/viafabricplus-visuals.mixins.json new file mode 100644 index 00000000..2ce7edb1 --- /dev/null +++ b/visuals/src/main/resources/viafabricplus-visuals.mixins.json @@ -0,0 +1,41 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.viaversion.viafabricplus.visuals.injection.mixin", + "compatibilityLevel": "JAVA_21", + "client": [ + "classic_creative_menu.MixinCreativeInventoryScreen", + "classic_walking_animation.MixinBipedEntityModel", + "disable_server_pinging.MixinMultiplayerServerListWidget_ServerEntry", + "downloading_terrain_transitions.MixinDownloadingTerrainScreen", + "filter_game_mode_selections.MixinGameModeSelectionScreen", + "filter_game_mode_selections.MixinGameModeSelectionScreen_GameModeSelection", + "filter_non_existing_characters.MixinFontStorage", + "filter_non_existing_characters.MixinLanguageManager", + "hud_element_changes.MixinChatHud", + "hud_element_changes.MixinChatScreen", + "hud_element_changes.MixinClientPlayerInteractionManager", + "hud_element_changes.MixinInGameHud", + "oof_sound.MixinPlayerEntity", + "petrified_oak_slab_model.MixinItemRenderer", + "player_rotations.MixinBipedEntityModel", + "player_rotations.MixinLivingEntity", + "remove_newer_screen_features.MixinCommandBlockScreen", + "remove_newer_screen_features.MixinGameMenuScreen", + "remove_newer_screen_features.MixinJigsawBlockScreen", + "remove_newer_screen_features.MixinScreen", + "remove_newer_screen_features.MixinStructureBlockScreen_1", + "secure_chat_warning.MixinClientPlayNetworkHandler", + "v1_7_item_tilt.MixinHeldItemRenderer", + "v1_7_tab_list_style.MixinClientPlayNetworkHandler", + "v1_7_tab_list_style.MixinPlayerListEntry", + "v1_7_tab_list_style.MixinPlayerListHud", + "villager_profession.MixinVillagerClothingFeatureRenderer" + ], + "injectors": { + "defaultRequire": 1 + }, + "overwrites": { + "requireAnnotations": true + } +}