WavePlayz

Old

Mar 30th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let chunk = 16, breakpoints = { x: [], y: [], z: [] }
  2.         let Position = {
  3.             min: {
  4.                 x: Math.min(position1.x , position2.x),
  5.                 y: Math.min(position1.y , position2.y),
  6.                 z: Math.min(position1.z , position2.z)
  7.             },
  8.             max: {
  9.                 x: Math.max(position1.x , position2.x),
  10.                 y: Math.max(position1.y , position2.y),
  11.                 z: Math.max(position1.z , position2.z)
  12.             },
  13.             get size() {
  14.                 return (this.max.x - this.min.x) * (this.max.y - this.min.y) * (this.max.z - this.min.z)
  15.             }
  16.         }
  17.        
  18.         // Chunk selection bassed on region size
  19.         if(Position.size <= 34000) {chunk = 24}
  20.         else if(Position.size <= 68000) {chunk = 22}
  21.         else if(Position.size <= 128000) {chunk = 20}
  22.         else if(Position.size <= 256000) {chunk = 18}
  23.         tellraw(callerName, "ยง7> Chunk size used: "+chunk);
  24.        
  25.         // Creating Breakpoints / Spliting Cordintes
  26.         ["x", "y", "z"].forEach(Axis => {
  27.             for(let xyz = Position.min[Axis] ;; xyz += chunk) {
  28.                 if(xyz < Position.max[Axis]) {
  29.                     breakpoints[Axis].push( xyz)
  30.                 }else{
  31.                     breakpoints[Axis].push( Position.max[Axis]);
  32.                     break
  33.                 }
  34.             }
  35.         })
  36.         // [0 5 10 15 20]
  37.         // Making Positions From Breakpoint
  38.         let sets = [];
  39.         breakpoints.x.forEach( (X, Xindex) => {
  40.             breakpoints.y.forEach( (Y, Yindex) => {
  41.                 breakpoints.z.forEach( (Z, Zindex) => {
  42.                     let [x1, y1, z1] = [X, Y, Z]
  43.                     let [x2, y2, z2] = [breakpoints.x[Xindex + 1] , breakpoints.y[Yindex + 1] , breakpoints.z[Zindex + 1]];
  44.                    
  45.                     if(x2 == undefined) {x2 = x1}
  46.                     if(y2 == undefined) {y2 = y1}
  47.                     if(z2 == undefined) {z2 = z1}
  48.                
  49.                     if(breakpoints.x.length > 1 && x1 == x2 ||
  50.                         breakpoints.y.length > 1 && y1 == y2 ||
  51.                         breakpoints.z.length > 1 && z1 == z2
  52.                     ) {return}
  53.                    
  54.                     if(Xindex) {x1++} // as first
  55.                     if(Yindex) {y1++} // value in array
  56.                     if(Zindex) {z1++} // is zero
  57.                    
  58.                     sets.push({
  59.                         position1: {x: x1, y: y1, z: z1},
  60.                         position2: {x: x2, y: y2, z: z2}
  61.                     })
  62.                 })
  63.             })
  64.         })
Add Comment
Please, Sign In to add comment