#include "stdafx.h" #include "net.minecraft.commands.h" #include "../Minecraft.Client/MinecraftServer.h" #include "../Minecraft.Client/ServerLevel.h" #include "../Minecraft.Client/ServerPlayer.h" #include "../Minecraft.Client/PlayerList.h" #include "net.minecraft.world.level.h" #include "net.minecraft.world.level.dimension.h" #include "net.minecraft.network.packet.h" #include "SetDefaultSpawnpointCommand.h" EGameCommand SetDefaultSpawnpointCommand::getId() { return eGameCommand_SetDefaultSpawnpoint; } int SetDefaultSpawnpointCommand::getPermissionLevel() { return LEVEL_GAMEMASTERS; } void SetDefaultSpawnpointCommand::execute(shared_ptr source, byteArray commandData) { shared_ptr player = dynamic_pointer_cast(source); if (player == nullptr || player->level == nullptr) return; if (player->level->dimension->id != 0) return; int x = Mth::floor(player->x); int y = Mth::floor(player->y); int z = Mth::floor(player->z); player->level->setSpawnPos(x, y, z); MinecraftServer::getInstance()->getPlayers()->broadcastAll(std::make_shared(x, y, z)); } shared_ptr SetDefaultSpawnpointCommand::preparePacket() { return std::make_shared(eGameCommand_SetDefaultSpawnpoint, byteArray()); }