Skip to content

Commit

Permalink
fix cast on HumanEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
SenseiTarzan committed Dec 23, 2024
1 parent 22f1838 commit 01618e8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
3 changes: 0 additions & 3 deletions src/main/java/org/sculk/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public Server(LocalManager localManager, Logger logger, String dataPath) {
//Language manager
this.localManager = localManager;
this.language = localManager.getLanguage(this.properties.get(ServerPropertiesKeys.LANGUAGE, DEFAULT_LANGUAGE));
System.out.println(this.properties.get(ServerPropertiesKeys.LANGUAGE, DEFAULT_LANGUAGE));
this.logger.info(this.language.translate(LanguageKeys.SCULK_SERVER_SELECTED_LANGUAGE, List.of(TextFormat.DARK_AQUA + this.language.getName() + TextFormat.RESET)));

//Load server properties
Expand Down Expand Up @@ -358,8 +357,6 @@ public boolean addOnlinePlayer(Player player) {
return false;
for (Player onlinePlayer : this.playerList.values()) {
onlinePlayer.getNetworkSession().onPlayerAdded(player);
player.spawnTo(onlinePlayer);
onlinePlayer.spawnTo(player);
}
this.playerList.put(player.getUniqueId(), player);
return true;
Expand Down
40 changes: 21 additions & 19 deletions src/main/java/org/sculk/entity/HumanEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Setter;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.protocol.bedrock.data.AttributeData;
import org.cloudburstmc.protocol.bedrock.data.GameType;
import org.cloudburstmc.protocol.bedrock.data.PlayerPermission;
import org.cloudburstmc.protocol.bedrock.data.command.CommandPermission;
Expand Down Expand Up @@ -123,8 +124,8 @@ protected void sendSpawnPacket(Player player) {
packet.getEntries().add(networkSession.createPlayerEntry(this, true));
networkSession.sendPacket(packet);
}
AddPlayerPacket addPlayerPacket = createAddEntityPacket();
networkSession.sendPacket(addPlayerPacket);
super.sendSpawnPacket(player);
this.sendData(List.of(player));

if(!(this instanceof Player)) {
PlayerListPacket packet = new PlayerListPacket();
Expand All @@ -136,23 +137,24 @@ protected void sendSpawnPacket(Player player) {

@Override
protected @NonNull BedrockPacket createAddEntityPacket() {
AddPlayerPacket addPlayerPacket = new AddPlayerPacket();
addPlayerPacket.setUuid(this.getUniqueId());
addPlayerPacket.setUsername(this.getName());
addPlayerPacket.setRuntimeEntityId(this.getEntityId());
addPlayerPacket.setUniqueEntityId(this.getEntityId());
addPlayerPacket.setPlatformChatId("");
addPlayerPacket.setPosition(Vector3f.ZERO);
addPlayerPacket.setRotation(Vector3f.ZERO);
addPlayerPacket.setMotion(Vector3f.ZERO);
addPlayerPacket.setHand(ItemData.AIR);
addPlayerPacket.getAdventureSettings().setCommandPermission(CommandPermission.ANY);
addPlayerPacket.getAdventureSettings().setPlayerPermission(PlayerPermission.MEMBER);
addPlayerPacket.setGameType(GameType.SURVIVAL);
addPlayerPacket.setMetadata(this.getAllNetworkData());
addPlayerPacket.setDeviceId("");
addPlayerPacket.setBuildPlatform(0);
return addPlayerPacket;
AddPlayerPacket packet = new AddPlayerPacket();
packet.setUuid(this.getUniqueId());
packet.setUsername(this.getName());
packet.setRuntimeEntityId(this.getEntityId());
packet.setUniqueEntityId(this.getEntityId());
packet.setPlatformChatId("");
packet.setPosition(Vector3f.from(0, -100, 0));
packet.setRotation(Vector3f.ZERO);
packet.setMotion(Vector3f.ZERO);
packet.setHand(ItemData.AIR);
packet.setAbilityLayers(List.of());
packet.getAdventureSettings().setCommandPermission(CommandPermission.ANY);
packet.getAdventureSettings().setPlayerPermission(PlayerPermission.MEMBER);
packet.setGameType(GameType.SURVIVAL);
packet.setMetadata(this.getAllNetworkData());
packet.setDeviceId("");
packet.setBuildPlatform(-1);
return packet;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public SculkBedrockServerInitializer(BedrockInterface bedrockInterface, Server s
protected void initSession(BedrockServerSession bedrockServerSession) {
bedrockServerSession.setCodec(ProtocolInfo.CODEC);
bedrockServerSession.setLogging(false);
System.out.println("Session Connected!");
}

@Override
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/sculk/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ public void doFirstSpawn() {
String defaultJoinMessage = this.getLanguage().translate(LanguageKeys.MINECRAFT_PLAYER_JOIN, List.of(this.getName()));
Server.getInstance().broadcastMessage(TextFormat.YELLOW + defaultJoinMessage + TextFormat.RESET);
}

for (Player player: Server.getInstance().getOnlinePlayers().values()) {
this.spawnTo(player);
player.spawnTo(this);
}
}

/**
Expand Down

0 comments on commit 01618e8

Please sign in to comment.