/[projects]/miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/TemplateCommand.java
ViewVC logotype

Diff of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/TemplateCommand.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1751 by torben, Sun Mar 18 14:36:49 2012 UTC revision 1752 by torben, Mon Mar 19 08:09:08 2012 UTC
# Line 177  public class TemplateCommand implements Line 177  public class TemplateCommand implements
177          }          }
178    
179          void buildTemplate(Location loc, Pair[][][] template, int pass) {          void buildTemplate(Location loc, Pair[][][] template, int pass) {
180    
181                    
182                  World world = loc.getWorld();                  World world = loc.getWorld();
183                  for (int i=0; i<template.length; i++ ) {                  for (int i=0; i<template.length; i++ ) {
184                          for (int j=0; j<template[0].length; j++) {                          for (int j=0; j<template[0].length; j++) {
185                                  for (int k=0; k<template[0][0].length; k++) {                                  for (int k=0; k<template[0][0].length; k++) {
186                                          int x = loc.getBlockX() + i + 1;                                          int x, y ,z;
187                                          int y = loc.getBlockY() + j;                                          
188                                          int z = loc.getBlockZ() + k;                                          x = z = 0;
189                                                                                    
190                                            y = loc.getBlockY() + j;
191                                          if (y >= 255) {                                          if (y >= 255) {
192                                                  continue;                                                  continue;
193                                            }                                                                              
194                                            
195                                            switch ( getFacing(loc) ) {
196                                            case 0: //west                                          
197                                                    x = loc.getBlockX() - k;                                        
198                                                    z = loc.getBlockZ() + i + 1;                                                    
199                                                    break;
200                                            case 1: //north
201                                                    x = loc.getBlockX() - i - 1;                                    
202                                                    z = loc.getBlockZ() - k;                                                
203                                                    break;                                          
204                                            case 2: //east
205                                                    x = loc.getBlockX() + k;                                        
206                                                    z = loc.getBlockZ() - i - 1;
207                                                    break;
208                                            case 3: //south
209                                                    x = loc.getBlockX() + i + 1;                                    
210                                                    z = loc.getBlockZ() + k;                                                
211                                                    break;                                          
212                                          }                                          }
213    
214    
215                                          int type = template[i][j][k].id;                                          int type = template[i][j][k].id;
216                                          byte data = (byte) template[i][j][k].subId;                                          byte data = (byte) template[i][j][k].subId;
217    
# Line 210  public class TemplateCommand implements Line 233  public class TemplateCommand implements
233                  }                  }
234    
235          }          }
236            
237            
238            //yaw is left,right looking direction, 0=straight west
239            int getFacing(Location loc) {
240                    int angle = (int) loc.getYaw();
241                    
242                    if (angle < 45) {
243                            return 0;
244                    } else if (angle < 135) {
245                            return 1;
246                    } else if (angle < 225) {
247                            return 2;
248                    } else if (angle < 315) {
249                            return 3;
250                    } else {
251                            return 0;
252                    }
253            }
254    
255  }  }

Legend:
Removed from v.1751  
changed lines
  Added in v.1752

  ViewVC Help
Powered by ViewVC 1.1.20