player coords

This commit is contained in:
Leijurv 2019-03-04 11:28:41 -08:00
parent 3ae05b7348
commit 882ac41291
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -257,7 +257,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
try { try {
String[] coords = msg.substring("build".length()).trim().split(" "); String[] coords = msg.substring("build".length()).trim().split(" ");
file = coords[0] + ".schematic"; file = coords[0] + ".schematic";
origin = new BlockPos(Integer.parseInt(coords[1]), Integer.parseInt(coords[2]), Integer.parseInt(coords[3])); origin = new BlockPos(parseOrDefault(coords[1], ctx.playerFeet().x), parseOrDefault(coords[2], ctx.playerFeet().y), parseOrDefault(coords[3], ctx.playerFeet().z));
} catch (Exception ex) { } catch (Exception ex) {
file = msg.substring(5).trim() + ".schematic"; file = msg.substring(5).trim() + ".schematic";
origin = ctx.playerFeet(); origin = ctx.playerFeet();
@ -603,6 +603,10 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
return false; return false;
} }
private int parseOrDefault(String str, int i) {
return str.equals("~") ? i : Integer.parseInt(str);
}
private void log(List<ItemStack> stacks) { private void log(List<ItemStack> stacks) {
for (ItemStack stack : stacks) { for (ItemStack stack : stacks) {
if (!stack.isEmpty()) { if (!stack.isEmpty()) {