From 162df810e322d698946e1568e86dd95ae1e4fefb Mon Sep 17 00:00:00 2001 From: jess Date: Fri, 13 Sep 2024 19:07:49 +0100 Subject: [PATCH 1/2] implement get xp for next level --- .../java/org/figuramc/figura/lua/api/entity/PlayerAPI.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/src/main/java/org/figuramc/figura/lua/api/entity/PlayerAPI.java b/common/src/main/java/org/figuramc/figura/lua/api/entity/PlayerAPI.java index ccf1f3e2d..5fc8c1f40 100644 --- a/common/src/main/java/org/figuramc/figura/lua/api/entity/PlayerAPI.java +++ b/common/src/main/java/org/figuramc/figura/lua/api/entity/PlayerAPI.java @@ -77,6 +77,13 @@ public float getExperienceProgress() { return entity.experienceProgress; } + @LuaWhitelist + @LuaMethodDoc("player.get_xp_for_next_level") + public int getExperienceForNextLevel(){ + checkEntity(); + return entity.getXpNeededForNextLevel(); + } + @LuaWhitelist @LuaMethodDoc("player.get_experience_level") public int getExperienceLevel() { From 59fb1a78883baca5d7ef1298c322d628253fb58e Mon Sep 17 00:00:00 2001 From: jess Date: Fri, 13 Sep 2024 19:08:55 +0100 Subject: [PATCH 2/2] doc mentation --- common/src/main/resources/assets/figura/lang/en_us.json | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/main/resources/assets/figura/lang/en_us.json b/common/src/main/resources/assets/figura/lang/en_us.json index e4b27a47b..0a969fe33 100644 --- a/common/src/main/resources/assets/figura/lang/en_us.json +++ b/common/src/main/resources/assets/figura/lang/en_us.json @@ -1029,6 +1029,7 @@ "figura.docs.player.get_saturation": "Gets the current saturation level of the player", "figura.docs.player.get_exhaustion": "Gets the current exhaustion level of the player", "figura.docs.player.get_experience_progress": "Gets the progress of the way towards the player's next level, as a value from 0 to 1", + "player.get_xp_for_next_level": "Gets the amount of experience needed to level up", "figura.docs.player.get_experience_level": "Gets the player's current level", "figura.docs.player.get_model_type": "Returns \"SLIM\" or \"DEFAULT\", depending on the player's model type", "figura.docs.player.get_gamemode": "Returns \"SURVIVAL\", \"CREATIVE\", \"ADVENTURE\", or \"SPECTATOR\" depending on the player's gamemode\nIf the gamemode is unknown, returns nil",