Attempt to fix crashes on login

This commit is contained in:
RednedEpic 2019-11-10 16:53:01 -06:00 committed by RednedEpic
parent 21ddf8af1e
commit 3ffaf5c0e5
7 changed files with 70 additions and 11 deletions

View file

@ -716,4 +716,49 @@ public class LoggingPacketHandler implements BedrockPacketHandler {
public boolean handle(VideoStreamConnectPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(EmotePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(TickSyncPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AnvilDamagePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(NetworkSettingsPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(PlayerAuthInputPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SettingsCommandPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(EducationSettingsPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(CompletedUsingItemPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(MultiplayerSettingsPacket packet) {
return defaultHandler(packet);
}
}

View file

@ -43,7 +43,10 @@ import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.protocol.bedrock.BedrockServerSession;
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
import com.nukkitx.protocol.bedrock.data.GameRule;
import com.nukkitx.protocol.bedrock.packet.AvailableEntityIdentifiersPacket;
import com.nukkitx.protocol.bedrock.packet.BiomeDefinitionListPacket;
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
import com.nukkitx.protocol.bedrock.packet.NetworkChunkPublisherUpdatePacket;
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
import com.nukkitx.protocol.bedrock.packet.TextPacket;
@ -131,8 +134,13 @@ public class GeyserSession implements Player {
Vector3f pos = Vector3f.ZERO;
int chunkX = pos.getFloorX() >> 4;
int chunkZ = pos.getFloorZ() >> 4;
for (int x = -3; x < 3; x++) {
for (int z = -3; z < 3; z++) {
for (int x = -5; x < 5; x++) {
for (int z = -5; z < 5; z++) {
NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket();
chunkPublisherUpdatePacket.setPosition(pos.toInt());
chunkPublisherUpdatePacket.setRadius(renderDistance << 4);
upstream.sendPacket(chunkPublisherUpdatePacket);
LevelChunkPacket data = new LevelChunkPacket();
data.setChunkX(chunkX + x);
data.setChunkZ(chunkZ + z);
@ -142,6 +150,9 @@ public class GeyserSession implements Player {
}
}
upstream.sendPacket(new BiomeDefinitionListPacket());
upstream.sendPacket(new AvailableEntityIdentifiersPacket());
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
upstream.sendPacket(playStatusPacket);
@ -279,15 +290,15 @@ public class GeyserSession implements Player {
startGamePacket.setPlayerPosition(Vector3f.from(0, 69, 0));
startGamePacket.setRotation(Vector2f.from(1, 1));
startGamePacket.setSeed(0);
startGamePacket.setSeed(-1);
startGamePacket.setDimensionId(playerEntity.getDimension());
startGamePacket.setGeneratorId(1);
startGamePacket.setLevelGamemode(0);
startGamePacket.setDifficulty(1);
startGamePacket.setDefaultSpawn(Vector3i.ZERO);
startGamePacket.setAcheivementsDisabled(true);
startGamePacket.setTime(0);
startGamePacket.setEduLevel(false);
startGamePacket.setTime(-1);
startGamePacket.setEduEditionOffers(0);
startGamePacket.setEduFeaturesEnabled(false);
startGamePacket.setRainLevel(0);
startGamePacket.setLightningLevel(0);
@ -313,12 +324,13 @@ public class GeyserSession implements Player {
startGamePacket.setLevelId("world");
startGamePacket.setWorldName("world");
startGamePacket.setPremiumWorldTemplateId("00000000-0000-0000-0000-000000000000");
startGamePacket.setCurrentTick(0);
// startGamePacket.setCurrentTick(0);
startGamePacket.setEnchantmentSeed(0);
startGamePacket.setMultiplayerCorrelationId("");
startGamePacket.setBlockPalette(Toolbox.BLOCKS);
startGamePacket.setItemEntries(Toolbox.ITEMS);
startGamePacket.setVanillaVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
// startGamePacket.setMovementServerAuthoritative(true);
upstream.sendPacket(startGamePacket);
}
}

View file

@ -18,7 +18,7 @@ public class UpstreamSession {
public void sendPacket(@NonNull BedrockPacket packet) {
if (isClosed())
return;
session.sendPacket(packet);
}

View file

@ -49,7 +49,7 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
PlayStatusPacket playStatus = new PlayStatusPacket();
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
session.getUpstream().sendPacket(playStatus);
// session.getUpstream().sendPacket(playStatus);
PlayerEntity entity = session.getPlayerEntity();
entity.setEntityId(packet.getEntityId());

View file

@ -57,9 +57,11 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
session.getUpstream().sendPacket(playerGameTypePacket);
session.setGameMode(packet.getGamemode());
/*
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
session.getUpstream().sendPacket(playStatusPacket);
*/
}
private int getDimension(int javaDimension) {

View file

@ -63,8 +63,8 @@ public class JavaPlayerHealthTranslator extends PacketTranslator<ServerPlayerHea
RespawnPacket respawnPacket = new RespawnPacket();
respawnPacket.setRuntimeEntityId(entity.getGeyserId());
respawnPacket.setPosition(Vector3f.from(0, 72, 0));
respawnPacket.setSpawnState(2); // client ready to respawn
session.getUpstream().sendPacket(new RespawnPacket());
respawnPacket.setSpawnState(0); // state searching for spawn
session.getUpstream().sendPacket(respawnPacket);
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
session.getDownstream().getSession().send(javaRespawnPacket);

View file

@ -48,7 +48,7 @@ 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(32, 64, skinData), ImageData.of(32, 64, capeData), geometryName, geometryData, true);
SerializedSkin serializedSkin = SerializedSkin.of(skinId, ImageData.of(64, 64, skinData), ImageData.of(64, 32, capeData), geometryName, geometryData, true);
PlayerListPacket.Entry entry = new PlayerListPacket.Entry(uuid);
entry.setName(username);