--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/TemplateCommand.java 2012/03/18 14:58:22 1751 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/TemplateCommand.java 2012/03/19 08:09:08 1752 @@ -177,18 +177,41 @@ } void buildTemplate(Location loc, Pair[][][] template, int pass) { + + World world = loc.getWorld(); for (int i=0; i= 255) { continue; + } + + switch ( getFacing(loc) ) { + case 0: //west + x = loc.getBlockX() - k; + z = loc.getBlockZ() + i + 1; + break; + case 1: //north + x = loc.getBlockX() - i - 1; + z = loc.getBlockZ() - k; + break; + case 2: //east + x = loc.getBlockX() + k; + z = loc.getBlockZ() - i - 1; + break; + case 3: //south + x = loc.getBlockX() + i + 1; + z = loc.getBlockZ() + k; + break; } + int type = template[i][j][k].id; byte data = (byte) template[i][j][k].subId; @@ -210,5 +233,23 @@ } } + + + //yaw is left,right looking direction, 0=straight west + int getFacing(Location loc) { + int angle = (int) loc.getYaw(); + + if (angle < 45) { + return 0; + } else if (angle < 135) { + return 1; + } else if (angle < 225) { + return 2; + } else if (angle < 315) { + return 3; + } else { + return 0; + } + } }