#pragma once #include #include #include #include #include "net.minecraft.world.entity.h" #include "net.minecraft.world.entity.player.h" #include "net.minecraft.world.level.h" #include "net.minecraft.commands.h" using std::wstring; using std::map; using std::vector; using std::shared_ptr; //translation of net.minecraft.command.PlayerSelector from java to c++ class PlayerSelector { public: // Returns true if the token is a selector pattern (@p, @a, @r, @e, @s) static bool hasArguments(const wstring& token); static bool matchesMultiplePlayers(const wstring& token); static shared_ptr matchOnePlayer(shared_ptr sender, const wstring& token); static shared_ptr matchOneEntity(shared_ptr sender, const wstring& token); static vector> matchEntities(shared_ptr sender, const wstring& token, eINSTANCEOF targetType = eTYPE_ENTITY); private: static map getArgumentMap(const wstring& argString); static int parseIntWithDefault(const map& args, const wstring& key, int def); static double parseDoubleWithDefault(const map& args, const wstring& key, double def); static wstring getArg(const map& args, const wstring& key); static void getOrigin(const map& args, shared_ptr sender, double& ox, double& oy, double& oz); static bool hasWorldBindingArgs(const map& args); static int normaliseAngle(int angle); static vector> applyCountAndSort( vector>& candidates, const map& args, shared_ptr sender, const wstring& selectorType, double ox, double oy, double oz); static bool matchesType (shared_ptr e, const wstring& selectorType, const map& args); static bool matchesLevel (shared_ptr e, const map& args); static bool matchesGameMode (shared_ptr e, const map& args); static bool matchesTeam (shared_ptr e, const map& args); static bool matchesName (shared_ptr e, const map& args); static bool matchesRange (shared_ptr e, const map& args, double ox, double oy, double oz); static bool matchesRotation (shared_ptr e, const map& args); static bool matchesNbt (shared_ptr e, const map& args); static bool matchesAABB (shared_ptr e, const map& args, double ox, double oy, double oz); };