Skip to content

Commit

Permalink
Create ResourceLocations class
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jun 1, 2024
1 parent 43e9855 commit be40e30
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
16 changes: 16 additions & 0 deletions src/main/java/io/github/gaming32/worldhost/ResourceLocations.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/gaming32/worldhost/toast/WHToast.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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)
);
}

Expand Down

0 comments on commit be40e30

Please sign in to comment.