Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20' into 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Aug 4, 2024
2 parents 66eb5c8 + bfbcdd2 commit 655f504
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}

Expand Down
12 changes: 11 additions & 1 deletion common/src/main/java/org/figuramc/figura/backend2/HttpAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,18 @@ public void onConnected(WebSocket websocket, Map<String, List<String>> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions common/src/main/resources/assets/figura/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 655f504

Please sign in to comment.