From 05c5c6822c8f7befc2efe81e9ecec7a0d0f8ccd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E6=B2=90=E5=91=80?= <163636894+zimuya4153@users.noreply.github.com> Date: Tue, 28 May 2024 01:21:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=96=B9=E5=9D=97=E7=A1=AC=E5=BA=A6=E6=8E=A5=E5=8F=A3=E5=92=8C?= =?UTF-8?q?=E6=88=96=E7=A0=B4=E5=9D=8F=E6=96=B9=E5=9D=97=E9=80=9F=E5=BA=A6?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/GMLIB_API-JS.js | 12 +++++++++++- src/CompatibilityApi.cpp | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/GMLIB_API-JS.js b/lib/GMLIB_API-JS.js index 4596cd7..3a2fe29 100644 --- a/lib/GMLIB_API-JS.js +++ b/lib/GMLIB_API-JS.js @@ -115,7 +115,9 @@ const GMLIB_API = { getItemTranslateKey: ll.import("GMLIB_API", "getItemTranslateKey"), getEntityTranslateKey: ll.import("GMLIB_API", "getEntityTranslateKey"), readNbtFromFile: ll.import("GMLIB_API", "readNbtFromFile"), - saveNbtToFile: ll.import("GMLIB_API", "saveNbtToFile") + saveNbtToFile: ll.import("GMLIB_API", "saveNbtToFile"), + getBlockDestroySpeed : ll.import("GMLIB_API","getBlockDestroySpeed"), + getDestroyBlockSpeed : ll.import("GMLIB_API","getDestroyBlockSpeed") } const FloatingTextList = []; @@ -440,6 +442,14 @@ class Minecraft { static readNbtFromFile(path, isBinary = true) { return GMLIB_API.readNbtFromFile(path, isBinary); } + + static getBlockDestroySpeed(block) { + return GMLIB_API.getBlockDestroySpeed(block); + } + + static getDestroyBlockSpeed(item,block) { + return GMLIB_API.getDestroyBlockSpeed(item,block); + } } class Recipes { diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index 7eb2c3f..8cd63dd 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -1,4 +1,7 @@ #include "Global.h" +#include "RemoteCallAPI.h" +#include "mc/world/actor/Actor.h" +#include "mc/world/item/registry/ItemStack.h" #include bool isInteger(const std::string& str) { @@ -630,4 +633,10 @@ void Export_Compatibility_API() { return GMLIB_CompoundTag::saveToFile(path, *nbt, isBinary); } ); + RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float { + return block->getDestroySpeed(); + }); + RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item,Block const* block) -> float { + return item->getDestroySpeed(*block); + }); } \ No newline at end of file From f55e64254921f0b9fe224f67c1a81d43f068c364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E6=B2=90=E5=91=80?= <163636894+zimuya4153@users.noreply.github.com> Date: Tue, 28 May 2024 03:12:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99include?= =?UTF-8?q?=E5=92=8C=E4=BF=AE=E6=AD=A3=E6=8E=A5=E5=8F=A3=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/GMLIB_API-JS.js | 16 ++++++++-------- src/CompatibilityApi.cpp | 3 --- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/GMLIB_API-JS.js b/lib/GMLIB_API-JS.js index 3a2fe29..1b6df03 100644 --- a/lib/GMLIB_API-JS.js +++ b/lib/GMLIB_API-JS.js @@ -442,14 +442,6 @@ class Minecraft { static readNbtFromFile(path, isBinary = true) { return GMLIB_API.readNbtFromFile(path, isBinary); } - - static getBlockDestroySpeed(block) { - return GMLIB_API.getBlockDestroySpeed(block); - } - - static getDestroyBlockSpeed(item,block) { - return GMLIB_API.getDestroyBlockSpeed(item,block); - } } class Recipes { @@ -973,6 +965,14 @@ LLSE_Item.prototype.getTranslateName = function (language) { return I18nAPI.get(this.getTranslateKey(), [], language); } +LLSE_Block.prototype.getBlockDestroySpeed = function () { + return GMLIB_API.getBlockDestroySpeed(this); +} + +LLSE_Item.prototype.getDestroyBlockSpeed = function (block) { + return GMLIB_API.getDestroyBlockSpeed(this,block); +} + module.exports = { StaticFloatingText, DynamicFloatingText, diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index 8cd63dd..9ed1fe6 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -1,7 +1,4 @@ #include "Global.h" -#include "RemoteCallAPI.h" -#include "mc/world/actor/Actor.h" -#include "mc/world/item/registry/ItemStack.h" #include bool isInteger(const std::string& str) {