Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.asodev.islandutils.modules.plobby.PlobbyJoinCodeCopy;
import net.asodev.islandutils.modules.scavenging.Scavenging;
import net.asodev.islandutils.modules.splits.LevelTimer;
import net.asodev.islandutils.state.MccIslandState;
import net.minecraft.client.gui.font.providers.BitmapProvider;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
Expand Down Expand Up @@ -39,7 +40,9 @@ private void init(ResourceLocation file, int i, int j, int[][] chars, CallbackIn
case "_fonts/tooltips/hat.png" -> CosmeticState.HAT_COMP = comp;
case "_fonts/tooltips/accessory.png" -> CosmeticState.ACCESSORY_COMP = comp;
case "_fonts/tooltips/hair.png" -> CosmeticState.HAIR_COMP = comp;
case "_fonts/medals.png" -> LevelTimer.medalCharacter = character;
case "_fonts/medals.png" -> {
if (MccIslandState.isOnline() && LevelTimer.medalCharacter.isEmpty()) LevelTimer.medalCharacter = character;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is certainly a solution, but it is also an edge case
i'm gonna take a look at it and see if there's a bit of a better, more concrete solution that won't make this susceptible to happening again with a different character.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to have a similar implementation and extract the real characters without a dummy resource pack, which should negate the need for any changes on your end. I coded this as a quick fix since I can't release an update for some time. The medal is the only character I'm using that conflicts with IslandUtils.

On second thought, however, I think my pack loaded after because of alphabetical order, so other mods might potentially still cause similar conflicts. I tried to find a way to check the origin resource pack of the glyph but I got nowhere.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I did something that can fix this issue a while ago, and I completely forgot about it:

https://github.com/anastarawneh/MCCINametagMod/blob/e220774376f366bd981f023927827676c104ba78/src/main/java/me/anastarawneh/mccinametagmod/util/Util.java

You can read the actual font/icon.json file and parse it manually. The chances that another mod is also using the same mcc:fonts/icon.json identifier is incredibly low, so there should be no overlap.

Regardless, I fixed the issue on my end, and I will upload an updated version soon.

}
case "_fonts/split_up.png" -> LevelTimer.splitUpComponent = comp;
case "_fonts/split_down.png" -> LevelTimer.splitDownComponent = comp;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.asodev.islandutils.mixins.resources;

import com.mojang.blaze3d.font.GlyphProvider;
import net.minecraft.client.gui.font.FontManager;
import net.minecraft.client.gui.font.providers.GlyphProviderDefinition;
import net.minecraft.server.packs.resources.ResourceManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

@Mixin(FontManager.class)
public class FontManagerMixin {
@Inject(method = "safeLoad", at = @At("HEAD"), cancellable = true)
public void load(FontManager.BuilderId builderId, GlyphProviderDefinition.Loader loader, ResourceManager resourceManager, Executor executor, CallbackInfoReturnable<CompletableFuture<Optional<GlyphProvider>>> cir) {
if (builderId.pack().equals("islandutils")) {
cir.setReturnValue(CompletableFuture.supplyAsync(() -> {
try {
return Optional.of(loader.load(resourceManager));
} catch (Exception exception) {
return Optional.empty();
}
}, executor));
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/islandutils.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ accessWidener v1 named
#accessible method net/minecraft/server/packs/FilePackResources <init> (Ljava/lang/String;Lnet/minecraft/server/packs/FilePackResources$SharedZipFileAccess;ZLjava/lang/String;)V
#accessible method net/minecraft/server/packs/FilePackResources$SharedZipFileAccess <init> (Ljava/io/File;)V
#accessible method net/minecraft/util/HttpUtil downloadAndHash (Lcom/google/common/hash/HashFunction;ILnet/minecraft/util/HttpUtil$DownloadProgressListener;Ljava/io/InputStream;Ljava/nio/file/Path;)Lcom/google/common/hash/HashCode;
#accessible method net/minecraft/client/resources/server/DownloadedPackSource createDownloadNotifier (I)Lnet/minecraft/util/HttpUtil$DownloadProgressListener;
#accessible method net/minecraft/client/resources/server/DownloadedPackSource createDownloadNotifier (I)Lnet/minecraft/util/HttpUtil$DownloadProgressListener;
accessible class net/minecraft/client/gui/font/FontManager$BuilderId
1 change: 1 addition & 0 deletions src/main/resources/islandutils.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"network.PacketListenerMixin",
"notif.ServerSelectionMixin",
"plobby.PlobbyChestMixin",
"resources.FontManagerMixin",
"resources.MultiplayerJoinMixin",
"sounds.SoundOptionsMixin",
"splits.HologramMixin",
Expand Down