set Favicon
RubenArtz opened this issue · 10 comments
Describe the question
So since the version (Build 616 for 1.19.3) everything works correctly with WrappedServerPing, in the last versions of ProtocolLib for 1.19.4 everything stopped working, I got everything to work except event.setFavicon();
API method(s) used
PacketType.Status.Server.SERVER_INFO
Code
@Override
public void onPacketSending(PacketEvent event) {
if (event.isCancelled()) return;
final WrappedServerPing ping = event.getPacket().getServerPings().read(0);
ping.setFavicon(WrappedServerPing.CompressedImage.fromPng(ProjectUtils.getImage(faviconText.get(random.nextInt(faviconText.size())))));
event.getPacket().getServerPings().write(0, ping);
}
Expected behavior
I can't get ping.setFavicon() to work since the last versions of ProtocolLib for 1.19.4 and I tried with complex methods as well as with simple methods.
In conclusion the .png image is not displayed in 1.19.4 but in 1.19.3 it works.
I was able to reproduce this. Or at least in a similar way. It seems like the server sends a malformed server icons once you modify it using ProtocolLib. I get the following exception in the client log:
[14:54:11] [Render thread/ERROR]: Invalid icon for server Minecraft Server (localhost)
java.io.IOException: Could not load image: Image not of any known type, or corrupt
at egf.a(SourceFile:138) ~[1.19.4.jar:?]
at egf.a(SourceFile:111) ~[1.19.4.jar:?]
at egf.a(SourceFile:119) ~[1.19.4.jar:?]
at ewd$d.a(SourceFile:402) ~[1.19.4.jar:?]
at ewd$d.a(SourceFile:318) ~[1.19.4.jar:?]
at enw.a(SourceFile:463) ~[1.19.4.jar:?]
at enw.b(SourceFile:448) ~[1.19.4.jar:?]
at enw.a(SourceFile:227) ~[1.19.4.jar:?]
at ewa.a(SourceFile:249) ~[1.19.4.jar:?]
at etd.b(SourceFile:121) ~[1.19.4.jar:?]
at fhz.a(SourceFile:937) ~[1.19.4.jar:?]
at emh.f(SourceFile:1218) ~[1.19.4.jar:?]
at emh.e(SourceFile:801) ~[1.19.4.jar:?]
at net.minecraft.client.main.Main.main(SourceFile:237) ~[1.19.4.jar:?]
[14:54:11] [Thread-18/INFO]: OpenGL debug message: id=1282, source=API, type=ERROR, severity=HIGH, message='GL_INVALID_OPERATION error generated. Texture name does not refer to a texture object generated by OpenGL.'
Also, it shows a piglin skin as the server icon instead ¯_(ツ)_/¯
Should be fixed in Build 638: https://ci.dmulloy2.net/job/ProtocolLib/638/
Please give it a try and confirm if this resolves the issue
It still doesn't work, I tried the other versions before 1.19.4 (638) and the favicon works fine but the version (638) didn't solve it.
I have the same problem for WrappedServerPing.setPlayersOnline
and WrappedServerPing.setPlayers
.
After a few tests, I have the impression that 1.19.4 has completely broken WrappedServerPing
.
@crazycat255 You are talking about a different issue. You need to explicitly write back the changed server ping. Like so:
final WrappedServerPing ping = event.getPacket().getServerPings().read(0);
ping.setFavicon(WrappedServerPing.CompressedImage.fromPng(ProjectUtils.getImage(faviconText.get(random.nextInt(faviconText.size())))));
event.getPacket().getServerPings().write(0, ping);
@RubenArtz Sorry for the delayed response. I have seen that you use the CompressedImage.fromPng(...)
method. This method however takes a raw, binary image as an input. If you provide a Base64 encoded string in this method, using the fromPng
method is wrong as it will cause the image to be encoded as bas64 again. So in this case, the image will be converted to base64 twice and will be invalid then.
If you want to provide a base 64 encoded image, please use CompressedImage.fromBase64Png('babse64String')
Hi I tried but it had the same result #2511 I am still waiting for a solution, take your time you do an excellent job.
Hi, the problem mentioned in #2511 has been fixed in #2533, which has not been merged yet. But you can download the build with the fix (just for up to 1.20.1) from https://github.com/lukalt/ProtocolLib/suites/16100238960/artifacts/919148113