3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

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.
Dieser Commit ist enthalten in:
RednedEpic 2019-11-15 21:25:43 -06:00
Ursprung 3c1a274f64
Commit 3e8ab6ca83
2 geänderte Dateien mit 17 neuen und 6 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -13,6 +13,7 @@ import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import java.util.Base64; import java.util.Base64;
import java.util.Collections;
import java.util.UUID; import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -48,7 +49,16 @@ public class SkinUtils {
public static PlayerListPacket.Entry buildEntryManually(UUID uuid, String username, long geyserId, public static PlayerListPacket.Entry buildEntryManually(UUID uuid, String username, long geyserId,
String skinId, byte[] skinData, byte[] capeData, String skinId, byte[] skinData, byte[] capeData,
String geometryName, String geometryData) { 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); PlayerListPacket.Entry entry = new PlayerListPacket.Entry(uuid);
entry.setName(username); entry.setName(username);