Add static parse for ArgumentBlockState

This commit is contained in:
TheMode 2021-06-27 17:05:57 +02:00
parent e95cc4d295
commit a29f5f1274

View File

@ -20,6 +20,18 @@ public class ArgumentBlockState extends Argument<Block> {
@Override
public @NotNull Block parse(@NotNull String input) throws ArgumentSyntaxException {
return staticParse(input);
}
@Override
public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:block_state";
nodeMaker.addNodes(new DeclareCommandsPacket.Node[]{argumentNode});
}
public static Block staticParse(@NotNull String input) throws ArgumentSyntaxException {
final int nbtIndex = input.indexOf("[");
if (nbtIndex == 0)
throw new ArgumentSyntaxException("No block type", input, NO_BLOCK);
@ -46,14 +58,6 @@ public class ArgumentBlockState extends Argument<Block> {
}
}
@Override
public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:block_state";
nodeMaker.addNodes(new DeclareCommandsPacket.Node[]{argumentNode});
}
@Override
public String toString() {
return String.format("BlockState<%s>", getId());