Skip to content

Commit

Permalink
🐛 support 1.21.4-fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
kitUIN committed Dec 13, 2024
1 parent af04015 commit e35b1d4
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@

public class ChatImageClientAdapter implements IClientAdapter {
// IF >= fabric-1.21.4
private final Map<String, Integer> dynamicIdCounters = Maps.newHashMap();
public Identifier registerDynamicTexture(String prefix, NativeImageBackedTexture texture) {
Integer integer = (Integer)this.dynamicIdCounters.get(prefix);
if (integer == null) {
integer = 1;
} else {
integer = integer + 1;
}

this.dynamicIdCounters.put(prefix, integer);
Identifier identifier = Identifier.ofVanilla(String.format(Locale.ROOT, "dynamic/%s_%d", prefix, integer));
MinecraftClient.getInstance().getTextureManager().registerTexture(identifier, texture);
return identifier;
}
// private final Map<String, Integer> dynamicIdCounters = Maps.newHashMap();
// public Identifier registerDynamicTexture(String prefix, NativeImageBackedTexture texture) {
// Integer integer = (Integer)this.dynamicIdCounters.get(prefix);
// if (integer == null) {
// integer = 1;
// } else {
// integer = integer + 1;
// }
//
// this.dynamicIdCounters.put(prefix, integer);
// Identifier identifier = Identifier.ofVanilla(String.format(Locale.ROOT, "dynamic/%s_%d", prefix, integer));
// MinecraftClient.getInstance().getTextureManager().registerTexture(identifier, texture);
// return identifier;
// }
// END IF

@Override
Expand All @@ -52,9 +52,9 @@ public ChatImageFrame.TextureReader<Identifier> loadTexture(InputStream image) t
NativeImage nativeImage = NativeImage.read(image);
return new ChatImageFrame.TextureReader<>(
// IF >= fabric-1.21.4
registerDynamicTexture(
// registerDynamicTexture(
// ELSE
//// MinecraftClient.getInstance().getTextureManager().registerDynamicTexture(
// MinecraftClient.getInstance().getTextureManager().registerDynamicTexture(
// END IF
MOD_ID + "/chatimage",
new NativeImageBackedTexture(nativeImage)),
Expand Down

0 comments on commit e35b1d4

Please sign in to comment.