|
6 | 6 | import org.cloudburstmc.math.vector.Vector3i;
|
7 | 7 | import org.cloudburstmc.nbt.NbtMap;
|
8 | 8 | 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.*; |
11 | 11 | import org.cloudburstmc.protocol.common.PacketSignal;
|
12 | 12 | import org.cloudburstmc.protocol.common.util.OptionalBoolean;
|
13 | 13 | import org.sculk.Player;
|
@@ -42,51 +42,100 @@ public PreSpawnPacketHandler(SculkServerSession session, Player player) {
|
42 | 42 | @Override
|
43 | 43 | public void setUp() {
|
44 | 44 | 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 | + |
50 | 51 | startGamePacket.setSeed(-1L);
|
51 | 52 | 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); |
56 | 57 | startGamePacket.setAchievementsDisabled(true);
|
57 |
| - startGamePacket.setDayCycleStopTime(0); |
| 58 | + startGamePacket.setCurrentTick(-1); |
| 59 | + startGamePacket.setEduEditionOffers(0); |
| 60 | + startGamePacket.setEduFeaturesEnabled(false); |
58 | 61 | startGamePacket.setRainLevel(0);
|
59 | 62 | startGamePacket.setLightningLevel(0);
|
60 |
| - startGamePacket.setCommandsEnabled(true); |
61 | 63 | startGamePacket.setMultiplayerGame(true);
|
62 | 64 | 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); |
69 | 65 | 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); |
70 | 72 | startGamePacket.setDefaultPlayerPermission(PlayerPermission.MEMBER);
|
71 | 73 | 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); |
84 | 80 | startGamePacket.setSpawnBiomeType(SpawnBiomeType.DEFAULT);
|
85 | 81 | startGamePacket.setCustomBiomeName("");
|
86 | 82 | startGamePacket.setEducationProductionId("");
|
87 | 83 | startGamePacket.setForceExperimentalGameplay(OptionalBoolean.empty());
|
88 | 84 |
|
| 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 | + |
89 | 127 | 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); |
90 | 139 | }
|
91 | 140 |
|
92 | 141 | @Override
|
|
0 commit comments