From 613df3fcda29d1994dbaf0a4f3e0f81a8d497385 Mon Sep 17 00:00:00 2001 From: Josiah Glosson Date: Wed, 23 Oct 2024 02:51:50 -0500 Subject: [PATCH 1/6] Drop support for 1.18.2 --- build.gradle.kts | 4 -- settings.gradle.kts | 2 - .../gaming32/worldhost/WHPlayerSkin.java | 10 +--- .../github/gaming32/worldhost/WorldHost.java | 42 ++++++----------- .../worldhost/WorldHostComponents.java | 8 ++-- .../worldhost/config/option/EnumOption.java | 6 +-- .../worldhost/config/option/StringOption.java | 7 ++- .../worldhost/config/option/YesNoOption.java | 6 +-- .../worldhost/gui/screen/AddFriendScreen.java | 17 ++++--- .../worldhost/gui/screen/FriendsScreen.java | 13 +++--- .../gui/screen/JoiningWorldHostScreen.java | 3 +- .../gui/screen/OnlineFriendsScreen.java | 45 ++++++++---------- .../gui/screen/PlayerInfoScreen.java | 4 +- .../gui/screen/WorldHostConfigScreen.java | 5 +- .../gui/widget/CustomCycleButton.java | 4 +- .../worldhost/gui/widget/EnumButton.java | 3 +- .../worldhost/gui/widget/FriendsButton.java | 4 +- .../gui/widget/OnlineStatusButton.java | 11 ++--- .../worldhost/gui/widget/UserListWidget.java | 13 +++--- .../gui/widget/WHPlayerSkinWidget.java | 4 +- .../worldhost/mixin/MinecraftAccessor.java | 2 - .../worldhost/mixin/MixinConnectScreen_1.java | 2 +- .../mixin/MixinIntegratedServer.java | 42 +++-------------- .../worldhost/mixin/MixinPublishCommand.java | 19 ++------ .../mixin/MixinSelectWorldScreen.java | 7 +-- .../mixin/MixinShareToLanScreen.java | 14 +----- .../plugin/vanilla/WorldHostFriendAdder.java | 9 ++-- .../worldhost/protocol/ProtocolClient.java | 7 +-- .../protocol/WorldHostS2CMessage.java | 14 +++--- .../worldhost/testing/MinecraftApi.java | 11 +---- .../worldhost/toast/ToastInstance.java | 3 +- .../gaming32/worldhost/toast/WHToast.java | 3 +- .../worldhost/versions/Components.java | 46 +------------------ version.gradle.kts | 10 ---- 34 files changed, 117 insertions(+), 283 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a5610c60..a6400bab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,8 +20,6 @@ preprocess { val forge11904 = createNode("1.19.4-forge", 1_19_04, "srg") val fabric11902 = createNode("1.19.2-fabric", 1_19_02, "yarn") val forge11902 = createNode("1.19.2-forge", 1_19_02, "srg") - val fabric11802 = createNode("1.18.2-fabric", 1_18_02, "yarn") - val forge11802 = createNode("1.18.2-forge", 1_18_02, "srg") fabric12101.link(neoforge12101) neoforge12101.link(neoforge12006) @@ -34,6 +32,4 @@ preprocess { fabric11904.link(forge11904) forge11904.link(forge11902) forge11902.link(fabric11902) - fabric11902.link(fabric11802) - fabric11802.link(forge11802) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 5ba1d22c..53bfd0ef 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,8 +19,6 @@ rootProject.name = "world-host" rootProject.buildFileName = "build.gradle.kts" listOf( - "1.18.2-forge", - "1.18.2-fabric", "1.19.2-forge", "1.19.2-fabric", "1.19.4-forge", diff --git a/src/main/java/io/github/gaming32/worldhost/WHPlayerSkin.java b/src/main/java/io/github/gaming32/worldhost/WHPlayerSkin.java index 4e002f59..fe61603f 100644 --- a/src/main/java/io/github/gaming32/worldhost/WHPlayerSkin.java +++ b/src/main/java/io/github/gaming32/worldhost/WHPlayerSkin.java @@ -12,11 +12,7 @@ //$$ import java.util.UUID; //$$ import java.util.concurrent.CompletableFuture; //$$ import net.minecraft.client.resources.DefaultPlayerSkin; -//#if MC >= 1.19.2 //$$ import net.minecraft.core.UUIDUtil; -//#else -//$$ import net.minecraft.world.entity.player.Player; -//#endif //#endif // TODO: Remove in 1.20.2+ @@ -43,11 +39,7 @@ public static WHPlayerSkin fromSkinManager(SkinManager skinManager, GameProfile //$$ skinTexture = skinManager.registerTexture(skin, MinecraftProfileTexture.Type.SKIN); //$$ skinModel = skin.getMetadata("model"); //$$ } else { - //#if MC >= 1.19.2 - //$$ final UUID uuid = UUIDUtil.getOrCreatePlayerUUID(profile); - //#else - //$$ final UUID uuid = Player.createPlayerUUID(profile); - //#endif + //$$ final UUID uuid = UUIDUtil.getOrCreatePlayerUUID(profile); //$$ skinTexture = DefaultPlayerSkin.getDefaultSkin(uuid); //$$ skinModel = DefaultPlayerSkin.getSkinModelName(uuid); //$$ } diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index 7a00faff..ad319242 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -15,6 +15,7 @@ import io.github.gaming32.worldhost.gui.screen.FriendsScreen; import io.github.gaming32.worldhost.gui.screen.JoiningWorldHostScreen; import io.github.gaming32.worldhost.gui.screen.OnlineFriendsScreen; +import io.github.gaming32.worldhost.mixin.MinecraftAccessor; import io.github.gaming32.worldhost.origincheck.OriginCheckers; import io.github.gaming32.worldhost.plugin.FriendAdder; import io.github.gaming32.worldhost.plugin.InfoTextsCategory; @@ -47,6 +48,7 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.ComponentUtils; import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket; @@ -101,13 +103,6 @@ import static net.minecraft.commands.Commands.literal; -//#if MC >= 1.19.2 -import io.github.gaming32.worldhost.mixin.MinecraftAccessor; -//#else -//$$ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; -//$$ import net.minecraft.world.entity.player.Player; -//#endif - //#if FABRIC import dev.isxander.mainmenucredits.MainMenuCredits; import net.fabricmc.api.ClientModInitializer; @@ -138,10 +133,8 @@ //$$ import net.neoforged.neoforge.client.gui.IConfigScreenFactory; //#elseif NEOFORGE //$$ import net.neoforged.neoforge.client.ConfigScreenHandler; -//#elseif MC >= 1.19.2 -//$$ import net.minecraftforge.client.ConfigScreenHandler; //#else -//$$ import net.minecraftforge.client.ConfigGuiHandler; +//$$ import net.minecraftforge.client.ConfigScreenHandler; //#endif //#endif @@ -264,12 +257,9 @@ public void onInitializeClient() { //$$ container.registerExtensionPoint( //#if MC >= 1.20.5 //$$ IConfigScreenFactory.class, (ignored, screen) -> new WorldHostConfigScreen(screen) - //#elseif MC >= 1.19.2 + //#else //$$ ConfigScreenHandler.ConfigScreenFactory.class, //$$ () -> new ConfigScreenHandler.ConfigScreenFactory((ignored, screen) -> new WorldHostConfigScreen(screen)) - //#else - //$$ ConfigGuiHandler.ConfigGuiFactory.class, - //$$ () -> new ConfigGuiHandler.ConfigGuiFactory((ignored, screen) -> new WorldHostConfigScreen(screen)) //#endif //$$ ); //$$ } @@ -301,7 +291,7 @@ private static void init(IOFunction assetGetter, Path modPath) { if (!nonstandardOrigins.isEmpty()) { LOGGER.warn("Found nonstandard download origins: {}", nonstandardOrigins); WHToast.builder("world-host.nonstandard_origin") - .description(Components.translatable( + .description(Component.translatable( "world-host.nonstandard_origin.desc", nonstandardOrigins.stream() .map(URI::getHost) @@ -318,11 +308,7 @@ private static void init(IOFunction assetGetter, Path modPath) { LOGGER.error("Failed to create cache directory", e); } profileCache = new GameProfileCache( - //#if MC >= 1.19.2 ((MinecraftAccessor)Minecraft.getInstance()).getAuthenticationService().createProfileRepository(), - //#else - //$$ new YggdrasilAuthenticationService(Minecraft.getInstance().getProxy()).createProfileRepository(), - //#endif CACHE_DIR.resolve("usercache.json").toFile() ); profileCache.setExecutor(Minecraft.getInstance()); @@ -634,7 +620,7 @@ public static void commandRegistrationHandler(CommandDispatcher= 1.20.0 () -> //#endif - Components.translatable( + Component.translatable( "world-host.worldhost.tempip.success", Components.copyOnClickText(protoClient.getUserIp() + ':' + port) ), @@ -646,9 +632,9 @@ public static void commandRegistrationHandler(CommandDispatcher style + ComponentUtils.wrapInSquareBrackets(Component.literal("/worldhost ip")).withStyle(style -> style .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/worldhost ip")) ) @@ -789,8 +775,8 @@ public static void showFriendOrOnlineToast( @Nullable Runnable clickAction ) { profileFuture.thenAccept(profile -> - WHToast.builder(Components.translatable(title, profile.name())) - .description(Components.translatable(description)) + WHToast.builder(Component.translatable(title, profile.name())) + .description(Component.translatable(description)) .icon(profile.iconRenderer()) .clickAction(clickAction) .ticks(ticks) @@ -830,7 +816,7 @@ public static FriendlyByteBuf writeServerStatus(@Nullable ServerStatus metadata) public static ServerStatus createEmptyServerStatus() { //#if MC >= 1.19.4 return new ServerStatus( - Components.EMPTY, Optional.empty(), Optional.empty(), Optional.empty(), false + CommonComponents.EMPTY, Optional.empty(), Optional.empty(), Optional.empty(), false //#if FORGELIKE && MC < 1.20.4 //$$ , Optional.empty() //#elseif NEOFORGE @@ -974,19 +960,19 @@ public static void connect(Screen parentScreen, long cid, String host, int port) private static int ipCommand(CommandContext ctx) { if (protoClient == null) { - ctx.getSource().sendFailure(Components.translatable("world-host.worldhost.ip.not_connected")); + ctx.getSource().sendFailure(Component.translatable("world-host.worldhost.ip.not_connected")); return 0; } final String externalIp = getExternalIp(); if (externalIp == null) { - ctx.getSource().sendFailure(Components.translatable("world-host.worldhost.ip.no_server_support")); + ctx.getSource().sendFailure(Component.translatable("world-host.worldhost.ip.no_server_support")); return 0; } ctx.getSource().sendSuccess( //#if MC >= 1.20.0 () -> //#endif - Components.translatable( + Component.translatable( "world-host.worldhost.ip.success", Components.copyOnClickText(externalIp) ), diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHostComponents.java b/src/main/java/io/github/gaming32/worldhost/WorldHostComponents.java index b7af95f0..2185e871 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHostComponents.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHostComponents.java @@ -1,11 +1,9 @@ package io.github.gaming32.worldhost; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.network.chat.Component; public class WorldHostComponents { - public static final Component FRIENDS = Components.translatable("world-host.friends"); - public static final Component SERVERS = Components.translatable("world-host.servers"); - public static final Component PLAY_TEXT = Components.translatable("world-host.play_world"); - public static final Component ELLIPSIS = Components.literal("..."); // TODO: Remove in 1.19.2 + public static final Component FRIENDS = Component.translatable("world-host.friends"); + public static final Component SERVERS = Component.translatable("world-host.servers"); + public static final Component PLAY_TEXT = Component.translatable("world-host.play_world"); } diff --git a/src/main/java/io/github/gaming32/worldhost/config/option/EnumOption.java b/src/main/java/io/github/gaming32/worldhost/config/option/EnumOption.java index c7d0209a..33e97f3f 100644 --- a/src/main/java/io/github/gaming32/worldhost/config/option/EnumOption.java +++ b/src/main/java/io/github/gaming32/worldhost/config/option/EnumOption.java @@ -3,10 +3,10 @@ import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.config.ConfigProperty; import io.github.gaming32.worldhost.gui.widget.EnumButton; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.Component; import net.minecraft.util.StringRepresentable; import org.quiltmc.parsers.json.JsonReader; import org.quiltmc.parsers.json.JsonWriter; @@ -74,8 +74,8 @@ public Collection createWidgets(int x, int y, int widt final EnumButton button = new EnumButton<>( x, y, width, height, translationBase, - Components.translatable(translationBase), - I18n.exists(tooltipKey) ? Components.translatable(tooltipKey) : null, + Component.translatable(translationBase), + I18n.exists(tooltipKey) ? Component.translatable(tooltipKey) : null, enumType, b -> setValue(WorldHost.CONFIG, b.getValue()) ); diff --git a/src/main/java/io/github/gaming32/worldhost/config/option/StringOption.java b/src/main/java/io/github/gaming32/worldhost/config/option/StringOption.java index cf085fc0..b6ec8167 100644 --- a/src/main/java/io/github/gaming32/worldhost/config/option/StringOption.java +++ b/src/main/java/io/github/gaming32/worldhost/config/option/StringOption.java @@ -5,7 +5,6 @@ import io.github.gaming32.worldhost.gui.screen.WorldHostScreen; import io.github.gaming32.worldhost.gui.widget.SimpleStringWidget; import io.github.gaming32.worldhost.gui.widget.TooltipEditBox; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.resources.language.I18n; @@ -19,7 +18,7 @@ import java.util.List; public final class StringOption extends ConfigOption { - private static final Component RESET = Components.translatable("controls.reset"); + private static final Component RESET = Component.translatable("controls.reset"); private final String defaultValue; @@ -53,8 +52,8 @@ public Collection createWidgets(int x, int y, int widt final String translationBase = "world-host.config." + property.getName(); final String tooltipKey = translationBase + ".tooltip"; - final Component translation = Components.translatable(translationBase); - final Component tooltip = I18n.exists(tooltipKey) ? Components.translatable(tooltipKey) : null; + final Component translation = Component.translatable(translationBase); + final Component tooltip = I18n.exists(tooltipKey) ? Component.translatable(tooltipKey) : null; final var label = new SimpleStringWidget(x + 5, y + 10 - font.lineHeight / 2, translation, tooltip, font); diff --git a/src/main/java/io/github/gaming32/worldhost/config/option/YesNoOption.java b/src/main/java/io/github/gaming32/worldhost/config/option/YesNoOption.java index 7eda1655..9e6d52fc 100644 --- a/src/main/java/io/github/gaming32/worldhost/config/option/YesNoOption.java +++ b/src/main/java/io/github/gaming32/worldhost/config/option/YesNoOption.java @@ -2,10 +2,10 @@ import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.gui.widget.YesNoButton; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.Component; import org.quiltmc.parsers.json.JsonReader; import org.quiltmc.parsers.json.JsonWriter; @@ -38,8 +38,8 @@ public Collection createWidgets(int x, int y, int widt final String tooltipKey = translationBase + ".tooltip"; final YesNoButton button = new YesNoButton( x, y, width, height, - Components.translatable(translationBase), - I18n.exists(tooltipKey) ? Components.translatable(tooltipKey) : null, + Component.translatable(translationBase), + I18n.exists(tooltipKey) ? Component.translatable(tooltipKey) : null, b -> setValue(WorldHost.CONFIG, b.isToggled()) ); button.setToggled(getValue(WorldHost.CONFIG)); diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java index ba053acb..73dd7a83 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java @@ -4,7 +4,6 @@ import io.github.gaming32.worldhost.gui.widget.UserListWidget; import io.github.gaming32.worldhost.plugin.FriendAdder; import io.github.gaming32.worldhost.plugin.FriendListFriend; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.Util; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.screens.Screen; @@ -26,19 +25,19 @@ //#endif public class AddFriendScreen extends WorldHostScreen { - private static final Component FRIEND_USERNAME_TEXT = Components.translatable("world-host.add_friend.enter_username"); - private static final Component ADD_FRIEND_TEXT = Components.literal("+"); + private static final Component FRIEND_USERNAME_TEXT = Component.translatable("world-host.add_friend.enter_username"); + private static final Component ADD_FRIEND_TEXT = Component.literal("+"); //#if MC >= 1.20.0 @VisibleForTesting - public static final Component ADD_FRIEND_SILENT_TEXT = Components.literal("+\ud83d\udd08"); - private static final Component ADD_FRIEND_NOTIFY_TEXT = Components.literal("+\ud83d\udd0a"); + public static final Component ADD_FRIEND_SILENT_TEXT = Component.literal("+\ud83d\udd08"); + private static final Component ADD_FRIEND_NOTIFY_TEXT = Component.literal("+\ud83d\udd0a"); //#else //$$ @VisibleForTesting - //$$ public static final Component ADD_FRIEND_SILENT_TEXT = Components.literal("+Q"); - //$$ private static final Component ADD_FRIEND_NOTIFY_TEXT = Components.literal("+N"); + //$$ public static final Component ADD_FRIEND_SILENT_TEXT = Component.literal("+Q"); + //$$ private static final Component ADD_FRIEND_NOTIFY_TEXT = Component.literal("+N"); //#endif - private static final Component ADD_FRIEND_SILENT_TOOLTIP = Components.translatable("world-host.friends.add_silently.tooltip"); - private static final Component ADD_FRIEND_NOTIFY_TOOLTIP = Components.translatable("world-host.add_friend.tooltip"); + private static final Component ADD_FRIEND_SILENT_TOOLTIP = Component.translatable("world-host.friends.add_silently.tooltip"); + private static final Component ADD_FRIEND_NOTIFY_TOOLTIP = Component.translatable("world-host.add_friend.tooltip"); private final Screen parent; private final BiConsumer addAction; diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java index a934b45d..ce6a67e8 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java @@ -7,7 +7,6 @@ import io.github.gaming32.worldhost.plugin.FriendListFriend; import io.github.gaming32.worldhost.plugin.InfoTextsCategory; import io.github.gaming32.worldhost.plugin.ProfileInfo; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; @@ -26,7 +25,7 @@ //#endif public class FriendsScreen extends ScreenWithInfoTexts { - public static final Component ADD_FRIEND_TEXT = Components.translatable("world-host.add_friend"); + public static final Component ADD_FRIEND_TEXT = Component.translatable("world-host.add_friend"); private final Screen parent; private Button infoButton; @@ -66,7 +65,7 @@ protected void init() { ); infoButton = addRenderableWidget( - button(Components.translatable("world-host.friends.show_info"), button -> { + button(Component.translatable("world-host.friends.show_info"), button -> { if (list.getSelected() != null) { list.getSelected().friend.showFriendInfo(this); } @@ -77,7 +76,7 @@ protected void init() { infoButton.active = false; removeButton = addRenderableWidget( - button(Components.translatable("world-host.friends.remove"), button -> { + button(Component.translatable("world-host.friends.remove"), button -> { if (list.getSelected() != null) { list.getSelected().maybeRemove(); } @@ -188,7 +187,7 @@ public FriendsEntry(FriendListFriend friend) { @NotNull @Override public Component getNarration() { - return Components.translatable("narrator.select", getNameWithTag()); + return Component.translatable("narrator.select", getNameWithTag()); } public Component getNameWithTag() { @@ -219,8 +218,8 @@ public void maybeRemove() { } minecraft.setScreen(FriendsScreen.this); }, - Components.translatable("world-host.friends.remove.title"), - Components.translatable("world-host.friends.remove.message") + Component.translatable("world-host.friends.remove.title"), + Component.translatable("world-host.friends.remove.message") )); } diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/JoiningWorldHostScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/JoiningWorldHostScreen.java index 27e76328..39239b9e 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/JoiningWorldHostScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/JoiningWorldHostScreen.java @@ -1,7 +1,6 @@ package io.github.gaming32.worldhost.gui.screen; import io.github.gaming32.worldhost.WorldHost; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; @@ -14,7 +13,7 @@ //#endif public class JoiningWorldHostScreen extends WorldHostScreen { - private static final Component MESSAGE = Components.translatable("world-host.joining_world_host"); + private static final Component MESSAGE = Component.translatable("world-host.joining_world_host"); public final Screen parent; diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java index 493f8400..1a461f73 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java @@ -15,7 +15,6 @@ import io.github.gaming32.worldhost.plugin.OnlineFriend; import io.github.gaming32.worldhost.plugin.ProfileInfo; import io.github.gaming32.worldhost.mixin.ServerStatusPingerAccessor; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.ChatFormatting; import net.minecraft.SharedConstants; import net.minecraft.Util; @@ -77,7 +76,7 @@ public class OnlineFriendsScreen extends ScreenWithInfoTexts implements FriendsL private List tooltip; public OnlineFriendsScreen(Screen parent) { - super(Components.translatable("world-host.online_friends.title"), InfoTextsCategory.ONLINE_FRIENDS_SCREEN); + super(Component.translatable("world-host.online_friends.title"), InfoTextsCategory.ONLINE_FRIENDS_SCREEN); this.parent = parent; } @@ -96,14 +95,14 @@ protected void init() { addWidget(list); joinButton = addRenderableWidget( - button(Components.translatable("selectServer.select"), button -> connect()) + button(Component.translatable("selectServer.select"), button -> connect()) .width(152) .pos(width / 2 - 154, height - 54) .build() ); addRenderableWidget( - button(Components.translatable("selectServer.refresh"), button -> WorldHost.refreshFriendsList()) + button(Component.translatable("selectServer.refresh"), button -> WorldHost.refreshFriendsList()) .width(152) .pos(width / 2 + 2, height - 54) .build() @@ -365,7 +364,7 @@ public OnlineFriendsListEntry(OnlineFriend friend) { @NotNull @Override public Component getNarration() { - return Components.translatable("narrator.select", displayName); + return Component.translatable("narrator.select", displayName); } @Override @@ -437,7 +436,7 @@ public void render( final int relY = mouseY - y; if (relX >= entryWidth - 15 && relX <= entryWidth - 5 && relY >= 0 && relY <= 8) { if (incompatibleVersion) { - tooltip = List.of(Components.translatable("multiplayer.status.incompatible").getVisualOrderText()); + tooltip = List.of(Component.translatable("multiplayer.status.incompatible").getVisualOrderText()); } } else if (relX >= entryWidth - labelWidth - 17 && relX <= entryWidth - 17 && relY >= 0 && relY <= 8) { tooltip = new ArrayList<>(); @@ -448,11 +447,7 @@ public void render( tooltip = joinabilityTooltip; } - //#if MC >= 1.19.0 final boolean touchscreen = minecraft.options.touchscreen().get(); - //#else - //$$ final boolean touchscreen = minecraft.options.touchscreen; - //#endif if (joinable && (touchscreen || hovered)) { fill(context, x, y, x + 32, y + 32, 0xa0909090); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); @@ -477,18 +472,18 @@ private void updateDisplayInfo() { updateNameAndTooltip(); final var metadata = WorldHost.ONLINE_FRIEND_PINGS.get(friend.uuid()); if (metadata == null) { - serverInfo.status = Components.EMPTY; - serverInfo.motd = Components.EMPTY; + serverInfo.status = CommonComponents.EMPTY; + serverInfo.motd = CommonComponents.EMPTY; return; } //#if MC >= 1.19.4 serverInfo.motd = metadata.description(); metadata.version().ifPresentOrElse(version -> { - serverInfo.version = Components.literal(version.name()); + serverInfo.version = Component.literal(version.name()); serverInfo.protocol = version.protocol(); }, () -> { - serverInfo.version = Components.translatable("multiplayer.status.old"); + serverInfo.version = Component.translatable("multiplayer.status.old"); serverInfo.protocol = 0; }); metadata.players().ifPresentOrElse(players -> { @@ -498,11 +493,11 @@ private void updateDisplayInfo() { final List playerList = new ArrayList<>(players.sample().size()); for(GameProfile gameProfile : players.sample()) { - playerList.add(Components.literal(gameProfile.getName())); + playerList.add(Component.literal(gameProfile.getName())); } if (players.sample().size() < players.online()) { - playerList.add(Components.translatable( + playerList.add(Component.translatable( "multiplayer.status.and_more", players.online() - players.sample().size() )); @@ -512,7 +507,7 @@ private void updateDisplayInfo() { } else { serverInfo.playerList = List.of(); } - }, () -> serverInfo.status = Components.translatable("multiplayer.status.unknown").withStyle(ChatFormatting.DARK_GRAY)); + }, () -> serverInfo.status = Component.translatable("multiplayer.status.unknown").withStyle(ChatFormatting.DARK_GRAY)); metadata.favicon().ifPresent(favicon -> { if (!Arrays.equals(favicon.iconBytes(), serverInfo.getIconBytes())) { serverInfo.setIconBytes(favicon.iconBytes()); @@ -522,14 +517,14 @@ private void updateDisplayInfo() { //$$ if (metadata.getDescription() != null) { //$$ serverInfo.motd = metadata.getDescription(); //$$ } else { - //$$ serverInfo.motd = Components.EMPTY; + //$$ serverInfo.motd = Component.empty(); //$$ } //$$ //$$ if (metadata.getVersion() != null) { - //$$ serverInfo.version = Components.literal(metadata.getVersion().getName()); + //$$ serverInfo.version = Component.literal(metadata.getVersion().getName()); //$$ serverInfo.protocol = metadata.getVersion().getProtocol(); //$$ } else { - //$$ serverInfo.version = Components.translatable("multiplayer.status.old"); + //$$ serverInfo.version = Component.translatable("multiplayer.status.old"); //$$ serverInfo.protocol = 0; //$$ } //$$ @@ -542,17 +537,17 @@ private void updateDisplayInfo() { //$$ final GameProfile[] sampleProfiles = metadata.getPlayers().getSample(); //$$ if (sampleProfiles != null && sampleProfiles.length > 0) { //$$ for (final GameProfile sampleProfile : sampleProfiles) { - //$$ lines.add(Components.literal(sampleProfile.getName())); + //$$ lines.add(Component.literal(sampleProfile.getName())); //$$ } //$$ if (sampleProfiles.length < metadata.getPlayers().getNumPlayers()) { - //$$ lines.add(Components.translatable( + //$$ lines.add(Component.translatable( //$$ "multiplayer.status.and_more", metadata.getPlayers().getNumPlayers() - sampleProfiles.length //$$ )); //$$ } //$$ serverInfo.playerList = lines; //$$ } //$$ } else { - //$$ serverInfo.status = Components.translatable("multiplayer.status.unknown").withStyle(ChatFormatting.DARK_GRAY); + //$$ serverInfo.status = Component.translatable("multiplayer.status.unknown").withStyle(ChatFormatting.DARK_GRAY); //$$ } //$$ //$$ String favicon = serverInfo.getIconB64(); @@ -574,9 +569,9 @@ private void updateNameAndTooltip() { final MutableComponent newDisplayName; if (security == SecurityLevel.SECURE) { - newDisplayName = Components.literal(profile.name()); + newDisplayName = Component.literal(profile.name()); } else { - newDisplayName = Components.translatable( + newDisplayName = Component.translatable( "world-host.world_with_security", profile.name(), EnumButton.getTranslation("world-host.config.requiredSecurityLevel", security) diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/PlayerInfoScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/PlayerInfoScreen.java index b605579e..5c912946 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/PlayerInfoScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/PlayerInfoScreen.java @@ -3,9 +3,9 @@ import com.mojang.authlib.GameProfile; import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.gui.widget.WHPlayerSkinWidget; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.CommonComponents; +import net.minecraft.network.chat.Component; //#if MC >= 1.20.0 import net.minecraft.client.gui.GuiGraphics; @@ -18,7 +18,7 @@ public class PlayerInfoScreen extends WorldHostScreen { private GameProfile profile; public PlayerInfoScreen(Screen parentScreen, GameProfile profile) { - super(Components.empty()); + super(Component.empty()); this.parentScreen = parentScreen; this.profile = profile; diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostConfigScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostConfigScreen.java index 7ca92cc4..9ecf1919 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostConfigScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostConfigScreen.java @@ -3,7 +3,6 @@ import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.WorldHostComponents; import io.github.gaming32.worldhost.config.option.ConfigOptions; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; @@ -20,8 +19,8 @@ //#endif public class WorldHostConfigScreen extends WorldHostScreen { - private static final Component TITLE = Components.translatable("world-host.config.title"); - private static final Component UPNP = Components.literal("UPnP"); + private static final Component TITLE = Component.translatable("world-host.config.title"); + private static final Component UPNP = Component.literal("UPnP"); private final Screen parent; diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java index 259777c0..629e353c 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java @@ -1,8 +1,8 @@ package io.github.gaming32.worldhost.gui.widget; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,7 +45,7 @@ protected CustomCycleButton( Consumer onUpdate, T[] values ) { super( - x, y, width, height, Components.EMPTY, b -> { + x, y, width, height, CommonComponents.EMPTY, b -> { @SuppressWarnings("unchecked") final B cycle = (B)b; final int add = Screen.hasShiftDown() ? -1 : 1; cycle.setValueIndex(Math.floorMod(cycle.getValueIndex() + add, cycle.getValues().length)); diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/EnumButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/EnumButton.java index 8f039bb0..4c32f280 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/EnumButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/EnumButton.java @@ -1,6 +1,5 @@ package io.github.gaming32.worldhost.gui.widget; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.network.chat.Component; import net.minecraft.util.StringRepresentable; import org.jetbrains.annotations.NotNull; @@ -34,7 +33,7 @@ private Component[] getTranslations(String translationBase) { } public static Component getTranslation(String base, StringRepresentable element) { - return Components.translatable(base + '.' + element.getSerializedName()); + return Component.translatable(base + '.' + element.getSerializedName()); } public void setValue(E value) { diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java index 34a1c5f0..d8804f3d 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java @@ -4,10 +4,10 @@ import io.github.gaming32.worldhost.WorldHostComponents; import io.github.gaming32.worldhost.gui.screen.WorldHostScreen; import io.github.gaming32.worldhost.plugin.OnlineFriend; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.Button; +import net.minecraft.network.chat.CommonComponents; import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -24,7 +24,7 @@ public final class FriendsButton extends Button implements FriendsListUpdate { public FriendsButton(int x, int y, int width, int height, OnPress onPress) { super( - x, y, width, height, Components.EMPTY, onPress + x, y, width, height, CommonComponents.EMPTY, onPress //#if MC >= 1.19.4 , DEFAULT_NARRATION //#endif diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java index c155c330..2fbe85e9 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java @@ -3,7 +3,6 @@ import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.gui.screen.WorldHostConfigScreen; import io.github.gaming32.worldhost.mixin.PlainTextButtonAccessor; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; @@ -31,9 +30,9 @@ public final class OnlineStatusButton extends PlainTextButton { }; private static final List> TEXTS = List.of( - () -> Components.translatable("world-host.online_status.offline", WorldHost.reconnectDelay / 20 + 1), - () -> Components.translatable("world-host.online_status.connecting"), - () -> Components.translatable("world-host.online_status.online") + () -> Component.translatable("world-host.online_status.offline", WorldHost.reconnectDelay / 20 + 1), + () -> Component.translatable("world-host.online_status.connecting"), + () -> Component.translatable("world-host.online_status.online") ); private final int alignedX; @@ -79,9 +78,9 @@ private static int getStatus() { private static Component generateStatusComponent() { final int status = getStatus(); - return Components.translatable( + return Component.translatable( "world-host.online_status", - Components.literal("\u25cf").withStyle(COLORS[status]), + Component.literal("\u25cf").withStyle(COLORS[status]), TEXTS.get(status).get() ); } diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/UserListWidget.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/UserListWidget.java index 6aa83c00..4ef06790 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/UserListWidget.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/UserListWidget.java @@ -2,18 +2,17 @@ import com.mojang.blaze3d.systems.RenderSystem; import io.github.gaming32.worldhost.WorldHost; -import io.github.gaming32.worldhost.WorldHostComponents; import io.github.gaming32.worldhost.gui.screen.WorldHostScreen; import io.github.gaming32.worldhost.plugin.FriendListFriend; import io.github.gaming32.worldhost.plugin.ProfileInfo; import io.github.gaming32.worldhost.toast.IconRenderer; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.locale.Language; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import net.minecraft.util.FormattedCharSequence; @@ -70,7 +69,7 @@ public UserListWidget( Function> getApplicableActions, @Nullable UserListWidget old ) { - super(x, y, width, height, Components.empty()); + super(x, y, width, height, Component.empty()); this.font = font; this.getApplicableActions = getApplicableActions; if (old != null && !old.users.isEmpty()) { @@ -246,11 +245,11 @@ public int getVisibleCount() { public static Component getNameWithTag(FriendListFriend user, ProfileInfo profile) { return user.tag() - .map(component -> Components.translatable( + .map(component -> Component.translatable( "world-host.friends.tagged_friend", profile.name(), component )) - .orElseGet(() -> Components.literal(profile.name())); + .orElseGet(() -> Component.literal(profile.name())); } private final class UserInfo { @@ -283,8 +282,8 @@ int getMaxNameWidth() { } FormattedCharSequence clipName(Component unclippedName) { - final FormattedText clipped = font.substrByWidth(unclippedName, getMaxNameWidth() - font.width(WorldHostComponents.ELLIPSIS)); - return Language.getInstance().getVisualOrder(FormattedText.composite(clipped, WorldHostComponents.ELLIPSIS)); + final FormattedText clipped = font.substrByWidth(unclippedName, getMaxNameWidth() - font.width(CommonComponents.ELLIPSIS)); + return Language.getInstance().getVisualOrder(FormattedText.composite(clipped, CommonComponents.ELLIPSIS)); } IconRenderer getIcon() { diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java index 3e6a3e68..f3016fa4 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java @@ -3,7 +3,6 @@ import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.vertex.VertexConsumer; import io.github.gaming32.worldhost.WHPlayerSkin; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.model.PlayerModel; @@ -14,6 +13,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.sounds.SoundManager; +import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import java.util.function.BooleanSupplier; @@ -56,7 +56,7 @@ public WHPlayerSkinWidget( Supplier skin, BooleanSupplier isDeadmau5, EntityModelSet models ) { - super(x, y, width, height, Components.empty()); + super(x, y, width, height, Component.empty()); this.skin = skin; this.isDeadmau5 = isDeadmau5; diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MinecraftAccessor.java b/src/main/java/io/github/gaming32/worldhost/mixin/MinecraftAccessor.java index 0e7cad00..2a079e97 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MinecraftAccessor.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MinecraftAccessor.java @@ -7,8 +7,6 @@ @Mixin(Minecraft.class) public interface MinecraftAccessor { - //#if MC >= 1.19.2 @Accessor YggdrasilAuthenticationService getAuthenticationService(); - //#endif } diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen_1.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen_1.java index 332c44ef..1c754ff8 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen_1.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen_1.java @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -//#if MC > 1.18.2 && MC < 1.19.4 +//#if MC < 1.19.4 //$$ import java.util.concurrent.CompletableFuture; //#endif diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinIntegratedServer.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinIntegratedServer.java index 914af03f..ff697bbe 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinIntegratedServer.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinIntegratedServer.java @@ -1,15 +1,16 @@ package io.github.gaming32.worldhost.mixin; import com.mojang.datafixers.DataFixer; +import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.proxy.ProxyChannels; import io.github.gaming32.worldhost.proxy.ProxyClient; -import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.versions.Components; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.server.IntegratedServer; import net.minecraft.network.chat.Component; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.Services; import net.minecraft.server.WorldStem; import net.minecraft.server.level.progress.ChunkProgressListenerFactory; import net.minecraft.server.packs.repository.PackRepository; @@ -26,20 +27,9 @@ import java.net.Proxy; -//#if MC > 1.18.2 -import net.minecraft.server.Services; -//#else -//$$ import com.mojang.authlib.GameProfileRepository; -//$$ import com.mojang.authlib.minecraft.MinecraftSessionService; -//$$ import net.minecraft.Util; -//$$ import net.minecraft.network.chat.ChatType; -//$$ import net.minecraft.server.players.GameProfileCache; -//#endif - @Mixin(IntegratedServer.class) public abstract class MixinIntegratedServer extends MinecraftServer { public MixinIntegratedServer( - //#if MC > 1.18.2 Thread thread, LevelStorageSource.LevelStorageAccess levelStorageAccess, PackRepository packRepository, @@ -48,24 +38,8 @@ public MixinIntegratedServer( DataFixer dataFixer, Services services, ChunkProgressListenerFactory chunkProgressListenerFactory - //#else - //$$ Thread thread, - //$$ LevelStorageSource.LevelStorageAccess levelStorageAccess, - //$$ PackRepository packRepository, - //$$ WorldStem worldStem, - //$$ Proxy proxy, - //$$ DataFixer dataFixer, - //$$ MinecraftSessionService minecraftSessionService, - //$$ GameProfileRepository gameProfileRepository, - //$$ GameProfileCache gameProfileCache, - //$$ ChunkProgressListenerFactory chunkProgressListenerFactory - //#endif ) { - //#if MC > 1.18.2 super(thread, levelStorageAccess, packRepository, worldStem, proxy, dataFixer, services, chunkProgressListenerFactory); - //#else - //$$ super(thread, levelStorageAccess, packRepository, worldStem, proxy, dataFixer, minecraftSessionService, gameProfileRepository, gameProfileCache, chunkProgressListenerFactory); - //#endif } @Shadow @Final private Minecraft minecraft; @@ -101,26 +75,22 @@ private void shareWorldOnLoad(CallbackInfo ci) { if (publishServer(worldData.getGameType(), allowCommands, HttpUtil.getAvailablePort())) { message = wh$getOpenedMessage(); } else { - message = Components.translatable("world-host.share_world.failed").withStyle(ChatFormatting.RED); + message = Component.translatable("world-host.share_world.failed").withStyle(ChatFormatting.RED); } - //#if MC > 1.18.2 minecraft.getChatListener().handleSystemMessage(message, false); - //#else - //$$ minecraft.gui.handleChat(ChatType.SYSTEM, message, Util.NIL_UUID); - //#endif } @Unique private Component wh$getOpenedMessage() { final Component port = Components.copyOnClickText(publishedPort); if (WorldHost.CONFIG.isEnableFriends()) { - return Components.translatable("world-host.lan_opened.friends", port); + return Component.translatable("world-host.lan_opened.friends", port); } final String externalIp = WorldHost.getExternalIp(); if (externalIp == null) { - return Components.translatable("commands.publish.started", port); + return Component.translatable("commands.publish.started", port); } - return Components.translatable( + return Component.translatable( "world-host.lan_opened.no_friends", Components.copyOnClickText(externalIp), port ); diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinPublishCommand.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinPublishCommand.java index ccbb3daa..f0811f04 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinPublishCommand.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinPublishCommand.java @@ -2,6 +2,7 @@ import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.versions.Components; +import net.minecraft.network.chat.Component; import net.minecraft.server.commands.PublishCommand; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -20,7 +21,7 @@ public class MixinPublishCommand { @Inject(method = "getSuccessMessage", at = @At("HEAD"), cancellable = true) private static void getSuccessMessage(int port, CallbackInfoReturnable cir) { if (WorldHost.CONFIG.isEnableFriends()) { - cir.setReturnValue(Components.translatable( + cir.setReturnValue(Component.translatable( "world-host.lan_opened.friends", Components.copyOnClickText(port) )); @@ -28,7 +29,7 @@ private static void getSuccessMessage(int port, CallbackInfoReturnable= 1.19.2 - //$$ "Lnet/minecraft/network/chat/Component;translatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/network/chat/MutableComponent;" - //#else - //$$ "Lnet/minecraft/network/chat/TranslatableComponent;(Ljava/lang/String;[Ljava/lang/Object;)V" - //#endif + //$$ target = "Lnet/minecraft/network/chat/Component;translatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/network/chat/MutableComponent;" //$$ ) //$$ ) //$$ private static String getSuccessMessage(String key) { @@ -62,12 +58,7 @@ private static void getSuccessMessage(int port, CallbackInfoReturnable= 1.19.2 - //$$ "Lnet/minecraft/network/chat/Component;translatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/network/chat/MutableComponent;" - //#else - //$$ "Lnet/minecraft/network/chat/TranslatableComponent;(Ljava/lang/String;[Ljava/lang/Object;)V" - //#endif + //$$ target = "Lnet/minecraft/network/chat/Component;translatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/network/chat/MutableComponent;" //$$ ) //$$ ) //$$ private static Object[] getSuccessMessage(Object[] args) { diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinSelectWorldScreen.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinSelectWorldScreen.java index 3bdd0b07..fde7216f 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinSelectWorldScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinSelectWorldScreen.java @@ -4,7 +4,6 @@ import io.github.gaming32.worldhost.WorldHostComponents; import io.github.gaming32.worldhost.ext.SelectWorldScreenExt; import io.github.gaming32.worldhost.gui.screen.WorldHostScreen; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.worldselection.SelectWorldScreen; @@ -74,7 +73,7 @@ private void addShareWorldButton(CallbackInfo ci) { return; } wh$shareButton = addRenderableWidget( - WorldHostScreen.button(Components.translatable("world-host.share_world"), b -> + WorldHostScreen.button(Component.translatable("world-host.share_world"), b -> list.getSelectedOpt().ifPresent(worldListEntry -> { wh$shareButtonPressed = true; worldListEntry.joinWorld(); @@ -124,9 +123,7 @@ private void updateShareButtonStatus(LevelSummary levelSummary, CallbackInfo ci) //#else //$$ private void updateShareButtonStatus( //$$ boolean active, - //#if MC > 1.19.2 - //$$ boolean bl2, - //#endif + //$$ boolean bl2, //$$ CallbackInfo ci //$$ ) { //$$ if (wh$shareButton != null) { diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinShareToLanScreen.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinShareToLanScreen.java index 8012ce38..081e0a2a 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinShareToLanScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinShareToLanScreen.java @@ -29,12 +29,7 @@ private String changeLabelI2(String constant) { //$$ method = "lambda$init$2", //$$ at = @At( //$$ value = "INVOKE", - //$$ target = - //#if MC >= 1.19.2 - //$$ "Lnet/minecraft/network/chat/Component;translatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/network/chat/MutableComponent;" - //#else - //$$ "Lnet/minecraft/network/chat/TranslatableComponent;(Ljava/lang/String;[Ljava/lang/Object;)V" - //#endif + //$$ target = "Lnet/minecraft/network/chat/Component;translatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/network/chat/MutableComponent;" //$$ ) //$$ ) //$$ private String changeSuccessMessage(String key) { @@ -49,12 +44,7 @@ private String changeLabelI2(String constant) { //$$ method = "lambda$init$2", //$$ at = @At( //$$ value = "INVOKE", - //$$ target = - //#if MC >= 1.19.2 - //$$ "Lnet/minecraft/network/chat/Component;translatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/network/chat/MutableComponent;" - //#else - //$$ "Lnet/minecraft/network/chat/TranslatableComponent;(Ljava/lang/String;[Ljava/lang/Object;)V" - //#endif + //$$ target = "Lnet/minecraft/network/chat/Component;translatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/network/chat/MutableComponent;" //$$ ) //$$ ) //$$ private Object[] changeSuccessMessage(Object[] args) { diff --git a/src/main/java/io/github/gaming32/worldhost/plugin/vanilla/WorldHostFriendAdder.java b/src/main/java/io/github/gaming32/worldhost/plugin/vanilla/WorldHostFriendAdder.java index 414c4520..512e7b43 100644 --- a/src/main/java/io/github/gaming32/worldhost/plugin/vanilla/WorldHostFriendAdder.java +++ b/src/main/java/io/github/gaming32/worldhost/plugin/vanilla/WorldHostFriendAdder.java @@ -4,10 +4,9 @@ import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.plugin.FriendAdder; import io.github.gaming32.worldhost.plugin.FriendListFriend; -import io.github.gaming32.worldhost.versions.Components; +import net.minecraft.core.UUIDUtil; import net.minecraft.network.chat.Component; -import java.nio.charset.StandardCharsets; import java.util.UUID; import java.util.function.Consumer; import java.util.regex.Pattern; @@ -18,7 +17,7 @@ public class WorldHostFriendAdder implements FriendAdder { @Override public Component label() { - return Components.literal("World Host"); + return Component.literal("World Host"); } @Override @@ -32,9 +31,9 @@ public void searchFriends(String name, int maxResults, Consumer= 1.19.1 -import com.mojang.authlib.exceptions.UserBannedException; -//#endif - public final class ProtocolClient implements AutoCloseable, ProxyPassthrough { private static final Thread.Builder CONNECTION_THREAD_BUILDER = Thread.ofVirtual().name("WH-ConnectionThread-", 1); private static final Thread.Builder SEND_THREAD_BUILDER = Thread.ofVirtual().name("WH-SendThread-", 1); @@ -298,7 +295,6 @@ private static String authenticateServer( } catch (InsufficientPrivilegesException e) { return I18n.get("disconnect.loginFailedInfo.insufficientPrivileges"); } catch (AuthenticationException e) { - //#if MC >= 1.19.1 if ( //#if MC >= 1.20.2 e instanceof ForcedUsernameChangeException || @@ -307,7 +303,6 @@ private static String authenticateServer( ) { return I18n.get("disconnect.loginFailedInfo.userBanned"); } - //#endif return e.getMessage(); } } diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java index c3b169f2..e6dec0e4 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java @@ -16,12 +16,12 @@ import io.github.gaming32.worldhost.protocol.punch.PunchManager; import io.github.gaming32.worldhost.protocol.punch.PunchReason; import io.github.gaming32.worldhost.toast.WHToast; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.DisconnectedScreen; import net.minecraft.client.gui.screens.TitleScreen; import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.status.ServerStatus; import java.io.DataInputStream; @@ -67,7 +67,7 @@ public static Error decode(DataInputStream dis) throws IOException { public void handle(ProtocolClient client) { if (critical) { WHToast.builder("world-host.protocol_error_occurred") - .description(Components.literal(message)) + .description(Component.literal(message)) .show(); throw new RuntimeException(message); } else { @@ -371,7 +371,7 @@ public void handle(ProtocolClient client) { if (version.isEmpty()) return; final String updateLink = WorldHostUpdateChecker.formatUpdateLink(version.get()); WHToast.builder("world-host.outdated_world_host") - .description(Components.translatable( + .description(Component.translatable( "world-host.outdated_world_host.desc", currentVersion, version.get() )) @@ -401,8 +401,8 @@ public void handle(ProtocolClient client) { } minecraft.setScreen(new DisconnectedScreen( parentScreen, - Components.translatable("world-host.connection_not_found"), - Components.translatable("world-host.connection_not_found.desc", WorldHost.connectionIdToString(connectionId)) + Component.translatable("world-host.connection_not_found"), + Component.translatable("world-host.connection_not_found.desc", WorldHost.connectionIdToString(connectionId)) )); }); } @@ -443,8 +443,8 @@ public static Warning decode(DataInputStream dis) throws IOException { @Override public void handle(ProtocolClient client) { WorldHost.LOGGER.warn("Warning from WH server (important: {}): {}", important, message); - WHToast.builder(Components.translatable("world-host.protocol_warning_occurred")) - .description(Components.literal(message)) + WHToast.builder(Component.translatable("world-host.protocol_warning_occurred")) + .description(Component.literal(message)) .important(important) .show(); } diff --git a/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java b/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java index 140d5426..42f80c27 100644 --- a/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java +++ b/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java @@ -8,18 +8,13 @@ import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.contents.TranslatableContents; import org.intellij.lang.annotations.RegExp; import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Stream; -//#if MC >= 1.19.2 -import net.minecraft.network.chat.contents.TranslatableContents; -//#else -//$$ import net.minecraft.network.chat.TranslatableComponent; -//#endif - public class MinecraftApi { private static final Thread.Builder SLEEP_BUILDER = Thread.ofVirtual().name("WH-TestingSleeper-", 1); @@ -83,11 +78,7 @@ public static AbstractWidget findWidgetByString(Predicate messageMatcher public static AbstractWidget findWidgetByTranslation(String translation) { return findWidget( - //#if MC >= 1.19.2 c -> c.getContents() instanceof TranslatableContents translatable && translatable.getKey().equals(translation), - //#else - //$$ c -> c instanceof TranslatableComponent translatable && translatable.getKey().equals(translation), - //#endif "Could not find widget with translation key \"" + translation + "\"" ); } diff --git a/src/main/java/io/github/gaming32/worldhost/toast/ToastInstance.java b/src/main/java/io/github/gaming32/worldhost/toast/ToastInstance.java index 25d727f0..f1bc803c 100644 --- a/src/main/java/io/github/gaming32/worldhost/toast/ToastInstance.java +++ b/src/main/java/io/github/gaming32/worldhost/toast/ToastInstance.java @@ -5,6 +5,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.network.chat.Component; +import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.Mth; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -19,8 +20,6 @@ import net.minecraft.client.gui.GuiGraphics; //#endif -import net.minecraft.util.FormattedCharSequence; - class ToastInstance { private static final int TEXT_WIDTH = 200; private static final int BORDER_SIZE = 5; diff --git a/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java b/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java index e8327b89..e591558b 100644 --- a/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java +++ b/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java @@ -5,7 +5,6 @@ import io.github.gaming32.worldhost.ResourceLocations; import io.github.gaming32.worldhost.gui.screen.WorldHostScreen; import io.github.gaming32.worldhost.testing.WorldHostTesting; -import io.github.gaming32.worldhost.versions.Components; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.network.chat.Component; @@ -36,7 +35,7 @@ public static ToastBuilder builder(@NotNull Component title) { } public static ToastBuilder builder(@NotNull @Translatable String titleKey) { - return new ToastBuilder(Components.translatable(titleKey)); + return new ToastBuilder(Component.translatable(titleKey)); } public static void ready() { diff --git a/src/main/java/io/github/gaming32/worldhost/versions/Components.java b/src/main/java/io/github/gaming32/worldhost/versions/Components.java index 7a530527..a7e7c760 100644 --- a/src/main/java/io/github/gaming32/worldhost/versions/Components.java +++ b/src/main/java/io/github/gaming32/worldhost/versions/Components.java @@ -1,63 +1,21 @@ package io.github.gaming32.worldhost.versions; -import com.demonwav.mcdev.annotations.Translatable; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.ClickEvent; -import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.ComponentUtils; import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; -//#if MC < 1.19.2 -//$$ import net.minecraft.network.chat.TextComponent; -//$$ import net.minecraft.network.chat.TranslatableComponent; -//#endif - public class Components { - //#if MC >= 1.19.2 - public static final Component EMPTY = CommonComponents.EMPTY; - //#else - //$$ public static final Component EMPTY = TextComponent.EMPTY; - //#endif - - public static MutableComponent literal(String text) { - //#if MC >= 1.19.1 - return Component.literal(text); - //#else - //$$ return new TextComponent(text); - //#endif - } - - public static MutableComponent translatable(@Translatable(foldMethod = true) String key) { - //#if MC >= 1.19.1 - return Component.translatable(key); - //#else - //$$ return new TranslatableComponent(key); - //#endif - } - - public static MutableComponent translatable(@Translatable(foldMethod = true) String key, Object... args) { - //#if MC >= 1.19.1 - return Component.translatable(key, args); - //#else - //$$ return new TranslatableComponent(key, args); - //#endif - } - - // TODO: Remove when 1.19.2 becomes the minimum - public static MutableComponent empty() { - return EMPTY.copy(); - } - // TODO: Remove when 1.19.4 becomes the minimum public static MutableComponent copyOnClickText(Object obj) { final String text = obj.toString(); return ComponentUtils.wrapInSquareBrackets( - literal(text).withStyle(style -> style + Component.literal(text).withStyle(style -> style .withColor(ChatFormatting.GREEN) .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, text)) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, translatable("chat.copy.click"))) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.translatable("chat.copy.click"))) .withInsertion(text) ) ); diff --git a/version.gradle.kts b/version.gradle.kts index 7c8243b3..4e61865b 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -98,12 +98,6 @@ unimined.minecraft { parchment(it.substringBefore(":"), it.substringAfter(":")) } - if (mcVersion <= 1_19_00) { - stub.withMappings("searge", listOf("mojmap")) { - c("net/minecraft/client/gui/chat/NarratorChatListener", "net/minecraft/client/GameNarrator") - } - } - devFallbackNamespace("official") } @@ -116,7 +110,6 @@ unimined.minecraft { 1_20_01 -> "47.1.3" 1_19_04 -> "45.1.0" 1_19_02 -> "43.2.0" - 1_18_02 -> "40.2.0" else -> throw IllegalStateException("Unknown Forge version for $mcVersionString") }) mixinConfig("world-host.mixins.json") @@ -281,7 +274,6 @@ dependencies { 1_20_01 -> "7.2.2" 1_19_04 -> "6.3.1" 1_19_02 -> "4.2.0-beta.2" - 1_18_02 -> "3.2.5" else -> null }?.let { modImplementation("com.terraformersmc:modmenu:$it") @@ -303,7 +295,6 @@ dependencies { 1_20_01 -> "0.92.2+1.20.1" 1_19_04 -> "0.87.2+1.19.4" 1_19_02 -> "0.77.0+1.19.2" - 1_18_02 -> "0.77.0+1.18.2" else -> null }?.let { fapiVersion -> val resourceLoader = fabricApi.fabricModule("fabric-resource-loader-v0", fapiVersion) @@ -339,7 +330,6 @@ dependencies { 1_20_01 -> "2.5.20" 1_19_04 -> "2.5.12" 1_19_02 -> "2.5.20" - 1_18_02 -> "2.5.20" else -> null }?.let { modCompileOnly("maven.modrinth:simple-voice-chat:$loaderName-$mcVersionString-$it") From 6805701ee2569df0da484243f330410a4e53cdd3 Mon Sep 17 00:00:00 2001 From: Josiah Glosson Date: Thu, 24 Oct 2024 15:09:24 -0500 Subject: [PATCH 2/6] 1.21.3 compiles --- build.gradle.kts | 26 ++-- settings.gradle.kts | 2 + .../gui/screen/OnlineFriendsScreen.java | 7 +- .../gui/screen/PlayerInfoScreen.java | 1 - .../worldhost/gui/screen/WorldHostScreen.java | 28 +++- .../gui/widget/WHPlayerSkinWidget.java | 121 +++++++++--------- .../worldhost/mixin/MixinGameRenderer.java | 19 ++- .../resources/META-INF/neoforge.mods.toml | 4 +- src/main/resources/fabric.mod.json | 4 +- version.gradle.kts | 6 + versions/mainProject | 2 +- 11 files changed, 132 insertions(+), 88 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a6400bab..3b4b2573 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,6 +8,8 @@ repositories { } preprocess { + val fabric12103 = createNode("1.21.3-fabric", 1_21_03, "yarn") + val neoforge12103 = createNode("1.21.3-neoforge", 1_21_03, "yarn") val fabric12101 = createNode("1.21.1-fabric", 1_21_01, "yarn") val neoforge12101 = createNode("1.21.1-neoforge", 1_21_01, "yarn") val fabric12006 = createNode("1.20.6-fabric", 1_20_06, "yarn") @@ -21,15 +23,17 @@ preprocess { val fabric11902 = createNode("1.19.2-fabric", 1_19_02, "yarn") val forge11902 = createNode("1.19.2-forge", 1_19_02, "srg") - fabric12101.link(neoforge12101) - neoforge12101.link(neoforge12006) - neoforge12006.link(fabric12006) - fabric12006.link(fabric12004) - fabric12004.link(neoforge12004) - neoforge12004.link(forge12001) - forge12001.link(fabric12001) - fabric12001.link(fabric11904) - fabric11904.link(forge11904) - forge11904.link(forge11902) - forge11902.link(fabric11902) + fabric12103.link(neoforge12103) + neoforge12103.link(neoforge12101) + neoforge12101.link(fabric12101) + fabric12101.link(fabric12006) + fabric12006.link(neoforge12006) + neoforge12006.link(neoforge12004) + neoforge12004.link(fabric12004) + fabric12004.link(fabric12001) + fabric12001.link(forge12001) + forge12001.link(forge11904) + forge11904.link(fabric11904) + fabric11904.link(fabric11902) + fabric11902.link(forge11902) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 53bfd0ef..0a2688c2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -31,6 +31,8 @@ listOf( "1.20.6-fabric", "1.21.1-neoforge", "1.21.1-fabric", + "1.21.3-neoforge", + "1.21.3-fabric", ).forEach { version -> include(":$version") project(":$version").apply { diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java index 1a461f73..4d6905dc 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java @@ -395,7 +395,7 @@ public void render( if (incompatibleVersion) { RenderSystem.enableBlend(); //#if MC >= 1.20.2 - context.blitSprite(INCOMPATIBLE_SPRITE, x + entryWidth - 15, y, 10, 8); + blitSprite(context, INCOMPATIBLE_SPRITE, x + entryWidth - 15, y, 10, 8); //#else //$$ blit(context, GUI_ICONS_LOCATION, x + entryWidth - 15, y, 0, 216, 10, 8, 256, 256); //#endif @@ -413,7 +413,6 @@ public void render( iconData = icon; } else { //#if MC >= 1.19.4 - //noinspection DataFlowIssue serverInfo.setIconBytes(null); //#else //$$ serverInfo.setIconB64(null); @@ -453,9 +452,9 @@ public void render( RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); //#if MC >= 1.20.2 if (relX < 32 && relX > 16) { - context.blitSprite(JOIN_HIGHLIGHTED_SPRITE, x, y, 32, 32); + blitSprite(context, JOIN_HIGHLIGHTED_SPRITE, x, y, 32, 32); } else { - context.blitSprite(JOIN_SPRITE, x, y, 32, 32); + blitSprite(context, JOIN_SPRITE, x, y, 32, 32); } //#else //$$ if (relX < 32 && relX > 16) { diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/PlayerInfoScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/PlayerInfoScreen.java index 5c912946..8f4ccc63 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/PlayerInfoScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/PlayerInfoScreen.java @@ -39,7 +39,6 @@ protected void init() { width / 2 - 100, top, 200, bottom - top, () -> WorldHost.getInsecureSkin(profile), - () -> profile.getName().equals("deadmau5"), minecraft.getEntityModels() )); addRenderableWidget( diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java index 0dbd3a72..2a8fc4ec 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java @@ -20,9 +20,12 @@ //#endif //#if MC < 1.19.4 -//$$ import net.minecraft.client.Minecraft; -//$$ //$$ import java.util.function.Consumer; +//$$ import net.minecraft.client.Minecraft; +//#endif + +//#if MC >= 1.21.2 +import net.minecraft.client.renderer.RenderType; //#endif import net.minecraft.util.FormattedCharSequence; @@ -147,7 +150,7 @@ public static void blit( //#else GuiGraphics context, //#endif - ResourceLocation texture, int x, int y, int width, int height, float uOffset, float vOffset, int uWidth, int vHeight, int textureWidth, int textureHeight + ResourceLocation texture, int x, int y, int width, int height, int uOffset, int vOffset, int uWidth, int vHeight, int textureWidth, int textureHeight ) { //#if MC >= 1.20.0 context. @@ -156,6 +159,9 @@ public static void blit( //$$ GuiComponent. //#endif blit( + //#if MC >= 1.21.2 + RenderType::guiTextured, + //#endif //#if MC < 1.20.0 //$$ context, //#else @@ -172,7 +178,7 @@ public static void blit( //#else GuiGraphics context, //#endif - ResourceLocation texture, int x, int y, float uOffset, float vOffset, int width, int height, int textureWidth, int textureHeight + ResourceLocation texture, int x, int y, int uOffset, int vOffset, int width, int height, int textureWidth, int textureHeight ) { //#if MC >= 1.20.0 context. @@ -181,6 +187,9 @@ public static void blit( //$$ GuiComponent. //#endif blit( + //#if MC >= 1.21.2 + RenderType::guiTextured, + //#endif //#if MC < 1.20.0 //$$ context, //#else @@ -190,6 +199,17 @@ public static void blit( ); } + //#if MC >= 1.20.2 + public static void blitSprite(GuiGraphics graphics, ResourceLocation sprite, int x, int y, int width, int height) { + graphics.blitSprite( + //#if MC >= 1.21.2 + RenderType::guiTextured, + //#endif + sprite, x, y, width, height + ); + } + //#endif + public static void drawString( @NotNull //#if MC < 1.20.0 diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java index f3016fa4..0fd550a9 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java @@ -16,7 +16,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; -import java.util.function.BooleanSupplier; +import java.util.function.Consumer; import java.util.function.Supplier; import static io.github.gaming32.worldhost.gui.screen.WorldHostScreen.pose; @@ -35,6 +35,11 @@ //$$ import static com.mojang.math.Vector3f.*; //#endif +//#if MC >= 1.21.2 +import net.minecraft.client.model.PlayerCapeModel; +import net.minecraft.client.renderer.entity.state.PlayerRenderState; +//#endif + public class WHPlayerSkinWidget extends AbstractWidget { private static final float MODEL_OFFSET = 0.0625f; private static final float MODEL_HEIGHT = 2.125f; @@ -45,25 +50,35 @@ public class WHPlayerSkinWidget extends AbstractWidget { private static final float ROTATION_X_LIMIT = 50f; private final Supplier skin; - private final BooleanSupplier isDeadmau5; - private final PlayerModel wideModel; - private final PlayerModel slimModel; + //#if MC >= 1.21.2 + private final PlayerModel wideModel; + private final PlayerModel slimModel; + private final PlayerCapeModel capeModel; + //#else + //$$ private final PlayerModel wideModel; + //$$ private final PlayerModel slimModel; + //#endif private float rotationX = DEFAULT_ROTATION_X; private float rotationY = DEFAULT_ROTATION_Y; public WHPlayerSkinWidget( int x, int y, int width, int height, - Supplier skin, BooleanSupplier isDeadmau5, + Supplier skin, EntityModelSet models ) { super(x, y, width, height, Component.empty()); this.skin = skin; - this.isDeadmau5 = isDeadmau5; - wideModel = new PlayerModel<>(models.bakeLayer(ModelLayers.PLAYER), false); - slimModel = new PlayerModel<>(models.bakeLayer(ModelLayers.PLAYER_SLIM), true); - wideModel.young = false; - slimModel.young = false; + //#if MC >= 1.21.2 + wideModel = new PlayerModel(models.bakeLayer(ModelLayers.PLAYER), false); + slimModel = new PlayerModel(models.bakeLayer(ModelLayers.PLAYER_SLIM), true); + capeModel = new PlayerCapeModel<>(models.bakeLayer(ModelLayers.PLAYER_CAPE)); + //#else + //$$ wideModel = new PlayerModel<>(models.bakeLayer(ModelLayers.PLAYER), false); + //$$ slimModel = new PlayerModel<>(models.bakeLayer(ModelLayers.PLAYER_SLIM), true); + //$$ wideModel.young = false; + //$$ slimModel.young = false; + //#endif } @Override @@ -102,14 +117,12 @@ public void renderWidget( //$$ pose(context).translate(0f, 1f + MODEL_OFFSET, 0f); //#endif pose(context).mulPose(YP.rotationDegrees(rotationY)); - flush(context); Lighting.setupForEntityInInventory( //#if MC >= 1.20.6 XP.rotationDegrees(rotationX) //#endif ); - renderModel(context, skin.get()); - flush(context); + drawSpecial(context, bufferSource -> renderModel(context, bufferSource, skin.get())); Lighting.setupFor3DItems(); pose(context).popPose(); } @@ -120,93 +133,81 @@ private void renderModel( //#else GuiGraphics context, //#endif + MultiBufferSource bufferSource, WHPlayerSkin skin ) { pose(context).pushPose(); pose(context).scale(1f, 1f, -1f); pose(context).translate(0f, -1.5f, 0f); - final PlayerModel model = skin.model() == WHPlayerSkin.Model.SLIM ? slimModel : wideModel; + final var model = skin.model() == WHPlayerSkin.Model.SLIM ? slimModel : wideModel; final var renderType = model.renderType(skin.texture()); model.renderToBuffer( - pose(context), bufferSource(context).getBuffer(renderType), LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY + pose(context), bufferSource.getBuffer(renderType), LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY //#if MC < 1.21 //$$ , 1f, 1f, 1f, 1f //#endif ); - if (isDeadmau5.getAsBoolean()) { - renderEars(context, model, skin); - } if (skin.capeTexture() != null) { - renderCape(context, model, skin); + renderCape( + context, bufferSource, + //#if MC < 1.21.2 + //$$ model, + //#endif + skin + ); } pose(context).popPose(); } - private void renderEars( - //#if MC < 1.20.0 - //$$ PoseStack context, - //#else - GuiGraphics context, - //#endif - PlayerModel model, - WHPlayerSkin skin - ) { - final var consumer = bufferSource(context).getBuffer(RenderType.entitySolid(skin.texture())); - for (int ear = 0; ear < 2; ear++) { - pose(context).pushPose(); - pose(context).translate(0.375f * (ear * 2 - 1), -0.375f, 0f); - final float scale = 1 + 1 / 3f; - pose(context).scale(scale, scale, scale); - model.renderEars(pose(context), consumer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); - pose(context).popPose(); - } - } - private void renderCape( //#if MC < 1.20.0 //$$ PoseStack context, //#else GuiGraphics context, //#endif - PlayerModel model, + MultiBufferSource bufferSource, + //#if MC < 1.21.2 + //$$ PlayerModel model, + //#endif WHPlayerSkin skin ) { pose(context).pushPose(); pose(context).translate(0f, 0f, 0.125f); pose(context).mulPose(XP.rotationDegrees(6f)); pose(context).mulPose(YP.rotationDegrees(180f)); - final VertexConsumer consumer = bufferSource(context).getBuffer(RenderType.entitySolid(skin.capeTexture())); - model.renderCloak(pose(context), consumer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); + final VertexConsumer consumer = bufferSource.getBuffer(RenderType.entitySolid(skin.capeTexture())); + //#if MC >= 1.21.2 + capeModel.renderToBuffer(context.pose(), consumer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); + //#else + //$$ model.renderCloak(pose(context), consumer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); + //#endif pose(context).popPose(); } - private static void flush( + private static void drawSpecial( //#if MC < 1.20.0 - //$$ PoseStack context + //$$ PoseStack context, //#else - GuiGraphics context + GuiGraphics context, //#endif + Consumer renderer ) { - //#if MC >= 1.20.0 - context.flush(); + //#if MC >= 1.21.2 + context.drawSpecial(renderer); //#else - //$$ RenderSystem.disableDepthTest(); - //$$ bufferSource(context).endBatch(); - //$$ RenderSystem.enableDepthTest(); - //#endif - } - - private static MultiBufferSource.BufferSource bufferSource( - //#if MC < 1.20.0 - //$$ PoseStack context + //#if MC >= 1.20.0 + //$$ final var bufferSource = context.bufferSource(); //#else - GuiGraphics context + //$$ final var bufferSource = Minecraft.getInstance().renderBuffers().bufferSource(); //#endif - ) { + //$$ renderer.accept(bufferSource); //#if MC >= 1.20.0 - return context.bufferSource(); + //$$ context.flush(); //#else - //$$ return Minecraft.getInstance().renderBuffers().bufferSource(); + //$$ RenderSystem.disableDepthTest(); + //$$ bufferSource.endBatch(); + //$$ RenderSystem.enableDepthTest(); + //#endif //#endif } diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinGameRenderer.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinGameRenderer.java index 34a047f9..6bf739f7 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinGameRenderer.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinGameRenderer.java @@ -1,5 +1,6 @@ package io.github.gaming32.worldhost.mixin; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.renderer.GameRenderer; import org.spongepowered.asm.mixin.Mixin; @@ -22,7 +23,8 @@ @Mixin(GameRenderer.class) public class MixinGameRenderer { //#if MC >= 1.19.4 - @Shadow @Final Minecraft minecraft; + @Shadow @Final + private Minecraft minecraft; //#if MC >= 1.20.0 @Shadow @Final private RenderBuffers renderBuffers; @@ -32,15 +34,22 @@ public class MixinGameRenderer { method = "render", at = @At( value = "INVOKE", - //#if MC >= 1.20.0 - target = "Lnet/minecraft/client/gui/components/toasts/ToastComponent;render(Lnet/minecraft/client/gui/GuiGraphics;)V", + //#if MC >= 1.21.2 + target = "Lnet/minecraft/client/gui/components/toasts/ToastManager;render(Lnet/minecraft/client/gui/GuiGraphics;)V", + //#elseif MC >= 1.20.0 + //$$ target = "Lnet/minecraft/client/gui/components/toasts/ToastComponent;render(Lnet/minecraft/client/gui/GuiGraphics;)V", //#else //$$ target = "Lnet/minecraft/client/gui/components/toasts/ToastComponent;render(Lcom/mojang/blaze3d/vertex/PoseStack;)V", //#endif shift = At.Shift.AFTER ) ) - private void toastRender(CallbackInfo ci) { + private void toastRender( + //#if MC >= 1.21 + DeltaTracker deltaTracker, boolean renderLevel, + //#endif + CallbackInfo ci + ) { int mouseX = (int)( this.minecraft.mouseHandler.xpos() * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth() ); @@ -55,7 +64,7 @@ private void toastRender(CallbackInfo ci) { //#endif mouseX, mouseY, //#if MC >= 1.21 - minecraft.getTimer().getGameTimeDeltaPartialTick(false) + deltaTracker.getGameTimeDeltaPartialTick(false) //#else //$$ minecraft.getFrameTime() //#endif diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml index de810fe6..b5c8008d 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -29,7 +29,9 @@ modId = "minecraft" ##if MC == 1.20.6 #?? versionRange = "[1.20.5,1.20.7)" ##elseif MC == 1.21.1 -versionRange = "[1.21.0,1.21.2)" +#?? versionRange = "[1.21.0,1.21.2)" +##elseif MC == 1.21.3 +versionRange = "[1.21.2,1.21.4)" ##else #?? versionRange = "[$mc_version]" ##endif diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e1f2d16e..5166f31a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -43,7 +43,9 @@ //#elseif MC == 1.20.6 //?? "minecraft": ">=1.20.5- <1.20.7", //#elseif MC == 1.21.1 - "minecraft": ">=1.21.0 <1.21.2", + //?? "minecraft": ">=1.21.0 <1.21.2", + //#elseif MC == 1.21.3 + "minecraft": ">=1.21.2 <1.21.4", //#else //?? "minecraft": "$mc_version", //#endif diff --git a/version.gradle.kts b/version.gradle.kts index 4e61865b..731cfaa2 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -116,6 +116,7 @@ unimined.minecraft { } isNeoForge -> neoForge { loader(when (mcVersion) { + 1_21_03 -> "2-beta" 1_21_01 -> "1" 1_20_06 -> "115" 1_20_04 -> "167" @@ -268,6 +269,7 @@ dependencies { if (isFabric) { when (mcVersion) { + 1_21_03 -> "12.0.0-beta.1" 1_21_01 -> "11.0.1" 1_20_06 -> "10.0.0-beta.1" 1_20_04 -> "9.0.0" @@ -289,6 +291,7 @@ dependencies { if (isFabric) { when (mcVersion) { + 1_21_03 -> "0.106.1+1.21.3" 1_21_01 -> "0.102.0+1.21.1" 1_20_06 -> "0.100.0+1.20.6" 1_20_04 -> "0.97.1+1.20.4" @@ -324,6 +327,7 @@ dependencies { compileOnly("de.maxhenkel.voicechat:voicechat-api:2.5.0") when (mcVersion) { + 1_21_03 -> "2.5.24" 1_21_01 -> "2.5.20" 1_20_06 -> "2.5.20" 1_20_04 -> "2.5.20" @@ -383,6 +387,7 @@ modrinth { 1_20_04 -> "1.20.3" 1_20_06 -> "1.20.5" 1_21_01 -> "1.21" + 1_21_03 -> "1.21.2" else -> null }?.let(gameVersions::add) loaders.add(this@Version_gradle.loaderName) @@ -405,6 +410,7 @@ tasks.processResources { // TODO: Remove pack.mcmeta in 1.20.4 filesMatching("pack.mcmeta") { expand("pack_format" to when { + mcVersion >= 1_21_02 -> 42 mcVersion >= 1_21_00 -> 34 mcVersion >= 1_20_05 -> 32 mcVersion >= 1_20_03 -> 22 diff --git a/versions/mainProject b/versions/mainProject index 3eadd8bb..71a33c87 100644 --- a/versions/mainProject +++ b/versions/mainProject @@ -1 +1 @@ -1.21.1-fabric \ No newline at end of file +1.21.3-fabric \ No newline at end of file From 1b85ad51139c9e05dae30324cab98cf4175acf94 Mon Sep 17 00:00:00 2001 From: Josiah Glosson Date: Thu, 24 Oct 2024 15:35:26 -0500 Subject: [PATCH 3/6] Fix build --- .../gaming32/worldhost/gui/screen/OnlineFriendsScreen.java | 4 ++-- .../github/gaming32/worldhost/mixin/MixinGameRenderer.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java index 4d6905dc..96689f9c 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java @@ -458,9 +458,9 @@ public void render( } //#else //$$ if (relX < 32 && relX > 16) { - //$$ blit(context, GUI_SERVER_SELECTION_LOCATION, x, y, 0.0F, 32.0F, 32, 32, 256, 256); + //$$ blit(context, GUI_SERVER_SELECTION_LOCATION, x, y, 0, 32, 32, 32, 256, 256); //$$ } else { - //$$ blit(context, GUI_SERVER_SELECTION_LOCATION, x, y, 0.0F, 0.0F, 32, 32, 256, 256); + //$$ blit(context, GUI_SERVER_SELECTION_LOCATION, x, y, 0, 0, 32, 32, 256, 256); //$$ } //#endif } diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinGameRenderer.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinGameRenderer.java index 6bf739f7..365116f6 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinGameRenderer.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinGameRenderer.java @@ -1,6 +1,5 @@ package io.github.gaming32.worldhost.mixin; -import net.minecraft.client.DeltaTracker; import net.minecraft.client.renderer.GameRenderer; import org.spongepowered.asm.mixin.Mixin; @@ -20,6 +19,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; //#endif +//#if MC >= 1.21.1 +import net.minecraft.client.DeltaTracker; +//#endif + @Mixin(GameRenderer.class) public class MixinGameRenderer { //#if MC >= 1.19.4 From b873d85e8b6e4d17951388f068ffeb2ae49f7908 Mon Sep 17 00:00:00 2001 From: Josiah Glosson Date: Fri, 25 Oct 2024 01:14:05 -0500 Subject: [PATCH 4/6] Fix some bugs --- .../worldhost/gui/screen/WorldHostScreen.java | 16 ++++++++++++---- .../worldhost/gui/widget/WHPlayerSkinWidget.java | 8 ++++++-- version.gradle.kts | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java index 2a8fc4ec..b43db0e2 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java @@ -150,7 +150,7 @@ public static void blit( //#else GuiGraphics context, //#endif - ResourceLocation texture, int x, int y, int width, int height, int uOffset, int vOffset, int uWidth, int vHeight, int textureWidth, int textureHeight + ResourceLocation texture, int x, int y, int width, int height, float uOffset, float vOffset, int uWidth, int vHeight, int textureWidth, int textureHeight ) { //#if MC >= 1.20.0 context. @@ -167,7 +167,11 @@ public static void blit( //#else texture, //#endif - x, y, width, height, uOffset, vOffset, uWidth, vHeight, textureWidth, textureHeight + //#if MC >= 1.21.2 + x, y, uOffset, vOffset, width, height, uWidth, vHeight, textureWidth, textureHeight + //#else + //$$ x, y, width, height, uOffset, vOffset, uWidth, vHeight, textureWidth, textureHeight + //#endif ); } @@ -178,7 +182,7 @@ public static void blit( //#else GuiGraphics context, //#endif - ResourceLocation texture, int x, int y, int uOffset, int vOffset, int width, int height, int textureWidth, int textureHeight + ResourceLocation texture, int x, int y, float uOffset, float vOffset, int width, int height, int textureWidth, int textureHeight ) { //#if MC >= 1.20.0 context. @@ -195,7 +199,11 @@ public static void blit( //#else texture, //#endif - x, y, uOffset, vOffset, width, height, textureWidth, textureHeight + //#if MC >= 1.21.2 + x, y, uOffset, vOffset, width, height, width, height, textureWidth, textureHeight + //#else + //$$ x, y, uOffset, vOffset, width, height, textureWidth, textureHeight + //#endif ); } diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java index 0fd550a9..2499feb0 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/WHPlayerSkinWidget.java @@ -172,9 +172,13 @@ private void renderCape( WHPlayerSkin skin ) { pose(context).pushPose(); - pose(context).translate(0f, 0f, 0.125f); + //#if MC < 1.21.2 + //$$ pose(context).translate(0f, 0f, 0.125f); + //#endif pose(context).mulPose(XP.rotationDegrees(6f)); - pose(context).mulPose(YP.rotationDegrees(180f)); + //#if MC < 1.21.2 + //$$ pose(context).mulPose(YP.rotationDegrees(180f)); + //#endif final VertexConsumer consumer = bufferSource.getBuffer(RenderType.entitySolid(skin.capeTexture())); //#if MC >= 1.21.2 capeModel.renderToBuffer(context.pose(), consumer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY); diff --git a/version.gradle.kts b/version.gradle.kts index 731cfaa2..4753fa5b 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -103,7 +103,7 @@ unimined.minecraft { when { isFabric -> fabric { - loader("0.15.11") + loader("0.16.7") } isForge -> minecraftForge { loader(when(mcVersion) { From 91140022d36789a39d764102e820249d7a0c65e8 Mon Sep 17 00:00:00 2001 From: Josiah Glosson Date: Fri, 25 Oct 2024 01:24:57 -0500 Subject: [PATCH 5/6] Clean up WorldHostScreen.blit --- .../worldhost/gui/screen/WorldHostScreen.java | 14 ++++++-------- .../gaming32/worldhost/toast/IconRenderer.java | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java index b43db0e2..b1e221b1 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java @@ -150,7 +150,7 @@ public static void blit( //#else GuiGraphics context, //#endif - ResourceLocation texture, int x, int y, int width, int height, float uOffset, float vOffset, int uWidth, int vHeight, int textureWidth, int textureHeight + ResourceLocation texture, int x, int y, float uOffset, float vOffset, int width, int height, int uWidth, int vHeight, int textureWidth, int textureHeight ) { //#if MC >= 1.20.0 context. @@ -167,11 +167,13 @@ public static void blit( //#else texture, //#endif + x, y, //#if MC >= 1.21.2 - x, y, uOffset, vOffset, width, height, uWidth, vHeight, textureWidth, textureHeight + uOffset, vOffset, width, height, //#else - //$$ x, y, width, height, uOffset, vOffset, uWidth, vHeight, textureWidth, textureHeight + //$$ width, height, uOffset, vOffset, //#endif + uWidth, vHeight, textureWidth, textureHeight ); } @@ -199,11 +201,7 @@ public static void blit( //#else texture, //#endif - //#if MC >= 1.21.2 - x, y, uOffset, vOffset, width, height, width, height, textureWidth, textureHeight - //#else - //$$ x, y, uOffset, vOffset, width, height, textureWidth, textureHeight - //#endif + x, y, uOffset, vOffset, width, height, textureWidth, textureHeight ); } diff --git a/src/main/java/io/github/gaming32/worldhost/toast/IconRenderer.java b/src/main/java/io/github/gaming32/worldhost/toast/IconRenderer.java index 0b267eda..5143cd61 100644 --- a/src/main/java/io/github/gaming32/worldhost/toast/IconRenderer.java +++ b/src/main/java/io/github/gaming32/worldhost/toast/IconRenderer.java @@ -26,8 +26,8 @@ void draw( static IconRenderer createSkinIconRenderer(ResourceLocation skinTexture) { return (context, x, y, width, height) -> { RenderSystem.enableBlend(); - WorldHostScreen.blit(context, skinTexture, x, y, width, height, 8, 8, 8, 8, 64, 64); - WorldHostScreen.blit(context, skinTexture, x, y, width, height, 40, 8, 8, 8, 64, 64); + WorldHostScreen.blit(context, skinTexture, x, y, 8, 8, width, height, 8, 8, 64, 64); + WorldHostScreen.blit(context, skinTexture, x, y, 40, 8, width, height, 8, 8, 64, 64); }; } } From 556ed3dcdbef5404182a943774e2bd74814e4529 Mon Sep 17 00:00:00 2001 From: Josiah Glosson Date: Fri, 25 Oct 2024 01:28:01 -0500 Subject: [PATCH 6/6] Remove useless RenderSystem.setShaderColor calls --- .../gaming32/worldhost/gui/screen/FriendsScreen.java | 4 +++- .../worldhost/gui/screen/OnlineFriendsScreen.java | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java index ce6a67e8..13bb45e4 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java @@ -204,7 +204,9 @@ public void render( //#endif int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta ) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + //#if MC < 1.21.2 + //$$ RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + //#endif profile.iconRenderer().draw(context, x, y, 32, 32); RenderSystem.disableBlend(); drawCenteredString(context, minecraft.font, getNameWithTag(), x + 110, y + 16 - minecraft.font.lineHeight / 2, 0xffffff); diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java index 96689f9c..f1554dc7 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java @@ -391,7 +391,9 @@ public void render( final int labelWidth = font.width(sideLabel); WorldHostScreen.drawString(context, font, sideLabel, x + entryWidth - labelWidth - 17, y + 1, 0x808080, false); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + //#if MC < 1.21.2 + //$$ RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + //#endif if (incompatibleVersion) { RenderSystem.enableBlend(); //#if MC >= 1.20.2 @@ -449,7 +451,9 @@ public void render( final boolean touchscreen = minecraft.options.touchscreen().get(); if (joinable && (touchscreen || hovered)) { fill(context, x, y, x + 32, y + 32, 0xa0909090); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + //#if MC < 1.21.2 + //$$ RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + //#endif //#if MC >= 1.20.2 if (relX < 32 && relX > 16) { blitSprite(context, JOIN_HIGHLIGHTED_SPRITE, x, y, 32, 32);