use of net.minecraft.network.packet.s2c.play.EntitySetHeadYawS2CPacket in project KahzerxMod by otakucraft.
the class KlonePlayerEntity method createKlone.
public static void createKlone(MinecraftServer server, ServerPlayerEntity player) {
ServerWorld world = player.getWorld();
GameProfile profile = player.getGameProfile();
server.getPlayerManager().remove(player);
player.networkHandler.disconnect(new LiteralText("A clone has been created.\nThe clone will leave once you rejoin.\nHappy AFK!"));
KlonePlayerEntity klonedPlayer = new KlonePlayerEntity(server, world, profile);
klonedPlayer.refreshPositionAndAngles(player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch());
server.getPlayerManager().onPlayerConnect(new KloneNetworkManager(NetworkSide.SERVERBOUND), klonedPlayer);
klonedPlayer.teleport(world, player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch());
klonedPlayer.setHealth(player.getHealth());
klonedPlayer.unsetRemoved();
klonedPlayer.stepHeight = 0.6F;
klonedPlayer.interactionManager.changeGameMode(player.interactionManager.getGameMode());
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(klonedPlayer, (byte) (player.headYaw * 256 / 360)), klonedPlayer.world.getRegistryKey());
server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(klonedPlayer), klonedPlayer.world.getRegistryKey());
server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, klonedPlayer));
player.getWorld().getChunkManager().updatePosition(klonedPlayer);
klonedPlayer.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f);
klonedPlayer.getAbilities().flying = player.getAbilities().flying;
}
Aggregations