Fix players not showing up

Skins still need some work as it applies to every player online rather than a specific player; however, players are now visible regardless.
This commit is contained in:
RednedEpic 2019-11-15 21:25:43 -06:00
parent 3c1a274f64
commit 3e8ab6ca83
2 changed files with 17 additions and 6 deletions

View file

@ -3,6 +3,7 @@ package org.geysermc.connector.utils;
import lombok.Getter;
import javax.imageio.ImageIO;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -18,11 +19,11 @@ public class ProvidedSkin {
try {
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
int rgba = image.getRGB(x, y);
outputStream.write((rgba >> 16) & 0xFF);
outputStream.write((rgba >> 8) & 0xFF);
outputStream.write(rgba & 0xFF);
outputStream.write((rgba >> 24) & 0xFF);
Color color = new Color(image.getRGB(x, y), true);
outputStream.write(color.getRed());
outputStream.write(color.getGreen());
outputStream.write(color.getBlue());
outputStream.write(color.getAlpha());
}
}
image.flush();

View file

@ -13,6 +13,7 @@ import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.network.session.GeyserSession;
import java.util.Base64;
import java.util.Collections;
import java.util.UUID;
import java.util.function.Consumer;
@ -48,7 +49,16 @@ public class SkinUtils {
public static PlayerListPacket.Entry buildEntryManually(UUID uuid, String username, long geyserId,
String skinId, byte[] skinData, byte[] capeData,
String geometryName, String geometryData) {
SerializedSkin serializedSkin = SerializedSkin.of(skinId, ImageData.of(64, 64, skinData), ImageData.of(64, 32, capeData), geometryName, geometryData, true);
if (skinData == null || skinData.length == 0) {
skinData = SkinProvider.EMPTY_SKIN.getSkinData();
}
if (capeData == null || capeData.length == 0) {
capeData = SkinProvider.EMPTY_CAPE.getCapeData();
}
SerializedSkin serializedSkin = SerializedSkin.of(skinId, geometryName, ImageData.of(64, 64, skinData),
Collections.emptyList(), ImageData.of(64, 32, capeData), geometryData, "", true, false, false, "", "");
PlayerListPacket.Entry entry = new PlayerListPacket.Entry(uuid);
entry.setName(username);