Skip to content

Commit

Permalink
Merge branch 'feature/smoother-than-butter' into bleeding
Browse files Browse the repository at this point in the history
# Conflicts:
#	connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
#	connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java
  • Loading branch information
bundabrg committed Aug 23, 2020
2 parents e91e3bc + d74e563 commit cf018f1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ public void connect(RemoteServer remoteServer) {
gamerulePacket.getGameRules().add(new GameRuleData<>("naturalregeneration", false));
sendUpstreamPacket(gamerulePacket);

login();
// Spawn the player
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
sendUpstreamPacket(playStatusPacket);
}

public void login() {
Expand Down Expand Up @@ -447,6 +450,25 @@ public void connected(ConnectedEvent event) {
// Download and load the language for the player
LocaleUtils.downloadAndLoadLocale(locale);

for (Entity entity : getEntityCache().getEntities().values()) {
if (!entity.isValid()) {
if (entity instanceof PlayerEntity) {
SkinUtils.requestAndHandleSkinAndCape((PlayerEntity) entity, GeyserSession.this, null);
}
entity.spawnEntity(GeyserSession.this);
}
}

// Send Skulls
for (PlayerEntity entity : session.getSkullCache().values()) {
entity.spawnEntity(session);

SkinUtils.requestAndHandleSkinAndCape(entity, session, (skinAndCape) -> session.getConnector().getGeneralThreadPool().schedule(() -> {
entity.getMetadata().getFlags().setFlag(EntityFlag.INVISIBLE, false);
entity.updateBedrockMetadata(session);
}, 2, TimeUnit.SECONDS));
}

// Register plugin channels
connector.getGeneralThreadPool().schedule(() -> {
for (String channel : getConnector().getRegisteredPluginChannels()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@

package org.geysermc.connector.network.translators.bedrock;

import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.utils.SkinUtils;

import com.nukkitx.protocol.bedrock.packet.SetLocalPlayerAsInitializedPacket;

Expand All @@ -44,26 +40,7 @@ public void translate(SetLocalPlayerAsInitializedPacket packet, GeyserSession se
if (session.getPlayerEntity().getGeyserId() == packet.getRuntimeEntityId()) {
if (!session.getUpstream().isInitialized()) {
session.getUpstream().setInitialized(true);

for (Entity entity : session.getEntityCache().getEntities().values()) {
if (!entity.isValid()) {
if (entity instanceof PlayerEntity) {
SkinUtils.requestAndHandleSkinAndCape((PlayerEntity) entity, session, null);
}
entity.spawnEntity(session);
}
}

// Send Skulls
for (PlayerEntity entity : session.getSkullCache().values()) {
entity.spawnEntity(session);

SkinUtils.requestAndHandleSkinAndCape(entity, session, (skinAndCape) -> session.getConnector().getGeneralThreadPool().schedule(() -> {
entity.getMetadata().getFlags().setFlag(EntityFlag.INVISIBLE, false);
entity.updateBedrockMetadata(session);
}, 2, TimeUnit.SECONDS));
}

session.login();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public void translate(ServerJoinGamePacket packet, GeyserSession session) {
session.sendUpstreamPacket(playerGameTypePacket);
session.setGameMode(packet.getGameMode());

SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
entityDataPacket.getMetadata().putAll(entity.getMetadata());
session.sendUpstreamPacket(entityDataPacket);
// SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
// entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
// entityDataPacket.getMetadata().putAll(entity.getMetadata());
// session.sendUpstreamPacket(entityDataPacket);

// Send if client should show respawn screen
GameRulesChangedPacket gamerulePacket = new GameRulesChangedPacket();
Expand Down

0 comments on commit cf018f1

Please sign in to comment.