WorldScannerBuilder
com.jsmacrosce.jsmacros.client.api.classes.worldscanner.WorldScannerBuilder
Builds scanners with separate block and block-state filters. Named-method and string filters run in the scanner's native filtering path. A filter step starts with a with, and, or, or xor method and is completed by a comparison call; not immediately negates the complete existing filter. A second with filter replaces the existing filter in that category, while the other operators combine with it. A pending step must be completed before another starts.
String filters inspect the helper's complete toString() text, and each supplied pattern is an alternative. matches(String[]) uses whole-string regular-expression matching; the other string operations compare literal text. Use a named-method filter such as withBlockFilter(String) with "getId" to compare a method's returned value instead.
For example, this finds blocks whose helper text contains _ore or _block:
// matches applies each regular expression to the complete helper text
const ores = World.getWorldScanner()
.withStringBlockFilter().matches(".*_ore.*")
.orStringBlockFilter().matches(".*_block.*")
.build();
Chat.log(`${ores.scanAroundPlayer(2).size()} ore or building blocks`);Named-method filters accept public no-argument methods on BlockStateHelper or BlockHelper, except methods declared by Object; their return values must be numeric, String, or boolean. Numeric comparisons use an operator and a value, String comparisons use a comparison name and text, and boolean comparisons take the expected value. For more complex filters, use FWorld.getWorldScanner(MethodWrapper, MethodWrapper).
Constructors
new WorldScannerBuilder
Methods
andBlockFilter
// Both comparisons are numeric; both conditions must accept the block
const scanner = World.getWorldScanner()
.withBlockFilter("getHardness").is(">=", 10)
.andBlockFilter("getBlastResistance").is(">", 1200)
.build();
Chat.log(`${scanner.scanAroundPlayer(2).size()} hard and blast resistant blocks`);Parameters:
method: the name of a public no-argument method available on BlockHelper
andStateFilter
// getLuminance returns a number, so its comparison takes an operator and a number
const scanner = World.getWorldScanner()
.withStateFilter("isToolRequired").is(false)
.andStateFilter("getLuminance").is("==", 15)
.build();
Chat.log(`${scanner.scanAroundPlayer(2).size()} unbreakable fully lit states`);Parameters:
method: the name of a public no-argument method available on BlockStateHelper
andStringBlockFilter
andStringStateFilter
build
// a block filter and a state filter are two independent stages, so a
// block that is hard enough and a state that needs no tool is one set
// of blocks rather than two alternative ones
const scanner = World.getWorldScanner()
.withBlockFilter("getHardness").is(">=", 10)
.withStateFilter("isToolRequired").is(false)
.build();
const found = scanner.scanAroundPlayer(2);
Chat.log(`${found.size()} hard blocks that break without a tool`);contains
Parameters:
args: the substrings to look for in the text, at least one of which has to be found for a candidate to be kept
endsWith
Parameters:
args: the suffixes the text has to end with, at least one of which has to match for a candidate to be kept
equals
Parameters:
args: the patterns to compare the text against, at least one of which has to be equal for a candidate to be kept
is
args as the comparison arguments. Boolean and character methods take one value; String and numeric methods take two (a comparison name or operator, then a value). Numeric operators are interpreted when candidates are tested, so an invalid operator rejects candidates rather than failing at construction. // is(">=", 10) is the whole argument list: an operator and a number,
// because getHardness returns a float
const scanner = World.getWorldScanner()
.withBlockFilter("getHardness").is(">=", 10)
.build();
Chat.log(`${scanner.scanAroundPlayer(2).size()} blocks of hardness 10 or more`);Parameters:
args: the arguments for the comparison, whose count and types are decided by the return type of the method the pending step named
methodArgs to that method and filterArgs to its comparison. The helpers' eligible methods take no arguments; use is(Object[]) to supply comparison arguments for those methods.Parameters:
methodArgs: the arguments to call the named method with, ornullfor nonefilterArgs: the arguments for the comparison, whose count and types are decided by the return type of the named method
matches
Parameters:
args: the regular expressions the whole text has to match, at least one of which has to match for a candidate to be kept
notBlockFilter
notStateFilter
// Negate the completed state filter
const scanner = World.getWorldScanner()
.withStateFilter("exceedsCube").is(false)
.notStateFilter()
.build();
Chat.log(`${scanner.scanAroundPlayer(2).size()} states that are not full cubes`);orBlockFilter
Parameters:
method: the name of a public no-argument method available on BlockHelper
orStateFilter
// getId returns a string, so compare it with a string operation and value
const scanner = World.getWorldScanner()
.withStateFilter("isSolid").is(true)
.orStateFilter("getId").is("ENDS_WITH", "torch")
.build();
Chat.log(`${scanner.scanAroundPlayer(2).size()} solid states or torches`);Parameters:
method: the name of a public no-argument method available on BlockStateHelper
orStringBlockFilter
orStringStateFilter
startsWith
Parameters:
args: the prefixes the text has to begin with, at least one of which has to match for a candidate to be kept
test
is is a keyword. This alias is not exposed by the typed builder returned by World.getWorldScanner().Parameters:
args: the arguments for the comparison, whose count and types are decided by the return type of the method the pending step named
is is a keyword. No helper method accepts arguments, so this overload has no useful named-method arguments; it is also absent from the typed builder returned by World.getWorldScanner().Parameters:
methodArgs: the arguments to call the named method with, ornullfor nonefilterArgs: the arguments for the comparison, whose count and types are decided by the return type of the named method
withBlockFilter
IllegalStateException. A block filter and a state filter are two independent stages rather than alternatives, so a state filter set afterwards narrows the block filter rather than replacing it. // getHardness returns a number, so its comparison takes an operator and a number
const scanner = World.getWorldScanner()
.withBlockFilter("getHardness").is(">=", 10)
.build();
const found = scanner.scanAroundPlayer(2);
Chat.log(`${found.size()} blocks with a hardness of 10 or more`);Parameters:
method: the name of a public no-argument method available on BlockHelper, and the arguments the following is(Object[], Object[]) needs are decided by its return type
withStateFilter
with filter replaces any existing state filter. A pending filter step prevents another from starting. // A boolean-returning method takes the expected value as its comparison
const scanner = World.getWorldScanner()
.withStateFilter("isToolRequired").is(false)
.build();
const found = scanner.scanAroundPlayer(2);
Chat.log(`${found.size()} states that break without a tool`);Parameters:
method: the name of a public no-argument method on BlockStateHelper
withStringBlockFilter
toString() text. Complete it with equals(String[]), contains(String[]), startsWith(String[]), endsWith(String[]) or matches(String[]).withStringStateFilter
toString() text, including its property map. Complete it with equals(String[]), contains(String[]), startsWith(String[]), endsWith(String[]) or matches(String[]).xorBlockFilter
xorBlockFilter(String method): WorldScannerBuilder#Parameters:
method: a public no-argument method, including inherited methods
xorStateFilter
xorStateFilter(String method): WorldScannerBuilder#Parameters:
method: the name of a public no-argument method available on BlockStateHelper
xorStringBlockFilter
xorStringBlockFilter(): WorldScannerBuilder#xorStringStateFilter
xorStringStateFilter(): WorldScannerBuilder#