diff --git a/common/src/main/java/org/figuramc/figura/animation/Animation.java b/common/src/main/java/org/figuramc/figura/animation/Animation.java index 895571eee..9041df9ac 100644 --- a/common/src/main/java/org/figuramc/figura/animation/Animation.java +++ b/common/src/main/java/org/figuramc/figura/animation/Animation.java @@ -103,8 +103,10 @@ else if (inverted && time < offset - loopDelay) } case HOLD -> { time = inverted ? Math.max(time, offset) : Math.min(time, length); - if (time == length) - playState = PlayState.HOLDING; + if (!inverted && time >= length) + playState = PlayState.HOLDING; + else if (inverted && time <= 0) + playState = PlayState.HOLDING; } } @@ -576,6 +578,10 @@ public Animation setSpeed(Float speed) { if (speed == null) speed = 1f; this.speed = speed; this.inverted = speed < 0; + if (inverted && this.time >= this.length && this.playState == PlayState.HOLDING) + this.playState = PlayState.PLAYING; + else if (!inverted && this.time <= 0 && this.playState == PlayState.HOLDING) + this.playState = PlayState.PLAYING; return this; } diff --git a/common/src/main/java/org/figuramc/figura/backend2/HttpAPI.java b/common/src/main/java/org/figuramc/figura/backend2/HttpAPI.java index 3e4f14279..f57dc7c8f 100644 --- a/common/src/main/java/org/figuramc/figura/backend2/HttpAPI.java +++ b/common/src/main/java/org/figuramc/figura/backend2/HttpAPI.java @@ -29,8 +29,18 @@ protected static URI getUri(String url) { } protected static String getBackendAddress() { + return "https://" + getBackendAddressWithPort() + "/api"; + } + + private static String getBackendAddressWithPort() { ServerAddress backendIP = ServerAddress.parseString(Configs.SERVER_IP.value); - return "https://" + backendIP.getHost() + "/api"; + boolean hasPort = Configs.SERVER_IP.value.matches("[^:]+:\\d+"); + if (hasPort) { + try { + return backendIP.getHost() + ":" + backendIP.getPort(); + } catch (IllegalStateException ignored) { } + } + return backendIP.getHost(); } protected HttpRequest.Builder header(String url) { diff --git a/common/src/main/java/org/figuramc/figura/backend2/websocket/FiguraWebSocketAdapter.java b/common/src/main/java/org/figuramc/figura/backend2/websocket/FiguraWebSocketAdapter.java index db69ece10..21153f380 100644 --- a/common/src/main/java/org/figuramc/figura/backend2/websocket/FiguraWebSocketAdapter.java +++ b/common/src/main/java/org/figuramc/figura/backend2/websocket/FiguraWebSocketAdapter.java @@ -55,8 +55,18 @@ public void onConnected(WebSocket websocket, Map> headers) } public static String getBackendAddress() { + return "wss://" + getBackendAddressWithPort() + "/ws"; + } + + private static String getBackendAddressWithPort() { ServerAddress backendIP = ServerAddress.parseString(Configs.SERVER_IP.value); - return "wss://" + backendIP.getHost() + "/ws"; + boolean hasPort = Configs.SERVER_IP.value.matches("[^:]+:\\d+"); + if (hasPort) { + try { + return backendIP.getHost() + ":" + backendIP.getPort(); + } catch (IllegalStateException ignored) { } + } + return backendIP.getHost(); } @Override diff --git a/common/src/main/java/org/figuramc/figura/lua/api/entity/EntityAPI.java b/common/src/main/java/org/figuramc/figura/lua/api/entity/EntityAPI.java index a2a820c8a..010d2b3b9 100644 --- a/common/src/main/java/org/figuramc/figura/lua/api/entity/EntityAPI.java +++ b/common/src/main/java/org/figuramc/figura/lua/api/entity/EntityAPI.java @@ -315,11 +315,20 @@ public boolean isCrouching() { } @LuaWhitelist - @LuaMethodDoc("entity.is_moving") - public boolean isMoving() { + @LuaMethodDoc( + overloads = { + @LuaMethodOverload, + @LuaMethodOverload( + argumentTypes = Boolean.class, + argumentNames = "ignoreY" + ) + }, + value = "entity.is_moving" + ) + public boolean isMoving(boolean ignoreY) { checkEntity(); return entity.getX() != entity.xOld - || entity.getY() != entity.yOld + || (ignoreY ? false : (entity.getY() != entity.yOld)) || entity.getZ() != entity.zOld; } 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 7b9f0d88a..9d40b937d 100644 --- a/common/src/main/resources/assets/figura/lang/en_us.json +++ b/common/src/main/resources/assets/figura/lang/en_us.json @@ -741,7 +741,7 @@ "figura.docs.wheel_action.set_toggled": "Sets the toggle state of the Action", "figura.docs.animations": "A global API used for control of Blockbench Animations", "figura.docs.animations.get_animations": "Returns a table with all animations", - "figura.docs.animations.get_playing": "Return a table with all playing animations\nIf true is passed in for hold animations in the HOLDING play state will be included", + "figura.docs.animations.get_playing": "Return a table with all playing animations\nTakes a boolean parameter, where if true, animations in the HOLDING play state will be included in the table", "figura.docs.animations.stop_all": "Stops all playing (and paused) animations", "figura.docs.animation": "A Blockbench animation", "figura.docs.animation.name": "This animation's name", @@ -977,7 +977,7 @@ "figura.docs.entity.is_silent": "Returns true if this entity is silent", "figura.docs.entity.is_sneaking": "Returns true if this entity is logically sneaking (can't fall from blocks edges, can't see nameplate behind walls, etc)", "figura.docs.entity.is_crouching": "Returns true if this entity is visually sneaking", - "figura.docs.entity.is_moving": "Returns true if this entity has some velocity", + "figura.docs.entity.is_moving": "Returns true if this entity has some velocity\nTakes a boolean parameter, where if true, the y velocity is ignored", "figura.docs.entity.is_falling": "Returns true if this entity has negative Y-velocity and is not on the ground", "figura.docs.entity.get_item": "Gets an ItemStack for the item in the given slot\nFor the player, slots are indexed with 1 as the main hand, 2 as the off hand, and 3,4,5,6 as the 4 armor slots from the boots to the helmet\nIf an invalid slot number is given, this will return nil", "figura.docs.entity.get_nbt": "Gets a table containing the NBT of this entity\nPlease note that not all values in the entity's NBT may be synced, as some are handled only on the server side",