diff --git a/src/main/java/io/github/gaming32/worldhost/ResourceLocations.java b/src/main/java/io/github/gaming32/worldhost/ResourceLocations.java new file mode 100644 index 0000000..79b41a5 --- /dev/null +++ b/src/main/java/io/github/gaming32/worldhost/ResourceLocations.java @@ -0,0 +1,16 @@ +package io.github.gaming32.worldhost; + +import net.minecraft.resources.ResourceLocation; + +public final class ResourceLocations { + private ResourceLocations() { + } + + public static ResourceLocation minecraft(String path) { + return new ResourceLocation(ResourceLocation.DEFAULT_NAMESPACE, path); + } + + public static ResourceLocation worldHost(String path) { + return new ResourceLocation("world-host", path); + } +} 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 6eab2dc..792a1d8 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 @@ -4,6 +4,7 @@ import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; import io.github.gaming32.worldhost.FriendsListUpdate; +import io.github.gaming32.worldhost.ResourceLocations; import io.github.gaming32.worldhost.WorldHost; import io.github.gaming32.worldhost.WorldHostComponents; import io.github.gaming32.worldhost.gui.widget.FriendsButton; @@ -56,12 +57,12 @@ //#endif public class OnlineFriendsScreen extends WorldHostScreen implements FriendsListUpdate { - private static final ResourceLocation GUI_ICONS_LOCATION = new ResourceLocation("textures/gui/icons.png"); + private static final ResourceLocation GUI_ICONS_LOCATION = ResourceLocations.minecraft("textures/gui/icons.png"); //#if MC >= 1.20.2 - private static final ResourceLocation JOIN_HIGHLIGHTED_SPRITE = new ResourceLocation("server_list/join_highlighted"); - private static final ResourceLocation JOIN_SPRITE = new ResourceLocation("server_list/join"); + private static final ResourceLocation JOIN_HIGHLIGHTED_SPRITE = ResourceLocations.minecraft("server_list/join_highlighted"); + private static final ResourceLocation JOIN_SPRITE = ResourceLocations.minecraft("server_list/join"); //#else - //$$ private static final ResourceLocation GUI_SERVER_SELECTION_LOCATION = new ResourceLocation("textures/gui/server_selection.png"); + //$$ private static final ResourceLocation GUI_SERVER_SELECTION_LOCATION = ResourceLocations.minecraft("textures/gui/server_selection.png"); //#endif private final Screen parent; @@ -321,7 +322,7 @@ public OnlineFriendsListEntry(UUID friendUuid, long connectionId) { Util.backgroundExecutor().execute( () -> profile = WorldHost.fetchProfile(minecraft.getMinecraftSessionService(), profile) ); - iconTextureId = new ResourceLocation("world-host", "servers/" + friendUuid + "/icon"); + iconTextureId = ResourceLocations.worldHost("servers/" + friendUuid + "/icon"); } @NotNull 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 d4f935f..30f5e4c 100644 --- a/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java +++ b/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java @@ -1,13 +1,13 @@ package io.github.gaming32.worldhost.toast; import com.mojang.blaze3d.vertex.PoseStack; +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; -import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import org.jetbrains.annotations.NotNull; @@ -159,7 +159,7 @@ private static SoundEvent newSoundEvent(String location) { //#else //$$ return new SoundEvent( //#endif - new ResourceLocation("world-host:toast/" + location) + ResourceLocations.worldHost("toast/" + location) ); }