Skip to content

Commit d6aca04

Browse files
committed
login Success
1 parent 8e60043 commit d6aca04

File tree

5 files changed

+102
-68
lines changed

5 files changed

+102
-68
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,24 @@ dependencies {
4848
}
4949
```
5050

51-
| Milestone | Status |
52-
|--------------------------------------------|--------|
53-
| **⚒️ Construction of the server tree** ||
54-
| **👓 Visible server** ||
55-
| **🛜 Join server** | |
56-
| **🎍 World loader** | 🚧 |
57-
| **🔌Plugin loader** ||
58-
| **⌨️ Command System** | 🚧 |
59-
| **🔐 Permission System** | 🚧 |
60-
| **🎈 Event System** ||
61-
| **🖼 Scoreboard API** | 🚧 |
62-
| **🖼 Form API** ||
63-
| **👤 Player & Actor API** ||
64-
| **🔩 Item API** | 🚧 |
65-
| **🧱 Block API** | 🚧 |
66-
| **📦 Inventory API** | 🚧 |
67-
| **🔬 Beta Testing & Community Feedback** | 🚧 |
68-
| **🚀 Official Release & Support** | 🚧 |
51+
| Milestone | Status |
52+
|------------------------------------------|--------|
53+
| **⚒️ Construction of the server tree** | |
54+
| **👓 Visible server** | |
55+
| **🛜 Join server** | |
56+
| **🎍 World loader** | 🚧 |
57+
| **🔌Plugin loader** | |
58+
| **⌨️ Command System** | 🚧 |
59+
| **🔐 Permission System** | 🚧 |
60+
| **🎈 Event System** | |
61+
| **🖼 Scoreboard API** | 🚧 |
62+
| **🖼 Form API** | |
63+
| **👤 Player & Actor API** | |
64+
| **🔩 Item API** | 🚧 |
65+
| **🧱 Block API** | 🚧 |
66+
| **📦 Inventory API** | 🚧 |
67+
| **🔬 Beta Testing & Community Feedback** | 🚧 |
68+
| **🚀 Official Release & Support** | 🚧 |
6969

7070
Here's a legend to guide you:
7171
- ✅: Task is completed. Woohoo! 🎉

src/main/java/org/sculk/network/handler/LoginPacketHandler.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44
import org.cloudburstmc.protocol.bedrock.packet.*;
55
import org.cloudburstmc.protocol.common.PacketSignal;
66
import org.cloudburstmc.protocol.common.util.QuadConsumer;
7-
import org.jose4j.jws.JsonWebSignature;
8-
import org.sculk.Player;
97
import org.sculk.Server;
108
import org.sculk.event.player.PlayerAsyncPreLoginEvent;
119
import org.sculk.event.player.PlayerPreLoginEvent;
12-
import org.sculk.network.BedrockInterface;
1310
import org.sculk.network.session.SculkServerSession;
1411
import org.sculk.player.PlayerLoginData;
1512
import org.sculk.player.client.ClientChainData;
1613
import org.sculk.scheduler.AsyncTask;
1714

18-
import java.util.List;
1915
import java.util.function.Consumer;
2016
import java.util.regex.Matcher;
2117
import java.util.regex.Pattern;
@@ -98,9 +94,6 @@ public void onCompletion(Server server) {
9894
} else if(loginData.isShouldLogin()) {
9995
Exception error = null;
10096
try {
101-
PlayStatusPacket statusPacket = new PlayStatusPacket();
102-
statusPacket.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
103-
session.sendPacket(statusPacket);
10497
for(Consumer<SculkServerSession> action : playerAsyncPreLoginEvent.getScheduledActions()) {
10598
action.accept(LoginPacketHandler.this.session);
10699
}

src/main/java/org/sculk/network/handler/PreSpawnPacketHandler.java

Lines changed: 80 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import org.cloudburstmc.math.vector.Vector3i;
77
import org.cloudburstmc.nbt.NbtMap;
88
import org.cloudburstmc.protocol.bedrock.data.*;
9-
import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
10-
import org.cloudburstmc.protocol.bedrock.packet.StartGamePacket;
9+
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
10+
import org.cloudburstmc.protocol.bedrock.packet.*;
1111
import org.cloudburstmc.protocol.common.PacketSignal;
1212
import org.cloudburstmc.protocol.common.util.OptionalBoolean;
1313
import org.sculk.Player;
@@ -42,51 +42,100 @@ public PreSpawnPacketHandler(SculkServerSession session, Player player) {
4242
@Override
4343
public void setUp() {
4444
StartGamePacket startGamePacket = new StartGamePacket();
45-
startGamePacket.setUniqueEntityId(this.player.getUniqueId());
46-
startGamePacket.setRuntimeEntityId(this.player.getRuntimeId());
47-
startGamePacket.setPlayerGameType(GameType.CREATIVE);
48-
startGamePacket.setPlayerPosition(Vector3f.from(0, 0, 0));
49-
startGamePacket.setRotation(Vector2f.from(0, 0));
45+
startGamePacket.setUniqueEntityId(0);
46+
startGamePacket.setRuntimeEntityId(0);
47+
startGamePacket.setPlayerGameType(GameType.DEFAULT);
48+
startGamePacket.setPlayerPosition(Vector3f.from(0, 69, 0));
49+
startGamePacket.setRotation(Vector2f.from(1, 1));
50+
5051
startGamePacket.setSeed(-1L);
5152
startGamePacket.setDimensionId(0);
52-
startGamePacket.setTrustingPlayers(false);
53-
startGamePacket.setLevelGameType(GameType.CREATIVE);
54-
startGamePacket.setDifficulty(0);
55-
startGamePacket.setDefaultSpawn(Vector3i.from(0, 0, 0));
53+
startGamePacket.setGeneratorId(1);
54+
startGamePacket.setLevelGameType(GameType.SURVIVAL);
55+
startGamePacket.setDifficulty(1);
56+
startGamePacket.setDefaultSpawn(Vector3i.ZERO);
5657
startGamePacket.setAchievementsDisabled(true);
57-
startGamePacket.setDayCycleStopTime(0);
58+
startGamePacket.setCurrentTick(-1);
59+
startGamePacket.setEduEditionOffers(0);
60+
startGamePacket.setEduFeaturesEnabled(false);
5861
startGamePacket.setRainLevel(0);
5962
startGamePacket.setLightningLevel(0);
60-
startGamePacket.setCommandsEnabled(true);
6163
startGamePacket.setMultiplayerGame(true);
6264
startGamePacket.setBroadcastingToLan(true);
63-
//NetworkUtils.gameRulesToNetwork(this.getLevel().getGameRules(), startGamePacket.getGamerules());
64-
startGamePacket.setLevelId(""); // This is irrelevant since we have multiple levels
65-
startGamePacket.setLevelName("world"); // We might as well use the MOTD instead of the default level name
66-
startGamePacket.setGeneratorId(1); // 0 old, 1 infinite, 2 flat - Has no effect to my knowledge
67-
startGamePacket.setItemDefinitions(List.of());
68-
startGamePacket.setXblBroadcastMode(GamePublishSetting.PUBLIC);
6965
startGamePacket.setPlatformBroadcastMode(GamePublishSetting.PUBLIC);
66+
startGamePacket.setXblBroadcastMode(GamePublishSetting.PUBLIC);
67+
startGamePacket.setCommandsEnabled(true);
68+
startGamePacket.setTexturePacksRequired(false);
69+
startGamePacket.setBonusChestEnabled(false);
70+
startGamePacket.setStartingWithMap(false);
71+
startGamePacket.setTrustingPlayers(true);
7072
startGamePacket.setDefaultPlayerPermission(PlayerPermission.MEMBER);
7173
startGamePacket.setServerChunkTickRange(4);
72-
startGamePacket.setVanillaVersion("1.21.2"); // Temporary hack that allows player to join by disabling the new chunk columns introduced in update 1.18
73-
startGamePacket.setPremiumWorldTemplateId("");
74-
startGamePacket.setMultiplayerCorrelationId("");
75-
startGamePacket.setInventoriesServerAuthoritative(true);
76-
startGamePacket.setRewindHistorySize(0);
77-
startGamePacket.setServerAuthoritativeBlockBreaking(false);
78-
startGamePacket.setAuthoritativeMovementMode(AuthoritativeMovementMode.CLIENT);
79-
startGamePacket.setServerEngine("Sculk");
80-
startGamePacket.setPlayerPropertyData(NbtMap.EMPTY);
81-
startGamePacket.setWorldTemplateId(new UUID(0, 0));
82-
startGamePacket.setWorldEditor(false);
83-
startGamePacket.setChatRestrictionLevel(ChatRestrictionLevel.NONE);
74+
startGamePacket.setBehaviorPackLocked(false);
75+
startGamePacket.setResourcePackLocked(false);
76+
startGamePacket.setFromLockedWorldTemplate(false);
77+
startGamePacket.setUsingMsaGamertagsOnly(false);
78+
startGamePacket.setFromWorldTemplate(false);
79+
startGamePacket.setWorldTemplateOptionLocked(false);
8480
startGamePacket.setSpawnBiomeType(SpawnBiomeType.DEFAULT);
8581
startGamePacket.setCustomBiomeName("");
8682
startGamePacket.setEducationProductionId("");
8783
startGamePacket.setForceExperimentalGameplay(OptionalBoolean.empty());
8884

85+
String serverName = session.getServer().getMotd();
86+
startGamePacket.setLevelId(serverName);
87+
startGamePacket.setLevelName(serverName);
88+
89+
startGamePacket.setPremiumWorldTemplateId("00000000-0000-0000-0000-000000000000");
90+
// startGamePacket.setCurrentTick(0);
91+
startGamePacket.setEnchantmentSeed(0);
92+
startGamePacket.setMultiplayerCorrelationId("");
93+
94+
startGamePacket.getItemDefinitions().addAll(List.of());
95+
96+
// Needed for custom block mappings and custom skulls system
97+
startGamePacket.getBlockProperties().addAll(List.of());
98+
99+
/* THANK GEYSER
100+
// See https://learn.microsoft.com/en-us/minecraft/creator/documents/experimentalfeaturestoggle for info on each experiment
101+
// data_driven_items (Holiday Creator Features) is needed for blocks and items
102+
startGamePacket.getExperiments().add(new ExperimentData("data_driven_items", true));
103+
// Needed for block properties for states
104+
startGamePacket.getExperiments().add(new ExperimentData("upcoming_creator_features", true));
105+
// Needed for certain molang queries used in blocks and items
106+
startGamePacket.getExperiments().add(new ExperimentData("experimental_molang_features", true));
107+
// Required for experimental 1.21 features
108+
startGamePacket.getExperiments().add(new ExperimentData("updateAnnouncedLive2023", true));*/
109+
110+
startGamePacket.setVanillaVersion("*");
111+
startGamePacket.setInventoriesServerAuthoritative(true);
112+
startGamePacket.setServerEngine(""); // Do we want to fill this in?
113+
114+
startGamePacket.setPlayerPropertyData(NbtMap.EMPTY);
115+
startGamePacket.setWorldTemplateId(UUID.randomUUID());
116+
117+
startGamePacket.setChatRestrictionLevel(ChatRestrictionLevel.NONE);
118+
119+
startGamePacket.setAuthoritativeMovementMode(AuthoritativeMovementMode.SERVER);
120+
startGamePacket.setRewindHistorySize(0);
121+
startGamePacket.setServerAuthoritativeBlockBreaking(false);
122+
123+
startGamePacket.setServerId("");
124+
startGamePacket.setWorldId("");
125+
startGamePacket.setScenarioId("");
126+
89127
session.sendPacket(startGamePacket);
128+
session.sendPacket(new CreativeContentPacket());
129+
session.sendPacket(new BiomeDefinitionListPacket());
130+
session.sendPacket(new AvailableEntityIdentifiersPacket());
131+
SetEntityDataPacket setEntityDataPacket = new SetEntityDataPacket();
132+
setEntityDataPacket.setRuntimeEntityId(0);
133+
setEntityDataPacket.getMetadata().put(EntityDataTypes.PLAYER_FLAGS, (byte) 2);
134+
session.sendPacket(setEntityDataPacket);
135+
136+
SetTimePacket setTimePacket = new SetTimePacket();
137+
setTimePacket.setTime(0);
138+
session.sendPacket(setTimePacket);
90139
}
91140

92141
@Override

src/main/java/org/sculk/network/handler/ResourcePackHandler.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
import org.cloudburstmc.protocol.bedrock.packet.ResourcePackStackPacket;
55
import org.cloudburstmc.protocol.bedrock.packet.ResourcePacksInfoPacket;
66
import org.cloudburstmc.protocol.common.PacketSignal;
7-
import org.sculk.Player;
87
import org.sculk.network.session.SculkServerSession;
98

109
import java.util.ArrayList;
11-
import java.util.Collections;
12-
import java.util.List;
1310
import java.util.function.Consumer;
1411

1512
/*
@@ -42,8 +39,6 @@ public void setUp() {
4239
}
4340

4441

45-
46-
4742
public PacketSignal handle(ResourcePackClientResponsePacket packet) {
4843
switch (packet.getStatus()) {
4944
case REFUSED -> {

src/main/java/org/sculk/network/session/SculkServerSession.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
import org.cloudburstmc.protocol.bedrock.BedrockServerSession;
99
import org.cloudburstmc.protocol.bedrock.packet.BedrockPacketHandler;
1010
import org.cloudburstmc.protocol.bedrock.packet.PlayStatusPacket;
11-
import org.cloudburstmc.protocol.common.util.QuadConsumer;
1211
import org.sculk.Player;
1312
import org.sculk.Server;
1413
import org.sculk.network.BedrockInterface;
1514
import org.sculk.network.handler.*;
1615
import org.sculk.player.client.ClientChainData;
1716

1817
import javax.annotation.Nullable;
19-
import java.util.concurrent.Future;
20-
import java.util.concurrent.FutureTask;
18+
import java.util.Objects;
2119

2220
/*
2321
* ____ _ _
@@ -67,7 +65,7 @@ private void onSessionStartSuccess(Object e) {
6765

6866
private void setAuthenticationStatus(boolean authenticated, boolean authRequired, Exception error, String clientPubKey) {
6967
if(error == null){
70-
if(authenticated && playerInfo.getXUID() == null){
68+
if(authenticated && Objects.requireNonNull(playerInfo).getXUID() == null){
7169
error = new Exception("Expected XUID but none found");
7270
}else if(clientPubKey == null){
7371
error = new Exception("Missing client public key"); //failsafe
@@ -96,6 +94,7 @@ private void onServerLoginSuccess() {
9694

9795
private void createPlayer(Object e) {
9896
this.server.createPlayer(this, this.playerInfo, false).thenAccept(this::onPlayerCreated).exceptionally(ex -> {
97+
server.getLogger().throwing(ex);
9998
this.disconnect("Failed to create player.");
10099
return null;
101100
});
@@ -112,19 +111,17 @@ private void notifyTerrainReady(Object e) {
112111
PlayStatusPacket packet = new PlayStatusPacket();
113112
packet.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
114113
this.sendPacket(packet);
115-
System.out.println(packet);
116114
this.setPacketHandler(new SpawnResponsePacketHandler(this, this::onClientSpawnResponse));
117115
}
118116

119117
private void onClientSpawnResponse(Object e) {
120-
System.out.println("vvvvvvvvvvvvvvvv");
121118
this.setPacketHandler(new InGamePacketHandler(this.getPlayer(),this));
122119
}
123120

124121
@Override
125122
public void setPacketHandler(@NonNull BedrockPacketHandler packetHandler) {
123+
super.setPacketHandler(packetHandler);
126124
if (packetHandler instanceof SculkPacketHandler _sculkHandler)
127125
_sculkHandler.setUp();
128-
super.setPacketHandler(packetHandler);
129126
}
130127
}

0 commit comments

Comments
 (0)