diff --git a/SDK-GMLIB b/SDK-GMLIB index 710cc6e..920b4e2 160000 --- a/SDK-GMLIB +++ b/SDK-GMLIB @@ -1 +1 @@ -Subproject commit 710cc6e4c3b0e85fd793fba807d8fffd6c4b607f +Subproject commit 920b4e243aa0961ee3c0ad011d8b5e249d8717ca diff --git a/lib/GMLIB_API-JS.js b/lib/GMLIB_API-JS.js index b14c966..56ff413 100644 --- a/lib/GMLIB_API-JS.js +++ b/lib/GMLIB_API-JS.js @@ -110,7 +110,12 @@ const GMLIB_API = { addFakeList: ll.import("GMLIB_API", "addFakeList"), removeFakeList: ll.import("GMLIB_API", "removeFakeList"), removeAllFakeLists: ll.import("GMLIB_API", "removeAllFakeList"), - setFixI18nEnabled: ll.import("GMLib_ModAPI", "setFixI18nEnabled") + setFixI18nEnabled: ll.import("GMLib_ModAPI", "setFixI18nEnabled"), + getBlockTranslateKey: ll.import("GMLIB_API", "getBlockTranslateKey"), + getItemTranslateKey: ll.import("GMLIB_API", "getItemTranslateKey"), + getEntityTranslateKey: ll.import("GMLIB_API", "getEntityTranslateKey"), + readNbtFromFile: ll.import("GMLIB_API", "readNbtFromFile"), + saveNbtToFile: ll.import("GMLIB_API", "saveNbtToFile") } const FloatingTextList = []; @@ -427,6 +432,14 @@ class Minecraft { static setFixI18nEnabled() { GMLIB_API.setFixI18nEnabled(); } + + static saveNbtToFile(path, nbt, isBinary = true) { + return GMLIB_API.saveNbtToFile(path, nbt, isBinary); + } + + static readNbtFromFile(path, isBinary = true) { + return GMLIB_API.readNbtFromFile(path, isBinary); + } } class Recipes { @@ -926,6 +939,30 @@ LLSE_Entity.prototype.throwEntity = function (proj, speed = 2, offset = 3) { return GMLIB_API.throwEntity(this, proj, speed, offset); } +LLSE_Entity.prototype.getTranslateKey = function () { + return GMLIB_API.getEntityTranslateKey(this); +} + +LLSE_Entity.prototype.getTranslateName = function (language) { + return I18nAPI.get(this.getTranslateKey(), [], language); +} + +LLSE_Block.prototype.getTranslateKey = function () { + return GMLIB_API.getBlockTranslateKey(this); +} + +LLSE_Block.prototype.getTranslateName = function (language) { + return I18nAPI.get(this.getTranslateKey(), [], language); +} + +LLSE_Item.prototype.getTranslateKey = function () { + return GMLIB_API.getItemTranslateKey(this); +} + +LLSE_Item.prototype.getTranslateName = function (language) { + return I18nAPI.get(this.getTranslateKey(), [], language); +} + module.exports = { StaticFloatingText, DynamicFloatingText, diff --git a/manifest.json b/manifest.json index bf503af..47a9296 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "${pluginName}", "entry": "${pluginFile}", - "version": "0.12.6", + "version": "0.12.7", "author": "GroupMountain", "type": "native", "dependencies": [ diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index 55da2b0..7eb2c3f 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -604,4 +604,30 @@ void Export_Compatibility_API() { } return 0; }); + RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string { + return block->buildDescriptionId(); + }); + RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string { + return item->getDescriptionId(); + }); + RemoteCall::exportAs("GMLIB_API", "getEntityTranslateKey", [](Actor* entity) -> std::string { + return entity->getEntityLocNameString(); + }); + RemoteCall::exportAs( + "GMLIB_API", + "readNbtFromFile", + [](std::string const& path, bool isBinary) -> std::unique_ptr { + if (auto nbt = GMLIB_CompoundTag::readFromFile(path, isBinary)) { + return std::make_unique(nbt.value()); + } + return nullptr; + } + ); + RemoteCall::exportAs( + "GMLIB_API", + "saveNbtToFile", + [](std::string const& path, CompoundTag* nbt, bool isBinary) -> bool { + return GMLIB_CompoundTag::saveToFile(path, *nbt, isBinary); + } + ); } \ No newline at end of file diff --git a/tooth.json b/tooth.json index 425e110..d5bba3e 100644 --- a/tooth.json +++ b/tooth.json @@ -1,7 +1,7 @@ { "format_version": 2, "tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi", - "version": "0.12.6", + "version": "0.12.7", "info": { "name": "GMLIB-LegacyRemoteCallApi", "description": "Legacy RemoteCall API for GMLIB", @@ -14,9 +14,9 @@ "library" ] }, - "asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.12.6/GMLIB-LegacyRemoteCallApi-windows-x64.zip", + "asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.12.7/GMLIB-LegacyRemoteCallApi-windows-x64.zip", "dependencies": { - "github.com/GroupMountain/GMLIB": ">=0.12.4" + "github.com/GroupMountain/GMLIB": ">=0.12.7" }, "files": { "place": [