-
Notifications
You must be signed in to change notification settings - Fork 1
Description
standard.string.equals(string source, string value) could be implemented using the success code of /data modify:
/data modify <somepath> set from <source path>
/execute store success score <targetscore> run data modify <somepath> set from <value path>
The success code of /data modify is only 1 if the value changed. As such will now contain whether two strings are not equal.
standard.string.length(string value) could be implemented using the result code of /data get:
/execute store result score <targetscore> run data get <value>
The result code of /data get for strings is the length of the string.
standard.string.substring(string source, int start, int length) could be replaced with standard.string.substring(string source, int start, int end) and be implemented using function macros.
standard.string.startsWith(string source, string value) could be implemented like this:
return equals(substring(source, length(value)), value)
standard.string.endsWith(string source, string value) could be implemented like this:
return equals(substring(source, length(source) - length(value)), value)
Other operations that required reverse can be implemented using endsWith and negative indexing (e.g. str[-1] means last character and str[0..-1] means everything except last character).
standard.collections.List doesn't require a field for length, use /data get's result like above.
standard.collections.List.removeAt(int index) can use a macro in combination with /data remove
(minor) standard.collections.List could use /data remove data[]