chore: update version

This commit is contained in:
Tsubasa6848
2024-03-25 23:07:28 +08:00
Unverified
parent 29ad4e1f3e
commit e50c3aedce
5 changed files with 63 additions and 12 deletions
+13
View File
@@ -14,6 +14,16 @@ ActorUniqueID parseScriptUniqueID(std::string uniqueId) {
}
void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string id) -> bool {
auto level = GMLIB_Level::getInstance();
if (!level) {
return false;
}
return GMLIB::Mod::CustomRecipe::unregisterRecipe(id);
});
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string path) -> void {
GMLIB::Mod::CustomPacks::addCustomPackPath(path);
});
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
auto level = GMLIB_Level::getInstance();
if (!level) {
@@ -163,6 +173,9 @@ void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string code) -> void {
I18n::chooseLanguage(code);
});
RemoteCall::exportAs("GMLIB_API", "getResourcePackI18nLanguage", []() -> std::string {
return I18n::getCurrentLanguage()->getFullLanguageCode();
});
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string uuid) -> std::pair<BlockPos, int> {
auto uid = mce::UUID::fromString(uuid);
auto pos = GMLIB_Player::getPlayerPosition(uid);
+28 -6
View File
@@ -105,14 +105,13 @@ void Export_Event_API() {
);
return true;
}
case doHash("onTextSend"): {
auto Call = RemoteCall::importAs<bool(std::string author, std::string message)>(eventName, eventId);
eventBus->emplaceListener<GMLIB::Event::PacketEvent::TextPacketSendBeforeEvent>(
[Call](GMLIB::Event::PacketEvent::TextPacketSendBeforeEvent& ev) {
auto pkt = ev.getPacket();
case doHash("onEntityChangeDim"): {
auto Call = RemoteCall::importAs<bool(Actor * entity, int toDimId)>(eventName, eventId);
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent>(
[Call](GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent& ev) {
bool result = true;
try {
result = Call(pkt.mAuthor, pkt.mMessage);
result = Call(&ev.self(), ev.getToDimensionId());
} catch (...) {}
if (!result) {
ev.cancel();
@@ -152,6 +151,29 @@ void Export_Event_API() {
);
return true;
}
case doHash("onMobHurted"): {
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * source, float damage, int cause)>(
eventName,
eventId
);
eventBus->emplaceListener<GMLIB::Event::EntityEvent::MobHurtAfterEvent>(
[Call](GMLIB::Event::EntityEvent::MobHurtAfterEvent& ev) {
auto& damageSource = ev.getSource();
Actor* source = nullptr;
if (damageSource.isEntitySource()) {
auto uniqueId = damageSource.getDamagingEntityUniqueID();
source = ll::service::getLevel()->fetchEntity(uniqueId);
if (source->getOwner()) {
source = source->getOwner();
}
}
try {
Call(&ev.self(), source, ev.getDamage(), (int)damageSource.getCause());
} catch (...) {}
}
);
return true;
}
default:
return false;
}