feat: adapt
This commit is contained in:
+179
-164
@@ -1,4 +1,7 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "mc/world/item/Item.h"
|
||||||
|
#include "mc/world/item/enchanting/EnchantUtils.h"
|
||||||
|
#include "mc/world/level/block/Block.h"
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -16,31 +19,31 @@ ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
|||||||
|
|
||||||
void Export_Compatibility_API() {
|
void Export_Compatibility_API() {
|
||||||
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return CustomRecipe::unregisterRecipe(id);
|
return recipe::RecipeRegistry::unregisterRecipe(id);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
||||||
CustomPacks::addCustomPackPath(path);
|
AddonsLoader::addCustomPackPath(path);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
return level->getServerMspt();
|
return level->getServerMspt();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
return level->getServerCurrentTps();
|
return level->getServerCurrentTps();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> float {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
@@ -48,38 +51,40 @@ void Export_Compatibility_API() {
|
|||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
std::vector<mce::UUID> uuids = GMLIB_Player::getAllUuids();
|
std::vector<mce::UUID> uuids = world::Player::getAllUuids();
|
||||||
for (auto& uuid : uuids) {
|
for (auto& uuid : uuids) {
|
||||||
result.push_back(uuid.asString());
|
result.push_back(uuid.asString());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<::CompoundTag> {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return std::move(GMLIB_Player::getPlayerNbt(uid));
|
return std::move(world::Player::getPlayerNbt(uid));
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerNbt",
|
"setPlayerNbt",
|
||||||
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
[](std::string const& uuid, ::CompoundTag* nbt, bool forceCreate) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
|
auto nbtt = world::CompoundTag(*nbt);
|
||||||
|
return world::Player::setPlayerNbt(uid, nbtt, forceCreate);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerNbtTags",
|
"setPlayerNbtTags",
|
||||||
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
[](std::string const& uuid, ::CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
auto nbtt = world::CompoundTag(*nbt);
|
||||||
|
return world::Player::setPlayerNbtTags(uid, nbtt, tags);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "deletePlayerNbt", [](std::string const& uuid) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "deletePlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::deletePlayerNbt(uid);
|
return world::Player::deletePlayerNbt(uid);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
||||||
auto list = GMLIB_Level::getAllExperiments();
|
auto list = world::Level::getAllExperiments();
|
||||||
std::vector<int> result;
|
std::vector<int> result;
|
||||||
for (auto& key : list) {
|
for (auto& key : list) {
|
||||||
result.push_back((int)key);
|
result.push_back((int)key);
|
||||||
@@ -113,7 +118,7 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
||||||
return FloatingTextManager::getInstance().remove(id);
|
return FloatingTextManager::getInstance().remove(id);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, ::Player* pl) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
ft->sendTo(*pl);
|
ft->sendTo(*pl);
|
||||||
return true;
|
return true;
|
||||||
@@ -127,7 +132,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, ::Player* pl) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
ft->removeFrom(*pl);
|
ft->removeFrom(*pl);
|
||||||
return true;
|
return true;
|
||||||
@@ -141,7 +146,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, ::Player* pl) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
ft->update(*pl);
|
ft->update(*pl);
|
||||||
return true;
|
return true;
|
||||||
@@ -176,24 +181,24 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string const& code) -> void {
|
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string const& code) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (world::Level::getInstance()) {
|
||||||
I18nAPI::chooseLanguage(code);
|
I18nAPI::chooseLanguage(code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getResourcePackI18nLanguage", []() -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getResourcePackI18nLanguage", []() -> std::string {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (world::Level::getInstance()) {
|
||||||
return I18nAPI::getCurrentLanguageCode();
|
return I18nAPI::getCurrentLanguageCode();
|
||||||
}
|
}
|
||||||
return "unknown";
|
return "unknown";
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getSupportedLanguages", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getSupportedLanguages", []() -> std::vector<std::string> {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (world::Level::getInstance()) {
|
||||||
return I18nAPI::getSupportedLanguageCodes();
|
return I18nAPI::getSupportedLanguageCodes();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "loadLanguage", [](std::string const& code, std::string const& lang) -> void {
|
RemoteCall::exportAs("GMLIB_API", "loadLanguage", [](std::string const& code, std::string const& lang) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (world::Level::getInstance()) {
|
||||||
I18nAPI::loadLanguage(code, lang);
|
I18nAPI::loadLanguage(code, lang);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -202,19 +207,19 @@ void Export_Compatibility_API() {
|
|||||||
"updateOrCreateLanguageFile",
|
"updateOrCreateLanguageFile",
|
||||||
[](std::string const& code, std::unordered_map<std::string, std::string> lang, std::string const& path
|
[](std::string const& code, std::unordered_map<std::string, std::string> lang, std::string const& path
|
||||||
) -> void {
|
) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (world::Level::getInstance()) {
|
||||||
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
|
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "loadLanguagePath", [](std::string const& path) -> void {
|
RemoteCall::exportAs("GMLIB_API", "loadLanguagePath", [](std::string const& path) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (world::Level::getInstance()) {
|
||||||
I18nAPI::loadLanguagesFromDirectory(path);
|
I18nAPI::loadLanguagesFromDirectory(path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
auto pos = GMLIB_Player::getPlayerPosition(uid);
|
auto pos = world::Player::getPlayerPosition(uid);
|
||||||
if (pos.has_value()) {
|
if (pos.has_value()) {
|
||||||
return pos.value();
|
return pos.value();
|
||||||
}
|
}
|
||||||
@@ -228,19 +233,19 @@ void Export_Compatibility_API() {
|
|||||||
"setPlayerPosition",
|
"setPlayerPosition",
|
||||||
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::setPlayerPosition(uid, pos.first, pos.second);
|
return world::Player::setPlayerPosition(uid, pos.first, pos.second);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
if (auto result = world::Player::getPlayerScore(uid, obj)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerScore", [](std::string const& uuid, std::string const& obj) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerScore", [](std::string const& uuid, std::string const& obj) -> int {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
if (auto result = world::Player::getPlayerScore(uid, obj)) {
|
||||||
return result.value();
|
return result.value();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -250,7 +255,7 @@ void Export_Compatibility_API() {
|
|||||||
"addPlayerScore",
|
"addPlayerScore",
|
||||||
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Add)) {
|
if (auto res = world::Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Add)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -261,7 +266,7 @@ void Export_Compatibility_API() {
|
|||||||
"reducePlayerScore",
|
"reducePlayerScore",
|
||||||
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Subtract)) {
|
if (auto res = world::Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -272,7 +277,7 @@ void Export_Compatibility_API() {
|
|||||||
"setPlayerScore",
|
"setPlayerScore",
|
||||||
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value)) {
|
if (auto res = world::Player::setPlayerScore(uid, obj, value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -280,18 +285,18 @@ void Export_Compatibility_API() {
|
|||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetPlayerScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::resetPlayerScore(uid, obj);
|
return world::Player::resetPlayerScore(uid, obj);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetPlayerScores", [](std::string const& uuid) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScores", [](std::string const& uuid) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::resetPlayerScore(uid);
|
return world::Player::resetPlayerScore(uid);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"entityHasScore",
|
"entityHasScore",
|
||||||
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
if (auto result = world::Scoreboard::getInstance()->getScore(obj, auid)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -299,7 +304,7 @@ void Export_Compatibility_API() {
|
|||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityScore", [](std::string const& uniqueId, std::string const& obj) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityScore", [](std::string const& uniqueId, std::string const& obj) -> int {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
if (auto result = world::Scoreboard::getInstance()->getScore(obj, auid)) {
|
||||||
return result.value();
|
return result.value();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -309,7 +314,7 @@ void Export_Compatibility_API() {
|
|||||||
"addEntityScore",
|
"addEntityScore",
|
||||||
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Add)) {
|
if (auto res = world::Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Add)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -321,7 +326,7 @@ void Export_Compatibility_API() {
|
|||||||
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
if (auto res =
|
if (auto res =
|
||||||
GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Subtract)) {
|
world::Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -332,7 +337,7 @@ void Export_Compatibility_API() {
|
|||||||
"setEntityScore",
|
"setEntityScore",
|
||||||
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value)) {
|
if (auto res = world::Scoreboard::getInstance()->setScore(obj, auid, value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -343,25 +348,25 @@ void Export_Compatibility_API() {
|
|||||||
"resetEntityScore",
|
"resetEntityScore",
|
||||||
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
return GMLIB_Scoreboard::getInstance()->resetScore(obj, auid);
|
return world::Scoreboard::getInstance()->resetScore(obj, auid);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetEntityScores", [](std::string const& uniqueId) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "resetEntityScores", [](std::string const& uniqueId) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
return GMLIB_Scoreboard::getInstance()->resetScore(auid);
|
return world::Scoreboard::getInstance()->resetScore(auid);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"fakePlayerHasScore",
|
"fakePlayerHasScore",
|
||||||
[](std::string const& name, std::string const& obj) -> bool {
|
[](std::string const& name, std::string const& obj) -> bool {
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
if (auto result = world::Scoreboard::getInstance()->getScore(obj, name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getFakePlayerScore", [](std::string const& name, std::string const& obj) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getFakePlayerScore", [](std::string const& name, std::string const& obj) -> int {
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
if (auto result = world::Scoreboard::getInstance()->getScore(obj, name)) {
|
||||||
return result.value();
|
return result.value();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -370,7 +375,7 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"addFakePlayerScore",
|
"addFakePlayerScore",
|
||||||
[](std::string const& name, std::string const& obj, int value) -> bool {
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Add)) {
|
if (auto res = world::Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Add)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -381,7 +386,7 @@ void Export_Compatibility_API() {
|
|||||||
"reduceFakePlayerScore",
|
"reduceFakePlayerScore",
|
||||||
[](std::string const& name, std::string const& obj, int value) -> bool {
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
if (auto res =
|
if (auto res =
|
||||||
GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Subtract)) {
|
world::Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -391,7 +396,7 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setFakePlayerScore",
|
"setFakePlayerScore",
|
||||||
[](std::string const& name, std::string const& obj, int value) -> bool {
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value)) {
|
if (auto res = world::Scoreboard::getInstance()->setScore(obj, name, value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -401,14 +406,14 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"resetFakePlayerScore",
|
"resetFakePlayerScore",
|
||||||
[](std::string const& name, std::string const& obj) -> bool {
|
[](std::string const& name, std::string const& obj) -> bool {
|
||||||
return GMLIB_Scoreboard::getInstance()->resetScore(obj, name);
|
return world::Scoreboard::getInstance()->resetScore(obj, name);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetFakePlayerScores", [](std::string const& name) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "resetFakePlayerScores", [](std::string const& name) -> bool {
|
||||||
return GMLIB_Scoreboard::getInstance()->resetScore(name);
|
return world::Scoreboard::getInstance()->resetScore(name);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "addObjective", [](std::string const& obj) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "addObjective", [](std::string const& obj) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->addObjective(obj)) {
|
if (auto res = world::Scoreboard::getInstance()->addObjective(obj)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -417,14 +422,14 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"addObjectiveWithDisplayName",
|
"addObjectiveWithDisplayName",
|
||||||
[](std::string const& obj, std::string const& displayName) -> bool {
|
[](std::string const& obj, std::string const& displayName) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->addObjective(obj, displayName)) {
|
if (auto res = world::Scoreboard::getInstance()->addObjective(obj, displayName)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getDisplayName", [](std::string const& obj) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getDisplayName", [](std::string const& obj) -> std::string {
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getObjectiveDisplayName(obj)) {
|
if (auto result = world::Scoreboard::getInstance()->getObjectiveDisplayName(obj)) {
|
||||||
return result.value();
|
return result.value();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
@@ -433,24 +438,24 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setDisplayName",
|
"setDisplayName",
|
||||||
[](std::string const& obj, std::string const& displayName) -> bool {
|
[](std::string const& obj, std::string const& displayName) -> bool {
|
||||||
return GMLIB_Scoreboard::getInstance()->setObjectiveDisplayName(obj, displayName);
|
return world::Scoreboard::getInstance()->setObjectiveDisplayName(obj, displayName);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeObjective", [](std::string const& obj) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeObjective", [](std::string const& obj) -> bool {
|
||||||
return GMLIB_Scoreboard::getInstance()->removeObjective(obj);
|
return world::Scoreboard::getInstance()->removeObjective(obj);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setDisplayObjective",
|
"setDisplayObjective",
|
||||||
[](std::string const& obj, std::string const& slot, int order) -> void {
|
[](std::string const& obj, std::string const& slot, int order) -> void {
|
||||||
return GMLIB_Scoreboard::getInstance()->setObjectiveDisplay(obj, slot, (ObjectiveSortOrder)order);
|
return world::Scoreboard::getInstance()->setObjectiveDisplay(obj, slot, (ObjectiveSortOrder)order);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "clearDisplayObjective", [](std::string const& slot) -> void {
|
RemoteCall::exportAs("GMLIB_API", "clearDisplayObjective", [](std::string const& slot) -> void {
|
||||||
return GMLIB_Scoreboard::getInstance()->clearObjectiveDisplay(slot);
|
return world::Scoreboard::getInstance()->clearObjectiveDisplay(slot);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllObjectives", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllObjectives", []() -> std::vector<std::string> {
|
||||||
auto objs = GMLIB_Scoreboard::getInstance()->getObjectives();
|
auto objs = world::Scoreboard::getInstance()->getObjectives();
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto& obj : objs) {
|
for (auto& obj : objs) {
|
||||||
result.push_back(obj->getName());
|
result.push_back(obj->getName());
|
||||||
@@ -458,7 +463,7 @@ void Export_Compatibility_API() {
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardPlayers", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardPlayers", []() -> std::vector<std::string> {
|
||||||
auto uuids = GMLIB_Scoreboard::getInstance()->getAllPlayerUuids();
|
auto uuids = world::Scoreboard::getInstance()->getAllPlayerUuids();
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto& uuid : uuids) {
|
for (auto& uuid : uuids) {
|
||||||
result.push_back(uuid.asString());
|
result.push_back(uuid.asString());
|
||||||
@@ -466,7 +471,7 @@ void Export_Compatibility_API() {
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardFakePlayers", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardFakePlayers", []() -> std::vector<std::string> {
|
||||||
auto names = GMLIB_Scoreboard::getInstance()->getAllFakePlayers();
|
auto names = world::Scoreboard::getInstance()->getAllFakePlayers();
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto& name : names) {
|
for (auto& name : names) {
|
||||||
result.push_back(name);
|
result.push_back(name);
|
||||||
@@ -474,7 +479,7 @@ void Export_Compatibility_API() {
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardEntities", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardEntities", []() -> std::vector<std::string> {
|
||||||
auto uniqueIds = GMLIB_Scoreboard::getInstance()->getAllEntities();
|
auto uniqueIds = world::Scoreboard::getInstance()->getAllEntities();
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto& uniqueId : uniqueIds) {
|
for (auto& uniqueId : uniqueIds) {
|
||||||
result.push_back(std::to_string(uniqueId.id));
|
result.push_back(std::to_string(uniqueId.id));
|
||||||
@@ -486,21 +491,21 @@ void Export_Compatibility_API() {
|
|||||||
"getAllTrackedTargets",
|
"getAllTrackedTargets",
|
||||||
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
auto uuids = GMLIB_Scoreboard::getInstance()->getAllPlayerUuids();
|
auto uuids = world::Scoreboard::getInstance()->getAllPlayerUuids();
|
||||||
for (auto& uuid : uuids) {
|
for (auto& uuid : uuids) {
|
||||||
std::unordered_map<std::string, std::string> data;
|
std::unordered_map<std::string, std::string> data;
|
||||||
data["Type"] = "Player";
|
data["Type"] = "Player";
|
||||||
data["Uuid"] = uuid.asString();
|
data["Uuid"] = uuid.asString();
|
||||||
result.push_back(data);
|
result.push_back(data);
|
||||||
}
|
}
|
||||||
auto names = GMLIB_Scoreboard::getInstance()->getAllFakePlayers();
|
auto names = world::Scoreboard::getInstance()->getAllFakePlayers();
|
||||||
for (auto& name : names) {
|
for (auto& name : names) {
|
||||||
std::unordered_map<std::string, std::string> data;
|
std::unordered_map<std::string, std::string> data;
|
||||||
data["Type"] = "FakePlayer";
|
data["Type"] = "FakePlayer";
|
||||||
data["Name"] = name;
|
data["Name"] = name;
|
||||||
result.push_back(data);
|
result.push_back(data);
|
||||||
}
|
}
|
||||||
auto uniqueIds = GMLIB_Scoreboard::getInstance()->getAllEntities();
|
auto uniqueIds = world::Scoreboard::getInstance()->getAllEntities();
|
||||||
for (auto& uniqueId : uniqueIds) {
|
for (auto& uniqueId : uniqueIds) {
|
||||||
std::unordered_map<std::string, std::string> data;
|
std::unordered_map<std::string, std::string> data;
|
||||||
data["Type"] = "Entity";
|
data["Type"] = "Entity";
|
||||||
@@ -510,38 +515,38 @@ void Export_Compatibility_API() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUuid", [](std::string const& uuid) -> Player* {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUuid", [](std::string const& uuid) -> ::Player* {
|
||||||
return ll::service::getLevel()->getPlayer(mce::UUID::fromString(uuid));
|
return ll::service::getLevel()->getPlayer(mce::UUID::fromString(uuid));
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUniqueId", [](std::string const& uniqueId) -> ::Actor* {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
return ll::service::getLevel()->getPlayer(auid);
|
return ll::service::getLevel()->getPlayer(auid);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
RemoteCall::exportAs("GMLIB_API", "getEntityFromUniqueId", [](std::string const& uniqueId) -> ::Actor* {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
return ll::service::getLevel()->fetchEntity(auid);
|
return ll::service::getLevel()->fetchEntity(auid);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getWorldSpawn", []() -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getWorldSpawn", []() -> std::pair<BlockPos, int> {
|
||||||
return {GMLIB_Level::getInstance()->getWorldSpawn(), 0};
|
return {world::Level::getInstance()->getWorldSpawn(), 0};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
|
||||||
if (pos.second != 0) {
|
if (pos.second != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GMLIB_Level::getInstance()->setWorldSpawn(pos.first);
|
world::Level::getInstance()->setWorldSpawn(pos.first);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](Player* pl) -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](::Player* pl) -> std::pair<BlockPos, int> {
|
||||||
auto player = (GMLIB_Player*)pl;
|
auto player = (world::Player*)pl;
|
||||||
auto res = player->getSpawnPoint();
|
auto res = player->getSpawnPoint();
|
||||||
return {res.first, res.second};
|
return {res.first, res.second};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](::Player* pl, std::pair<BlockPos, int> pos) -> void {
|
||||||
auto player = (GMLIB_Player*)pl;
|
auto player = (world::Player*)pl;
|
||||||
player->setSpawnPoint(pos.first, pos.second);
|
player->setSpawnPoint(pos.first, pos.second);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void {
|
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](::Player* pl) -> void {
|
||||||
auto player = (GMLIB_Player*)pl;
|
auto player = (world::Player*)pl;
|
||||||
player->clearSpawnPoint();
|
player->clearSpawnPoint();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -608,18 +613,18 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
||||||
return block->buildDescriptionId();
|
return block->buildDescriptionId();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](::ItemStack* item) -> std::string {
|
||||||
return item->getDescriptionId();
|
return item->getDescriptionId();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityTranslateKey", [](Actor* entity) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getEntityTranslateKey", [](::Actor* entity) -> std::string {
|
||||||
return entity->getEntityLocNameString();
|
return entity->getEntityLocNameString();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"readNbtFromFile",
|
"readNbtFromFile",
|
||||||
[](std::string const& path, bool isBinary) -> std::unique_ptr<CompoundTag> {
|
[](std::string const& path, bool isBinary) -> std::unique_ptr<::CompoundTag> {
|
||||||
if (auto nbt = GMLIB_CompoundTag::readFromFile(path, isBinary)) {
|
if (auto nbt = world::CompoundTag::readFromFile(path, isBinary)) {
|
||||||
return std::make_unique<CompoundTag>(nbt.value());
|
return std::make_unique<::CompoundTag>(nbt.value());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -627,33 +632,33 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"saveNbtToFile",
|
"saveNbtToFile",
|
||||||
[](std::string const& path, CompoundTag* nbt, bool isBinary) -> bool {
|
[](std::string const& path, ::CompoundTag* nbt, bool isBinary) -> bool {
|
||||||
return GMLIB_CompoundTag::saveToFile(path, *nbt, isBinary);
|
return world::CompoundTag::saveToFile(path, *nbt, isBinary);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float {
|
||||||
return block->getDestroySpeed();
|
return block->getDestroySpeed();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](::ItemStack const* item, Block const* block) -> float {
|
||||||
return item->getDestroySpeed(*block);
|
return item->getDestroySpeed(*block);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"playerDestroyBlock",
|
"playerDestroyBlock",
|
||||||
[](Block const* block, std::pair<BlockPos, int> pos, Player* player) -> void {
|
[](Block const* block, std::pair<BlockPos, int> pos, ::Player* player) -> void {
|
||||||
return block->playerDestroy(*player, pos.first);
|
return block->playerDestroy(*player, pos.first);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyBlock", [](ItemStack const* item, Block const* block) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyBlock", [](::ItemStack const* item, Block const* block) -> bool {
|
||||||
return item->canDestroy(block);
|
return item->canDestroy(block);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](ItemStack const* item) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](::ItemStack const* item) -> bool {
|
||||||
if (auto itemDef = item->getItem()) {
|
if (auto itemDef = item->getItem()) {
|
||||||
return itemDef->canDestroyInCreative();
|
return itemDef->canDestroyInCreative();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](::ItemStack const* item, Block const* block) -> bool {
|
||||||
return item->canDestroySpecial(*block);
|
return item->canDestroySpecial(*block);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
||||||
@@ -665,14 +670,14 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"blockPlayerWillDestroy",
|
"blockPlayerWillDestroy",
|
||||||
[](Block const* block, Player* player, std::pair<BlockPos, int> pos) -> bool {
|
[](Block const* block, ::Player* player, std::pair<BlockPos, int> pos) -> bool {
|
||||||
return block->playerWillDestroy(*player, pos.first);
|
return block->playerWillDestroy(*player, pos.first);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](::Player* player, ::Actor* entity) -> bool {
|
||||||
return player->attack(*entity, ActorDamageCause::EntityAttack);
|
return player->attack(*entity, ActorDamageCause::EntityAttack);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](Player* player, Actor* entity) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](::Player* player, ::Actor* entity) -> bool {
|
||||||
return player->pullInEntity(*entity);
|
return player->pullInEntity(*entity);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
|
||||||
@@ -721,7 +726,7 @@ void Export_Compatibility_API() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getLegalEnchants", [](ItemStack const* item) -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getLegalEnchants", [](::ItemStack const* item) -> std::vector<std::string> {
|
||||||
std::vector<int> enchants = EnchantUtils::getLegalEnchants(item->getItem());
|
std::vector<int> enchants = EnchantUtils::getLegalEnchants(item->getItem());
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto& enchant : enchants) {
|
for (auto& enchant : enchants) {
|
||||||
@@ -738,30 +743,34 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"applyEnchant",
|
"applyEnchant",
|
||||||
[](ItemStack const* item, std::string const& typeName, int level, bool allowNonVanilla) -> bool {
|
[](::ItemStack const* item, std::string const& typeName, int level, bool allowNonVanilla) -> bool {
|
||||||
return EnchantUtils::applyEnchant(
|
return EnchantUtils::applyEnchant(
|
||||||
*(const_cast<ItemStack*>(item)),
|
*(const_cast<::ItemStack*>(item)),
|
||||||
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
||||||
level,
|
level,
|
||||||
allowNonVanilla
|
allowNonVanilla
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack const* item) -> void {
|
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](::ItemStack const* item) -> void {
|
||||||
EnchantUtils::removeEnchants((ItemStack&)*item);
|
EnchantUtils::removeEnchants((::ItemStack&)*item);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack const* item, std::string const& typeName) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](::ItemStack const* item, std::string const& typeName) -> bool {
|
||||||
return EnchantUtils::hasEnchant(
|
return EnchantUtils::hasEnchant(
|
||||||
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
||||||
*(const_cast<ItemStack*>(item))
|
*(const_cast<::ItemStack*>(item))
|
||||||
);
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEnchantLevel", [](ItemStack const* item, std::string const& typeName) -> int {
|
|
||||||
return EnchantUtils::getEnchantLevel(
|
|
||||||
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
|
||||||
*(const_cast<ItemStack*>(item))
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getEnchantLevel",
|
||||||
|
[](::ItemStack const* item, std::string const& typeName) -> int {
|
||||||
|
return EnchantUtils::getEnchantLevel(
|
||||||
|
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
||||||
|
*(const_cast<::ItemStack*>(item))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"getEnchantNameAndLevel",
|
"getEnchantNameAndLevel",
|
||||||
@@ -772,44 +781,44 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"dropPlayerItem",
|
"dropPlayerItem",
|
||||||
[](Player* player, ItemStack const* item, bool randomly) -> bool { return player->drop(*item, randomly); }
|
[](::Player* player, ::ItemStack const* item, bool randomly) -> bool { return player->drop(*item, randomly); }
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerRuntimeId", [](Player* player) -> uint64 {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerRuntimeId", [](::Player* player) -> uint64 {
|
||||||
return player->getRuntimeID().id;
|
return player->getRuntimeID().id;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityRuntimeId", [](Actor* entity) -> uint64 {
|
RemoteCall::exportAs("GMLIB_API", "getEntityRuntimeId", [](::Actor* entity) -> uint64 {
|
||||||
return entity->getRuntimeID().id;
|
return entity->getRuntimeID().id;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityNameTag", [](Actor* entity) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getEntityNameTag", [](::Actor* entity) -> std::string {
|
||||||
return entity->getNameTag();
|
return entity->getNameTag();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "ItemisUnbreakable", [](ItemStack const* item) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "ItemisUnbreakable", [](::ItemStack const* item) -> bool {
|
||||||
return ((GMLIB_ItemStack*)item)->isUnbreakable();
|
return ((world::ItemStack*)item)->isUnbreakable();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setItemUnbreakable", [](ItemStack const* item, bool value) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setItemUnbreakable", [](::ItemStack const* item, bool value) -> void {
|
||||||
((GMLIB_ItemStack*)item)->setUnbreakable(value);
|
((world::ItemStack*)item)->setUnbreakable(value);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemShouldKeepOnDeath", [](ItemStack const* item) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "getItemShouldKeepOnDeath", [](::ItemStack const* item) -> bool {
|
||||||
return ((GMLIB_ItemStack*)item)->getShouldKeepOnDeath();
|
return ((world::ItemStack*)item)->getShouldKeepOnDeath();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setItemShouldKeepOnDeath", [](ItemStack const* item, bool value) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setItemShouldKeepOnDeath", [](::ItemStack const* item, bool value) -> void {
|
||||||
((GMLIB_ItemStack*)item)->setShouldKeepOnDeath(value);
|
((world::ItemStack*)item)->setShouldKeepOnDeath(value);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemLockMode", [](ItemStack const* item) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getItemLockMode", [](::ItemStack const* item) -> int {
|
||||||
return (int)((GMLIB_ItemStack*)item)->getItemLockMode();
|
return (int)((world::ItemStack*)item)->getItemLockMode();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setItemLockMode", [](ItemStack const* item, int value) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setItemLockMode", [](::ItemStack const* item, int value) -> void {
|
||||||
((GMLIB_ItemStack*)item)->setItemLockMode((ItemLockMode)value);
|
((world::ItemStack*)item)->setItemLockMode((::ItemLockMode)value);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemRepairCost", [](ItemStack const* item) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getItemRepairCost", [](::ItemStack const* item) -> int {
|
||||||
return item->getBaseRepairCost();
|
return item->getBaseRepairCost();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setItemRepairCost", [](ItemStack const* item, int cost) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setItemRepairCost", [](::ItemStack const* item, int cost) -> void {
|
||||||
(*(const_cast<ItemStack*>(item))).setRepairCost(cost);
|
(*(const_cast<::ItemStack*>(item))).setRepairCost(cost);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemCanDestroy", [](ItemStack const* item) -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getItemCanDestroy", [](::ItemStack const* item) -> std::vector<std::string> {
|
||||||
std::vector<std::string> result = {};
|
std::vector<std::string> result = {};
|
||||||
for (auto& block : ((GMLIB_ItemStack*)item)->getCanDestroy()) {
|
for (auto& block : ((world::ItemStack*)item)->getCanDestroy()) {
|
||||||
result.push_back(block->getTypeName());
|
result.push_back(block->getTypeName());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -817,13 +826,13 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setItemCanDestroy",
|
"setItemCanDestroy",
|
||||||
[](ItemStack const* item, std::vector<std::string> blocks) -> void {
|
[](::ItemStack const* item, std::vector<std::string> blocks) -> void {
|
||||||
((GMLIB_ItemStack*)item)->setCanDestroy(blocks);
|
((world::ItemStack*)item)->setCanDestroy(blocks);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemCanPlaceOn", [](ItemStack const* item) -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getItemCanPlaceOn", [](::ItemStack const* item) -> std::vector<std::string> {
|
||||||
std::vector<std::string> result = {};
|
std::vector<std::string> result = {};
|
||||||
for (auto& block : ((GMLIB_ItemStack*)item)->getCanPlaceOn()) {
|
for (auto& block : ((world::ItemStack*)item)->getCanPlaceOn()) {
|
||||||
result.push_back(block->getTypeName());
|
result.push_back(block->getTypeName());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -831,47 +840,51 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setItemCanPlaceOn",
|
"setItemCanPlaceOn",
|
||||||
[](ItemStack const* item, std::vector<std::string> blocks) -> void {
|
[](::ItemStack const* item, std::vector<std::string> blocks) -> void {
|
||||||
((GMLIB_ItemStack*)item)->setCanPlaceOn(blocks);
|
((world::ItemStack*)item)->setCanPlaceOn(blocks);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerHungry", [](Player* player) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerHungry", [](::Player* player) -> float {
|
||||||
return player->getMutableAttribute(Player::HUNGER)->getCurrentValue();
|
return player->getMutableAttribute(::Player::HUNGER)->getCurrentValue();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerArmorCoverPercentage", [](Player* player) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerArmorCoverPercentage", [](::Player* player) -> float {
|
||||||
return player->getArmorCoverPercentage();
|
return player->getArmorCoverPercentage();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerArmorValue", [](Player* player) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerArmorValue", [](::Player* player) -> int {
|
||||||
return player->getArmorValue();
|
return player->getArmorValue();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityOwnerUniqueId", [](Actor* entity) -> int64 {
|
RemoteCall::exportAs("GMLIB_API", "getEntityOwnerUniqueId", [](::Actor* entity) -> int64 {
|
||||||
return entity->getOwnerId().id;
|
return entity->getOwnerId().id;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](ItemStack const* item) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](::ItemStack const* item) -> std::string {
|
||||||
return item->getCategoryName();
|
return item->getCategoryName();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemCustomName", [](ItemStack const* item) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getItemCustomName", [](::ItemStack const* item) -> std::string {
|
||||||
return item->getCustomName();
|
return item->getCustomName();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemEffecName", [](ItemStack const* item) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getItemEffecName", [](::ItemStack const* item) -> std::string {
|
||||||
return item->getEffectName();
|
return item->getEffectName();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "itemIsFood", [](ItemStack const* item) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "itemIsFood", [](::ItemStack const* item) -> bool {
|
||||||
if (auto itemDef = item->getItem()) {
|
if (auto itemDef = item->getItem()) {
|
||||||
return itemDef->isFood();
|
return itemDef->isFood();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerUIItem", [](Player* player, int slot, ItemStack const* item) -> void {
|
RemoteCall::exportAs(
|
||||||
player->setPlayerUIItem((PlayerUISlot)slot, *item);
|
"GMLIB_API",
|
||||||
});
|
"setPlayerUIItem",
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerUIItem", [](Player* player, int slot) -> ItemStack* {
|
[](::Player* player, int slot, ::ItemStack const* item) -> void {
|
||||||
return const_cast<ItemStack*>(&player->getPlayerUIItem((PlayerUISlot)slot));
|
player->setPlayerUIItem((PlayerUISlot)slot, *item);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerUIItem", [](::Player* player, int slot) -> ::ItemStack* {
|
||||||
|
return const_cast<::ItemStack*>(&player->getPlayerUIItem((PlayerUISlot)slot));
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"sendInventorySlotPacket",
|
"sendInventorySlotPacket",
|
||||||
[](Player* player, int containerId, int slot, ItemStack const* item) -> void {
|
[](::Player* player, int containerId, int slot, ::ItemStack const* item) -> void {
|
||||||
InventorySlotPacket((ContainerID)containerId, slot, *item).sendTo(*player);
|
InventorySlotPacket((ContainerID)containerId, slot, *item).sendTo(*player);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -880,60 +893,62 @@ void Export_Compatibility_API() {
|
|||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::getPlayerNbt(uid) ? true : false;
|
return world::Player::getPlayerNbt(uid) ? true : false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](::ItemStack const* item) -> int {
|
||||||
return item->getMaxStackSize();
|
return item->getMaxStackSize();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "entityHasFamily", [](Actor* entity, std::string const& family) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "entityHasFamily", [](::Actor* entity, std::string const& family) -> bool {
|
||||||
return entity->hasFamily(HashedString(family));
|
return entity->hasFamily(HashedString(family));
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerDestroyBlockProgress", [](Player* player, Block const* block) -> float {
|
RemoteCall::exportAs(
|
||||||
return player->getDestroyProgress(*block);
|
"GMLIB_API",
|
||||||
});
|
"getPlayerDestroyBlockProgress",
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectVisible", [](Actor* entity, int effectId) -> bool {
|
[](::Player* player, Block const* block) -> float { return player->getDestroyProgress(*block); }
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectVisible", [](::Actor* entity, int effectId) -> bool {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mEffectVisible;
|
return effect->mEffectVisible;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDuration", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDuration", [](::Actor* entity, int effectId) -> int {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mDuration;
|
return effect->mDuration;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationEasy", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationEasy", [](::Actor* entity, int effectId) -> int {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mDurationEasy;
|
return effect->mDurationEasy;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationHard", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationHard", [](::Actor* entity, int effectId) -> int {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mDurationHard;
|
return effect->mDurationHard;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationNormal", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationNormal", [](::Actor* entity, int effectId) -> int {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mDurationNormal;
|
return effect->mDurationNormal;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmplifier", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmplifier", [](::Actor* entity, int effectId) -> int {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mAmplifier;
|
return effect->mAmplifier;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmbient", [](Actor* entity, int effectId) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmbient", [](::Actor* entity, int effectId) -> bool {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mAmbient;
|
return effect->mAmbient;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "entityHasEffect", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "entityHasEffect", [](::Actor* entity, int effectId) -> int {
|
||||||
return entity->hasEffect(*MobEffect::getById(effectId));
|
return entity->hasEffect(*MobEffect::getById(effectId));
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getGameDifficulty", []() -> int {
|
RemoteCall::exportAs("GMLIB_API", "getGameDifficulty", []() -> int {
|
||||||
@@ -961,8 +976,8 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"registerCustomShapelessRecipe",
|
"registerCustomShapelessRecipe",
|
||||||
[](std::string const& recipe_id, std::vector<std::string> ingredients, ItemStack* result) -> void {
|
[](std::string const& recipe_id, std::vector<std::string> ingredients, ::ItemStack* result) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -973,7 +988,7 @@ void Export_Compatibility_API() {
|
|||||||
types.push_back(key);
|
types.push_back(key);
|
||||||
rt++;
|
rt++;
|
||||||
}
|
}
|
||||||
CustomRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, *result);
|
recipe::RecipeRegistry::registerShapelessCraftingTableRecipe(recipe_id, types, *result);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -982,8 +997,8 @@ void Export_Compatibility_API() {
|
|||||||
[](std::string const& recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::vector<std::string> shape,
|
std::vector<std::string> shape,
|
||||||
std::vector<std::string> ingredients,
|
std::vector<std::string> ingredients,
|
||||||
ItemStack* result) -> void {
|
::ItemStack* result) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -994,7 +1009,7 @@ void Export_Compatibility_API() {
|
|||||||
types.push_back(key);
|
types.push_back(key);
|
||||||
rt++;
|
rt++;
|
||||||
}
|
}
|
||||||
CustomRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, *result);
|
recipe::RecipeRegistry::registerShapedCraftingTableRecipe(recipe_id, shape, types, *result);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+2
-2
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
ll::Logger logger(PLUGIN_NAME);
|
ll::Logger logger(PLUGIN_NAME);
|
||||||
|
|
||||||
namespace GMLIB {
|
namespace gmlib {
|
||||||
|
|
||||||
std::unique_ptr<LegacyRemoteCallApi>& LegacyRemoteCallApi::getInstance() {
|
std::unique_ptr<LegacyRemoteCallApi>& LegacyRemoteCallApi::getInstance() {
|
||||||
static std::unique_ptr<LegacyRemoteCallApi> instance;
|
static std::unique_ptr<LegacyRemoteCallApi> instance;
|
||||||
@@ -32,6 +32,6 @@ bool LegacyRemoteCallApi::enable() { return true; }
|
|||||||
|
|
||||||
bool LegacyRemoteCallApi::disable() { return true; }
|
bool LegacyRemoteCallApi::disable() { return true; }
|
||||||
|
|
||||||
} // namespace GMLIB
|
} // namespace gmlib
|
||||||
|
|
||||||
LL_REGISTER_MOD(LegacyRemoteCallApi, LegacyRemoteCallApi::getInstance());
|
LL_REGISTER_MOD(LegacyRemoteCallApi, LegacyRemoteCallApi::getInstance());
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@
|
|||||||
#include <ll/api/mod/NativeMod.h>
|
#include <ll/api/mod/NativeMod.h>
|
||||||
#include <ll/api/mod/RegisterHelper.h>
|
#include <ll/api/mod/RegisterHelper.h>
|
||||||
|
|
||||||
namespace GMLIB {
|
namespace gmlib {
|
||||||
|
|
||||||
class LegacyRemoteCallApi {
|
class LegacyRemoteCallApi {
|
||||||
|
|
||||||
@@ -30,4 +30,4 @@ private:
|
|||||||
ll::mod::NativeMod& mSelf;
|
ll::mod::NativeMod& mSelf;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GMLIB
|
} // namespace gmlib
|
||||||
|
|||||||
+36
-34
@@ -1,4 +1,6 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "ll/api/event/EventBus.h"
|
||||||
|
#include "mc/world/inventory/network/ItemStackRequestActionTransferBase.h"
|
||||||
using namespace ll::hash_utils;
|
using namespace ll::hash_utils;
|
||||||
|
|
||||||
class LegacyScriptEventManager {
|
class LegacyScriptEventManager {
|
||||||
@@ -63,7 +65,7 @@ void Export_Event_API() {
|
|||||||
switch (doHash(eventName)) {
|
switch (doHash(eventName)) {
|
||||||
case doHash("onClientLogin"): {
|
case doHash("onClientLogin"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::PacketEvent::ClientLoginAfterEvent,
|
gmlib::event::packet::ClientLoginAfterEvent,
|
||||||
(std::string const& realName,
|
(std::string const& realName,
|
||||||
std::string const& uuid,
|
std::string const& uuid,
|
||||||
std::string const& serverXuid,
|
std::string const& serverXuid,
|
||||||
@@ -74,7 +76,7 @@ void Export_Event_API() {
|
|||||||
}
|
}
|
||||||
case doHash("onWeatherChange"): {
|
case doHash("onWeatherChange"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::LevelEvent::WeatherUpdateBeforeEvent,
|
gmlib::event::level::WeatherUpdateBeforeEvent,
|
||||||
(int lightningLevel, int rainLevel, int lightningLast, int rainLast),
|
(int lightningLevel, int rainLevel, int lightningLast, int rainLast),
|
||||||
(ev.getLightningLevel(), ev.getRainLevel(), ev.getLightningLastTick(), ev.getRainingLastTick()),
|
(ev.getLightningLevel(), ev.getRainLevel(), ev.getLightningLastTick(), ev.getRainingLastTick()),
|
||||||
ev.cancel(),
|
ev.cancel(),
|
||||||
@@ -82,16 +84,16 @@ void Export_Event_API() {
|
|||||||
}
|
}
|
||||||
case doHash("onMobPick"): {
|
case doHash("onMobPick"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::MobPickupItemBeforeEvent,
|
gmlib::event::entity::MobPickupItemBeforeEvent,
|
||||||
(Actor * mob, Actor * item),
|
(::Actor * mob, ::Actor * item),
|
||||||
(&ev.self(), (Actor*)&ev.getItemActor()),
|
(&ev.self(), (::Actor*)&ev.getItemActor()),
|
||||||
ev.cancel(),
|
ev.cancel(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("onItemTrySpawn"): {
|
case doHash("onItemTrySpawn"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::ItemActorSpawnBeforeEvent,
|
gmlib::event::entity::ItemActorSpawnBeforeEvent,
|
||||||
(const ItemStack* item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
(const ::ItemStack* item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||||
(&ev.getItem(),
|
(&ev.getItem(),
|
||||||
{ev.getPosition(), ev.getBlockSource().getDimensionId().id},
|
{ev.getPosition(), ev.getBlockSource().getDimensionId().id},
|
||||||
ev.getSpawner().has_value() ? ev.getSpawner()->getOrCreateUniqueID().id : -1),
|
ev.getSpawner().has_value() ? ev.getSpawner()->getOrCreateUniqueID().id : -1),
|
||||||
@@ -100,10 +102,10 @@ void Export_Event_API() {
|
|||||||
}
|
}
|
||||||
case doHash("onItemSpawned"): {
|
case doHash("onItemSpawned"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::ItemActorSpawnAfterEvent,
|
gmlib::event::entity::ItemActorSpawnAfterEvent,
|
||||||
(const ItemStack* item, Actor* itemActor, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
(const ::ItemStack* item, ::Actor* itemActor, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||||
(&ev.getItem(),
|
(&ev.getItem(),
|
||||||
(Actor*)&ev.getItemActor(),
|
(::Actor*)&ev.getItemActor(),
|
||||||
{ev.getPosition(), ev.getBlockSource().getDimensionId().id},
|
{ev.getPosition(), ev.getBlockSource().getDimensionId().id},
|
||||||
ev.getSpawner().has_value() ? ev.getSpawner()->getOrCreateUniqueID().id : -1),
|
ev.getSpawner().has_value() ? ev.getSpawner()->getOrCreateUniqueID().id : -1),
|
||||||
logger.error("Event \"onItemSpawned\" cannot be intercepted"),
|
logger.error("Event \"onItemSpawned\" cannot be intercepted"),
|
||||||
@@ -111,36 +113,36 @@ void Export_Event_API() {
|
|||||||
}
|
}
|
||||||
case doHash("onEntityTryChangeDim"): {
|
case doHash("onEntityTryChangeDim"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::ActorChangeDimensionBeforeEvent,
|
gmlib::event::entity::ActorChangeDimensionBeforeEvent,
|
||||||
(Actor * entity, int toDimId),
|
(::Actor * entity, int toDimId),
|
||||||
(&ev.self(), ev.getToDimensionId()),
|
(&ev.self(), ev.getToDimensionId()),
|
||||||
ev.cancel(),
|
ev.cancel(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("onLeaveBed"): {
|
case doHash("onLeaveBed"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
gmlib::event::player::PlayerStopSleepBeforeEvent,
|
||||||
(Player * pl),
|
(::Player * pl),
|
||||||
(&ev.self()),
|
(&ev.self()),
|
||||||
ev.cancel(),
|
ev.cancel(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("onDeathMessage"): {
|
case doHash("onDeathMessage"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::DeathMessageAfterEvent,
|
gmlib::event::entity::DeathMessageAfterEvent,
|
||||||
(std::string const& message, std::vector<std::string>, Actor* dead),
|
(std::string const& message, std::vector<std::string>, ::Actor* dead),
|
||||||
(ev.getDeathMessage().first, ev.getDeathMessage().second, &ev.self()),
|
(ev.getDeathMessage().first, ev.getDeathMessage().second, &ev.self()),
|
||||||
logger.error("Event \"onDeathMessage\" cannot be intercepted"),
|
logger.error("Event \"onDeathMessage\" cannot be intercepted"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("onMobHurted"): {
|
case doHash("onMobHurted"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::MobHurtAfterEvent,
|
gmlib::event::entity::MobHurtAfterEvent,
|
||||||
(Actor * mob, Actor * source, float damage, int cause),
|
(::Actor * mob, ::Actor * source, float damage, int cause),
|
||||||
(&ev.self(), source, ev.getDamage(), (int)damageSource.getCause()),
|
(&ev.self(), source, ev.getDamage(), (int)damageSource.getCause()),
|
||||||
logger.error("Event \"onMobHurted\" cannot be intercepted"),
|
logger.error("Event \"onMobHurted\" cannot be intercepted"),
|
||||||
auto& damageSource = ev.getSource();
|
auto& damageSource = ev.getSource();
|
||||||
Actor* source = nullptr;
|
::Actor* source = nullptr;
|
||||||
if (damageSource.isEntitySource()) {
|
if (damageSource.isEntitySource()) {
|
||||||
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||||
source = ll::service::getLevel()->fetchEntity(uniqueId);
|
source = ll::service::getLevel()->fetchEntity(uniqueId);
|
||||||
@@ -150,23 +152,23 @@ void Export_Event_API() {
|
|||||||
}
|
}
|
||||||
case doHash("onEndermanTake"): {
|
case doHash("onEndermanTake"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::EndermanTakeBlockBeforeEvent,
|
gmlib::event::entity::EndermanTakeBlockBeforeEvent,
|
||||||
(Actor * mob),
|
(::Actor * mob),
|
||||||
(&ev.self()),
|
(&ev.self()),
|
||||||
ev.cancel(),
|
ev.cancel(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("onEntityChangeDim"): {
|
case doHash("onEntityChangeDim"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::ActorChangeDimensionAfterEvent,
|
gmlib::event::entity::ActorChangeDimensionAfterEvent,
|
||||||
(Actor * mob, int fromDimId),
|
(::Actor * mob, int fromDimId),
|
||||||
(&ev.self(), ev.getFromDimensionId()),
|
(&ev.self(), ev.getFromDimensionId()),
|
||||||
logger.error("Event \"onEntityChangeDim\" cannot be intercepted"),
|
logger.error("Event \"onEntityChangeDim\" cannot be intercepted"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("onDragonRespawn"): {
|
case doHash("onDragonRespawn"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::DragonRespawnBeforeEvent,
|
gmlib::event::entity::DragonRespawnBeforeEvent,
|
||||||
(int64 enderDragonUniqueID),
|
(int64 enderDragonUniqueID),
|
||||||
(ev.getEnderDragon().id),
|
(ev.getEnderDragon().id),
|
||||||
ev.cancel(),
|
ev.cancel(),
|
||||||
@@ -174,38 +176,38 @@ void Export_Event_API() {
|
|||||||
}
|
}
|
||||||
case doHash("onProjectileTryCreate"): {
|
case doHash("onProjectileTryCreate"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::ProjectileCreateBeforeEvent,
|
gmlib::event::entity::ProjectileCreateBeforeEvent,
|
||||||
(Actor * mob, int64 uniqueId),
|
(::Actor * mob, int64 uniqueId),
|
||||||
(&ev.self(), ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1),
|
(&ev.self(), ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1),
|
||||||
ev.cancel(),
|
ev.cancel(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("onProjectileCreate"): {
|
case doHash("onProjectileCreate"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::ProjectileCreateAfterEvent,
|
gmlib::event::entity::ProjectileCreateAfterEvent,
|
||||||
(Actor * mob, int64 uniqueId),
|
(::Actor * mob, int64 uniqueId),
|
||||||
(&ev.self(), ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1),
|
(&ev.self(), ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1),
|
||||||
logger.error("Event \"onProjectileCreate\" cannot be intercepted"),
|
logger.error("Event \"onProjectileCreate\" cannot be intercepted"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("onSpawnWanderingTrader"): {
|
case doHash("onSpawnWanderingTrader"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::EntityEvent::SpawnWanderingTraderBeforeEvent,
|
gmlib::event::entity::SpawnWanderingTraderBeforeEvent,
|
||||||
(std::pair<BlockPos, int> pos),
|
(std::pair<BlockPos, int> pos),
|
||||||
({ev.getPos(), ev.getRegion().getDimensionId()}),
|
({ev.getPos(), ev.getRegion().getDimensionId()}),
|
||||||
ev.cancel(),
|
ev.cancel(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("onHandleRequestAction"): {
|
case doHash("onHandleRequestAction"): {
|
||||||
REGISTER_EVENT_LISTEN(Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
REGISTER_EVENT_LISTEN(gmlib::event::player::HandleRequestActionBeforeEvent,
|
||||||
(Player * player,
|
(::Player * player,
|
||||||
std::string const& actionType,
|
std::string const& actionType,
|
||||||
int count,
|
int count,
|
||||||
std::string const& sourceContainerNetId,
|
std::string const& sourceContainerNetId,
|
||||||
int sourceSlot,
|
int sourceSlot,
|
||||||
std::string const& destinationContainerNetId,
|
std::string const& destinationContainerNetId,
|
||||||
int destinationSlot),
|
int destinationSlot),
|
||||||
((Player*)&ev.self(),
|
((::Player*)&ev.self(),
|
||||||
magic_enum::enum_name(requestAction->mActionType).data(),
|
magic_enum::enum_name(requestAction->mActionType).data(),
|
||||||
(int)requestAction->mAmount,
|
(int)requestAction->mAmount,
|
||||||
magic_enum::enum_name(requestAction->mSrc.mOpenContainerNetId).data(),
|
magic_enum::enum_name(requestAction->mSrc.mOpenContainerNetId).data(),
|
||||||
@@ -218,8 +220,8 @@ void Export_Event_API() {
|
|||||||
}
|
}
|
||||||
case doHash("onSendContainerClosePacket"): {
|
case doHash("onSendContainerClosePacket"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
event::packet::ContainerClosePacketSendAfterEvent,
|
||||||
(Player * player, int ContainerNetId),
|
(::Player * player, int ContainerNetId),
|
||||||
(ev.getServerNetworkHandler()
|
(ev.getServerNetworkHandler()
|
||||||
.getServerPlayer(ev.getNetworkIdentifier(), ev.getPacket().mClientSubId),
|
.getServerPlayer(ev.getNetworkIdentifier(), ev.getPacket().mClientSubId),
|
||||||
(int)ev.getPacket().mContainerId),
|
(int)ev.getPacket().mContainerId),
|
||||||
|
|||||||
+66
-33
@@ -1,8 +1,7 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "gmlib/world/Player.h"
|
||||||
|
|
||||||
#include <GMLIB/Server/FormAPI/ChestForm.h>
|
using namespace gmlib::form;
|
||||||
|
|
||||||
using namespace GMLIB::Server::Form;
|
|
||||||
using namespace ll::hash_utils;
|
using namespace ll::hash_utils;
|
||||||
|
|
||||||
class LegacyScriptFormManager {
|
class LegacyScriptFormManager {
|
||||||
@@ -10,7 +9,7 @@ private:
|
|||||||
int64 mNextFormCallbackId = 0;
|
int64 mNextFormCallbackId = 0;
|
||||||
int64 mNextFormId = 0;
|
int64 mNextFormId = 0;
|
||||||
std::unordered_map<int64, std::unique_ptr<NpcDialogueForm>> mNpcDialogueForms;
|
std::unordered_map<int64, std::unique_ptr<NpcDialogueForm>> mNpcDialogueForms;
|
||||||
std::unordered_map<int64, std::unique_ptr<ChestForm>> mChestForms;
|
// std::unordered_map<int64, std::unique_ptr<ChestForm>> mChestForms;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string getNextFormCallbackId() {
|
std::string getNextFormCallbackId() {
|
||||||
@@ -45,6 +44,30 @@ public:
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
int64 createChestForm(std::string const& npcName, std::string const& sceneName, std::string const& dialogue) {
|
||||||
|
auto formId = LegacyScriptFormManager::getInstance().getNextFormId();
|
||||||
|
auto formPtr = std::make_unique<ChestForm>(npcName, sceneName, dialogue);
|
||||||
|
mChestForms[formId] = std::move(formPtr);
|
||||||
|
return formId;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool destroyChestForm(int64 formId) {
|
||||||
|
if (mChestForms.contains(formId)) {
|
||||||
|
mChestForms.erase(formId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
optional_ref<ChestForm> getChestForm(int64 formId) {
|
||||||
|
if (mChestForms.contains(formId)) {
|
||||||
|
return mChestForms[formId].get();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
public:
|
public:
|
||||||
static LegacyScriptFormManager& getInstance() {
|
static LegacyScriptFormManager& getInstance() {
|
||||||
static std::unique_ptr<LegacyScriptFormManager> instance;
|
static std::unique_ptr<LegacyScriptFormManager> instance;
|
||||||
@@ -56,10 +79,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define PLAYER_DETECROR \
|
#define PLAYER_DETECROR \
|
||||||
[detectorId, result](Player& pl) -> bool { \
|
[detectorId, result](::Player& pl) -> bool { \
|
||||||
try { \
|
try { \
|
||||||
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", detectorId)) { \
|
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", detectorId)) { \
|
||||||
auto const& detector = RemoteCall::importAs<bool(Player*)>("GMLIB_FORM_CALLBACK", detectorId); \
|
auto const& detector = RemoteCall::importAs<bool(::Player*)>("GMLIB_FORM_CALLBACK", detectorId); \
|
||||||
return detector(&pl); \
|
return detector(&pl); \
|
||||||
} else { \
|
} else { \
|
||||||
ServerSettingForm::removeElement(result); \
|
ServerSettingForm::removeElement(result); \
|
||||||
@@ -69,11 +92,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CALLBACK_TYPE_STRING \
|
#define CALLBACK_TYPE_STRING \
|
||||||
[callbackId, result](Player& pl, std::string const& data) { \
|
[callbackId, result](::Player& pl, std::string const& data) { \
|
||||||
try { \
|
try { \
|
||||||
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||||
auto const& callback = \
|
auto const& callback = \
|
||||||
RemoteCall::importAs<void(Player*, std::string const&)>("GMLIB_FORM_CALLBACK", callbackId); \
|
RemoteCall::importAs<void(::Player*, std::string const&)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||||
callback(&pl, data); \
|
callback(&pl, data); \
|
||||||
} else { \
|
} else { \
|
||||||
ServerSettingForm::removeElement(result); \
|
ServerSettingForm::removeElement(result); \
|
||||||
@@ -82,10 +105,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CALLBACK_TYPE_BOOL \
|
#define CALLBACK_TYPE_BOOL \
|
||||||
[callbackId, result](Player& pl, bool data) { \
|
[callbackId, result](::Player& pl, bool data) { \
|
||||||
try { \
|
try { \
|
||||||
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||||
auto const& callback = RemoteCall::importAs<void(Player*, bool)>("GMLIB_FORM_CALLBACK", callbackId); \
|
auto const& callback = RemoteCall::importAs<void(::Player*, bool)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||||
callback(&pl, data); \
|
callback(&pl, data); \
|
||||||
} else { \
|
} else { \
|
||||||
ServerSettingForm::removeElement(result); \
|
ServerSettingForm::removeElement(result); \
|
||||||
@@ -94,10 +117,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CALLBACK_TYPE_DOUBLE \
|
#define CALLBACK_TYPE_DOUBLE \
|
||||||
[callbackId, result](Player& pl, double data) { \
|
[callbackId, result](::Player& pl, double data) { \
|
||||||
try { \
|
try { \
|
||||||
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||||
auto const& callback = RemoteCall::importAs<void(Player*, double)>("GMLIB_FORM_CALLBACK", callbackId); \
|
auto const& callback = \
|
||||||
|
RemoteCall::importAs<void(::Player*, double)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||||
callback(&pl, data); \
|
callback(&pl, data); \
|
||||||
} else { \
|
} else { \
|
||||||
ServerSettingForm::removeElement(result); \
|
ServerSettingForm::removeElement(result); \
|
||||||
@@ -107,10 +131,11 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
#define CALLBACK_TYPE_LONG \
|
#define CALLBACK_TYPE_LONG \
|
||||||
[callbackId, result](Player& pl, int64 data) { \
|
[callbackId, result](::Player& pl, int64 data) { \
|
||||||
try { \
|
try { \
|
||||||
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||||
auto const& callback = RemoteCall::importAs<void(Player*, int64)>("GMLIB_FORM_CALLBACK", callbackId); \
|
auto const& callback = \
|
||||||
|
RemoteCall::importAs<void(::Player*, int64)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||||
callback(&pl, data); \
|
callback(&pl, data); \
|
||||||
} else { \
|
} else { \
|
||||||
ServerSettingForm::removeElement(result); \
|
ServerSettingForm::removeElement(result); \
|
||||||
@@ -118,6 +143,16 @@ public:
|
|||||||
} catch (...) {} \
|
} catch (...) {} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CALLBACK_TYPE_NORMAL \
|
||||||
|
[callbackId](::Player& pl) { \
|
||||||
|
try { \
|
||||||
|
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||||
|
auto const& callback = RemoteCall::importAs<void(::Player*)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||||
|
callback(&pl); \
|
||||||
|
} \
|
||||||
|
} catch (...) {} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Export_Form_API() {
|
void Export_Form_API() {
|
||||||
//////////////////////////////// Form Manager /////////////////////////////////
|
//////////////////////////////// Form Manager /////////////////////////////////
|
||||||
@@ -273,30 +308,28 @@ void Export_Form_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_NpcDialogueForm", "destroyForm", [](int64 formId) -> bool {
|
RemoteCall::exportAs("GMLIB_NpcDialogueForm", "destroyForm", [](int64 formId) -> bool {
|
||||||
return LegacyScriptFormManager::getInstance().destroyNpcDialogueForm(formId);
|
return LegacyScriptFormManager::getInstance().destroyNpcDialogueForm(formId);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_NpcDialogueForm", "addButton", [](int64 formId, std::string const& button) -> int {
|
|
||||||
if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
|
||||||
return formPtr->addButton(button);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_NpcDialogueForm",
|
"GMLIB_NpcDialogueForm",
|
||||||
"sendTo",
|
"addButton",
|
||||||
[](int64 formId, Player* pl, std::string const& callbackId) -> void {
|
[](int64 formId, std::string const& button, std::string const& callbackId) -> void {
|
||||||
if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
||||||
formPtr->sendTo(*pl, [callbackId](Player& pl, int index, NpcRequestPacket::RequestType type) -> void {
|
formPtr->addButton(button, CALLBACK_TYPE_NORMAL);
|
||||||
try {
|
|
||||||
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) {
|
|
||||||
auto const& callback = RemoteCall::importAs<void(Player*, int index, int type)>(
|
|
||||||
"GMLIB_FORM_CALLBACK",
|
|
||||||
callbackId
|
|
||||||
);
|
|
||||||
callback(&pl, index, (int)type);
|
|
||||||
}
|
|
||||||
} catch (...) {}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_NpcDialogueForm",
|
||||||
|
"onPlayerClose",
|
||||||
|
[](int64 formId, std::string const& callbackId) -> void {
|
||||||
|
if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
||||||
|
formPtr->onPlayerClose(CALLBACK_TYPE_NORMAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_NpcDialogueForm", "sendTo", [](int64 formId, ::Player* pl) -> void {
|
||||||
|
if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
||||||
|
formPtr->sendTo(*pl);
|
||||||
|
}
|
||||||
|
});
|
||||||
////////////////////////////// ChestForm //////////////////////////////
|
////////////////////////////// ChestForm //////////////////////////////
|
||||||
}
|
}
|
||||||
+6
-6
@@ -1,17 +1,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <include_all.h>
|
|
||||||
|
|
||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
#include <headers/include_all.h>
|
||||||
|
|
||||||
using namespace GMLIB;
|
using namespace gmlib;
|
||||||
using namespace Server;
|
using namespace world;
|
||||||
using namespace Mod;
|
using namespace mod;
|
||||||
|
using namespace tools;
|
||||||
|
|
||||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||||
|
|
||||||
#define LIB_VERSION_MAJOR 0
|
#define LIB_VERSION_MAJOR 0
|
||||||
#define LIB_VERSION_MINOR 13
|
#define LIB_VERSION_MINOR 13
|
||||||
#define LIB_VERSION_PATCH 3
|
#define LIB_VERSION_PATCH 4
|
||||||
|
|
||||||
#define LIB_VERSION Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
#define LIB_VERSION Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||||
|
|
||||||
|
|||||||
+24
-24
@@ -22,7 +22,7 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string const& unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
}
|
}
|
||||||
auto res = RecipeIngredient(result, 0, count);
|
auto res = RecipeIngredient(result, 0, count);
|
||||||
auto unl = makeRecipeUnlockingKey(unlock);
|
auto unl = makeRecipeUnlockingKey(unlock);
|
||||||
JsonRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
|
recipe::JsonRecipeRegistry::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -45,7 +45,7 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string const& unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
}
|
}
|
||||||
auto res = RecipeIngredient(result, 0, count);
|
auto res = RecipeIngredient(result, 0, count);
|
||||||
auto unl = makeRecipeUnlockingKey(unlock);
|
auto unl = makeRecipeUnlockingKey(unlock);
|
||||||
JsonRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
|
recipe::JsonRecipeRegistry::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -66,13 +66,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& input,
|
std::string const& input,
|
||||||
std::string const& output,
|
std::string const& output,
|
||||||
std::vector<std::string> tags) -> void {
|
std::vector<std::string> tags) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
auto inp = RecipeIngredient(input, 0, 1);
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
auto outp = RecipeIngredient(output, 0, 1);
|
||||||
JsonRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags);
|
recipe::JsonRecipeRegistry::registerFurnaceRecipe(recipe_id, inp, outp, tags);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -80,12 +80,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
"registerBrewingMixRecipe",
|
"registerBrewingMixRecipe",
|
||||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
) -> void {
|
) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
auto rea = RecipeIngredient(reagent, 0, 1);
|
||||||
JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea);
|
recipe::JsonRecipeRegistry::registerBrewingMixRecipe(recipe_id, input, output, rea);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -93,14 +93,14 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
"registerBrewingContainerRecipe",
|
"registerBrewingContainerRecipe",
|
||||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
) -> void {
|
) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
auto inp = RecipeIngredient(input, 0, 1);
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
auto outp = RecipeIngredient(output, 0, 1);
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
auto rea = RecipeIngredient(reagent, 0, 1);
|
||||||
JsonRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
|
recipe::JsonRecipeRegistry::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -111,11 +111,11 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& base,
|
std::string const& base,
|
||||||
std::string const& addition,
|
std::string const& addition,
|
||||||
std::string const& result) -> void {
|
std::string const& result) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JsonRecipe::registerSmithingTransformRecipe(recipe_id, smithing_template, base, addition, result);
|
recipe::JsonRecipeRegistry::registerSmithingTransformRecipe(recipe_id, smithing_template, base, addition, result);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -125,11 +125,11 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& smithing_template,
|
std::string const& smithing_template,
|
||||||
std::string const& base,
|
std::string const& base,
|
||||||
std::string const& addition) -> void {
|
std::string const& addition) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
recipe::JsonRecipeRegistry::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -141,13 +141,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& output,
|
std::string const& output,
|
||||||
int output_data,
|
int output_data,
|
||||||
int output_count) -> void {
|
int output_count) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = world::Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
auto inp = RecipeIngredient(input, 0, 1);
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
auto outp = RecipeIngredient(output, 0, 1);
|
||||||
JsonRecipe::registerStoneCutterRecipe(recipe_id, inp, outp);
|
recipe::JsonRecipeRegistry::registerStoneCutterRecipe(recipe_id, inp, outp);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// 错误方块清理
|
// 错误方块清理
|
||||||
@@ -156,29 +156,29 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
});
|
});
|
||||||
// 实验性
|
// 实验性
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||||
auto list = GMLIB_Level::getAllExperiments();
|
auto list = world::Level::getAllExperiments();
|
||||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
if (set.contains((AllExperiments)experiment_id)) {
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
world::Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||||
} else {
|
} else {
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (world::Level::getInstance()) {
|
||||||
auto list = GMLIB_Level::getAllExperiments();
|
auto list = world::Level::getAllExperiments();
|
||||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
if (set.contains((AllExperiments)experiment_id)) {
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
world::Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||||
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (world::Level::getInstance()) {
|
||||||
auto list = GMLIB_Level::getAllExperiments();
|
auto list = world::Level::getAllExperiments();
|
||||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
if (set.contains((AllExperiments)experiment_id)) {
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
return world::Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||||
} else {
|
} else {
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+19
-17
@@ -2,62 +2,64 @@
|
|||||||
|
|
||||||
void Export_Legacy_GMLib_ServerAPI() {
|
void Export_Legacy_GMLib_ServerAPI() {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||||
GMLIB_Level::tryEnableEducationEdition();
|
world::Level::tryEnableEducationEdition();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||||
GMLIB_Level::tryRegisterAbilityCommand();
|
world::Level::tryRegisterAbilityCommand();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||||
GMLIB_Level::setForceAchievementsEnabled();
|
world::Level::setForceAchievementsEnabled();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
|
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { world::Level::trustAllSkins(); });
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||||
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
world::Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
if (auto level = GMLIB_Level::getInstance()) {
|
if (auto level = world::Level::getInstance()) {
|
||||||
return level->getLevelName();
|
return level->getLevelName();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||||
if (auto level = GMLIB_Level::getInstance()) {
|
if (auto level = world::Level::getInstance()) {
|
||||||
level->setLevelName(name);
|
level->setLevelName(name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
||||||
if (auto level = GMLIB_Level::getInstance()) {
|
if (auto level = world::Level::getInstance()) {
|
||||||
return std::to_string(level->getSeed());
|
return std::to_string(level->getSeed());
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||||
return GMLIB_Level::setFakeSeed(seed);
|
return world::Level::setFakeSeed(seed);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"spawnEntity",
|
"spawnEntity",
|
||||||
[](std::pair<Vec3, int> pos, std::string const& name) -> Actor* {
|
[](std::pair<Vec3, int> pos, std::string const& name) -> ::Actor* {
|
||||||
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
return world::Spawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"shootProjectile",
|
"shootProjectile",
|
||||||
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
[](::Actor* owner, std::string const& name, float speed, float offset) -> ::Actor* {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto ac = (world::Actor*)owner;
|
||||||
return ac->shootProjectile(name, speed, offset).as_ptr();
|
return ac->shootProjectile(name, speed, offset).as_ptr();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"throwEntity",
|
"throwEntity",
|
||||||
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
[](::Actor* owner, ::Actor* actor, float speed, float offset) -> bool {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto ac = (world::Actor*)owner;
|
||||||
return ac->throwEntity(*actor, speed, offset);
|
return ac->throwEntity(*actor, speed, offset);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](::Player* player) -> ::Actor* {
|
||||||
|
return (::Actor*)player;
|
||||||
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"addFakeList",
|
"addFakeList",
|
||||||
@@ -72,7 +74,7 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
return FakeList::removeAllFakeLists();
|
return FakeList::removeAllFakeLists();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
||||||
if (auto level = GMLIB_Level::getInstance()) {
|
if (auto level = world::Level::getInstance()) {
|
||||||
return level->getMaxPlayerCount();
|
return level->getMaxPlayerCount();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ bool isParameters(std::string const& str) {
|
|||||||
|
|
||||||
std::string GetValue(std::string const& from) { return PlaceholderAPI::getValue(from); }
|
std::string GetValue(std::string const& from) { return PlaceholderAPI::getValue(from); }
|
||||||
|
|
||||||
std::string GetValueWithPlayer(std::string const& key, Player* player) { return PlaceholderAPI::getValue(key, player); }
|
std::string GetValueWithPlayer(std::string const& key, ::Player* player) { return PlaceholderAPI::getValue(key, player); }
|
||||||
|
|
||||||
bool registerPlayerPlaceholder(
|
bool registerPlayerPlaceholder(
|
||||||
std::string const& PluginName,
|
std::string const& PluginName,
|
||||||
@@ -25,18 +25,18 @@ bool registerPlayerPlaceholder(
|
|||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
if (isParameters(PAPIName)) {
|
if (isParameters(PAPIName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
auto Call = RemoteCall::importAs<std::string(::Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||||
PluginName,
|
PluginName,
|
||||||
FuncName
|
FuncName
|
||||||
);
|
);
|
||||||
PlaceholderAPI::registerPlayerPlaceholder(
|
PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
[Call](::Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string(::Player * pl)>(PluginName, FuncName);
|
||||||
PlaceholderAPI::registerPlayerPlaceholder(PAPIName, [Call](Player* sp) { return Call(sp); }, PluginName);
|
PlaceholderAPI::registerPlayerPlaceholder(PAPIName, [Call](::Player* sp) { return Call(sp); }, PluginName);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ bool registerStaticPlaceholder(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
std::string translateStringWithPlayer(std::string const& str, ::Player* pl) {
|
||||||
return PlaceholderAPI::translateString(str, pl);
|
return PlaceholderAPI::translateString(str, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user