TeamsPacket
This commit is contained in:
@@ -13,10 +13,7 @@ import mc.protocol.packets.client.LoginStartPacket;
|
||||
import mc.protocol.packets.client.StatusServerRequestPacket;
|
||||
import mc.protocol.packets.server.*;
|
||||
import mc.protocol.serializer.TextSerializer;
|
||||
import mc.protocol.utils.Difficulty;
|
||||
import mc.protocol.utils.GameMode;
|
||||
import mc.protocol.utils.LevelType;
|
||||
import mc.protocol.utils.ScoreboardPosition;
|
||||
import mc.protocol.utils.*;
|
||||
import mc.server.config.Config;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
@@ -69,15 +66,19 @@ public class PacketHandler {
|
||||
}
|
||||
|
||||
public void onLoginStart(ConnectionContext context, LoginStartPacket loginStartPacket) {
|
||||
UUID playerUuid = UUID.randomUUID();
|
||||
int playerEid = random.nextInt();
|
||||
String playerName = loginStartPacket.getName();
|
||||
|
||||
var loginSuccessPacket = new LoginSuccessPacket();
|
||||
loginSuccessPacket.setUuid(UUID.randomUUID());
|
||||
loginSuccessPacket.setName(loginStartPacket.getName());
|
||||
loginSuccessPacket.setUuid(playerUuid);
|
||||
loginSuccessPacket.setName(playerName);
|
||||
|
||||
context.sendNow(loginSuccessPacket);
|
||||
context.setState(State.PLAY);
|
||||
|
||||
var joinGamePacket = new JoinGamePacket();
|
||||
joinGamePacket.setEntityId(random.nextInt());
|
||||
joinGamePacket.setEntityId(playerEid);
|
||||
joinGamePacket.setGameMode(GameMode.SPECTATOR);
|
||||
joinGamePacket.setDimension(0/*Overworld*/);
|
||||
joinGamePacket.setDifficulty(Difficulty.PEACEFUL);
|
||||
@@ -126,11 +127,24 @@ public class PacketHandler {
|
||||
|
||||
// --- Эксперименты --- //
|
||||
|
||||
TeamsPacket teamsPacket = new TeamsPacket();
|
||||
teamsPacket.setName("Score::List");
|
||||
teamsPacket.setMode(TeamsMode.CREATE);
|
||||
teamsPacket.setDisplayName(teamsPacket.getName());
|
||||
teamsPacket.setNameTagVisibility(TeamsNameTagVisibility.NEVER);
|
||||
teamsPacket.setCollisionRule(TeamsCollisionRule.NEVER);
|
||||
teamsPacket.setColor(-1/*no color*/);
|
||||
teamsPacket.getMembers().add(playerName);
|
||||
|
||||
context.send(teamsPacket);
|
||||
|
||||
ScoreboardDisplayPacket scoreboardDisplayPacket = new ScoreboardDisplayPacket();
|
||||
scoreboardDisplayPacket.setPosition(ScoreboardPosition.LIST);
|
||||
scoreboardDisplayPacket.setName("Score::List");
|
||||
scoreboardDisplayPacket.setName(teamsPacket.getName());
|
||||
|
||||
context.sendNow(scoreboardDisplayPacket);
|
||||
context.send(scoreboardDisplayPacket);
|
||||
|
||||
context.flushSending();
|
||||
}
|
||||
|
||||
private static String faviconToBase64(Path iconPath) {
|
||||
|
||||
Reference in New Issue
Block a user