Skip to content

Commit

Permalink
chore: update version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsubasa6848 committed Mar 25, 2024
1 parent 29ad4e1 commit e50c3ae
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 12 deletions.
19 changes: 17 additions & 2 deletions lib/GMLIB_API-JS.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const GMLIB_API = {
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
getResourcePackI18nLanguage: ll.import("GMLIB_API", "getResourcePackI18nLanguage"),
chooseResourcePackI18nLanguage: ll.import("GMLIB_API", "chooseResourcePackI18nLanguage"),
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"),
Expand All @@ -34,6 +35,7 @@ const GMLIB_API = {
getExperimentTranslatedName: ll.import("GMLIB_API", "getExperimentTranslatedName"),
getExperimentEnabled: ll.import("GMLib_ModAPI", "getExperimentEnabled"),
setExperimentEnabled: ll.import("GMLib_ModAPI", "setExperimentEnabled"),
unregisterRecipe: ll.import("GMLIB_API", "unregisterRecipe"),
registerExperimentsRequire: ll.import("GMLib_ModAPI", "registerExperimentsRequire"),
registerStoneCutterRecipe: ll.import("GMLib_ModAPI", "registerStoneCutterRecipe"),
registerSmithingTrimRecipe: ll.import("GMLib_ModAPI", "registerSmithingTrimRecipe"),
Expand Down Expand Up @@ -87,7 +89,8 @@ const GMLIB_API = {
setWorldSpawn: ll.import("GMLIB_API", "setWorldSpawn"),
getPlayerSpawnPoint: ll.import("GMLIB_API", "getPlayerSpawnPoint"),
setPlayerSpawnPoint: ll.import("GMLIB_API", "setPlayerSpawnPoint"),
clearPlayerSpawnPoint: ll.import("GMLIB_API", "clearPlayerSpawnPoint")
clearPlayerSpawnPoint: ll.import("GMLIB_API", "clearPlayerSpawnPoint"),
setCustomPackPath: ll.import("GMLIB_API", "setCustomPackPath")
}

const FloatingTextList = [];
Expand Down Expand Up @@ -380,10 +383,18 @@ class Minecraft {
return GMLIB_API.throwEntity(entity, proj, speed = 2, offset = 3);
}

static chooseResourcePackI18nLanguage(language) {
static getServerLanguage() {
return GMLIB_API.getResourcePackI18nLanguage(language);
}

static setServerLanguage(language) {
return GMLIB_API.chooseResourcePackI18nLanguage(language);
}

static setCustomPackPath(path) {
GMLIB_API.setCustomPackPath(path);
}

static resourcePackTranslate(key, params = []) {
return GMLIB_API.resourcePackTranslate(key, params);
}
Expand All @@ -394,6 +405,10 @@ class Recipes {
throw new Error("Static class cannot be instantiated");
}

static unregisterRecipe(recipeId) {
return GMLIB_API.unregisterRecipe(recipeId);
}

static registerStoneCutterRecipe(recipeId, inputName, inputAux, outputName, outputAux, outputCount) {
return GMLIB_API.registerStoneCutterRecipe(recipeId, inputName, inputAux, outputName, outputAux, outputCount);
}
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "${pluginName}",
"entry": "${pluginFile}",
"version": "0.9.4",
"version": "0.9.5",
"author": "GroupMountain",
"type": "native",
"dependencies": [
{
Expand Down
13 changes: 13 additions & 0 deletions src/CompatibilityApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
34 changes: 28 additions & 6 deletions src/EventAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions tooth.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"format_version": 2,
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
"version": "0.9.4",
"version": "0.9.5",
"info": {
"name": "GMLIB-LegacyRemoteCallApi",
"description": "Legacy RemoteCall API for GMLIB",
Expand All @@ -14,9 +14,9 @@
"library"
]
},
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.9.4/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.9.5/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
"dependencies": {
"github.com/GroupMountain/GMLIB": ">=0.9.6"
"github.com/GroupMountain/GMLIB": ">=0.9.8"
},
"files": {
"place": [
Expand Down

0 comments on commit e50c3ae

Please sign in to comment.