/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.nitro.position;

import com.flowpowered.math.vector.Vector3d;
import com.flowpowered.math.vector.Vector3i;
import com.skelril.nitro.probability.Probability;

public class PositionRandomizer {
    private int noiseX;
    private int noiseY;
    private int noiseZ;

    public PositionRandomizer(int noise) {
        this(noise, noise, noise);
    }

    public PositionRandomizer(int noiseX, int noiseY, int noiseZ) {
        this.noiseX = noiseX;
        this.noiseY = noiseY;
        this.noiseZ = noiseZ;
    }

    public Vector3i createPosition3i(Vector3i src) {
        return src.add(
                Probability.getRangedRandom(-noiseX, noiseX * 2),
                Probability.getRangedRandom(-noiseY, noiseY * 2),
                Probability.getRangedRandom(-noiseZ, noiseZ * 2)
        );
    }

    public Vector3i createPosition3i(Vector3d src) {
        return createPosition3i(src.toInt());
    }
}

@@ -330,16 +330,58 @@
 ctor3i;%0A
+import com.skelril.nitro.numeric.MathExt;%0A
 import c
@@ -422,16 +422,16 @@
 bility;%0A
-
 %0Apublic 
@@ -841,22 +841,30 @@
         
-return
+Vector3i res =
  src.add
@@ -993,24 +993,24 @@
 oiseY * 2),%0A
-
             
@@ -1072,16 +1072,235 @@
       );
+%0A%0A        return new Vector3i(%0A                MathExt.bound(res.getX(), -30000000, 30000000),%0A                MathExt.bound(res.getY(), 0, 255),%0A                MathExt.bound(res.getZ(), -30000000, 30000000)%0A        );
 %0A    %7D%0A%0A

Put world boundings on the PositionRandomizer