forked from gaucho-matrero/baritone
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
277 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package baritone.utils; | ||
|
||
import baritone.api.utils.BetterBlockPos; | ||
|
||
import java.util.Random; | ||
|
||
public class RandomSpotNearby { | ||
private BetterBlockPos end; | ||
private final Random rand; | ||
private double r; | ||
private double old_r; | ||
|
||
public RandomSpotNearby(final double r) { | ||
this.rand = new Random(); | ||
this.r = r; | ||
this.old_r = r; | ||
} | ||
|
||
private final double MAX_DIST_INCREASE() { | ||
return old_r * 2; | ||
} | ||
|
||
private BetterBlockPos calc(final BetterBlockPos start) { | ||
final double phi = rand.nextInt(360) + rand.nextDouble(); | ||
final double radius = rand.nextInt((int) Math.round(r)) + rand.nextDouble(); //rand.nextDouble(r) + rand.nextDouble(); | ||
final int x = (int) Math.round(radius * Math.sin(phi)); | ||
final int z = (int) Math.round(radius * Math.cos(phi)); | ||
|
||
this.end = new BetterBlockPos(start.getX() + x, start.getY(), start.getZ() + z); | ||
return this.end; | ||
} | ||
|
||
public BetterBlockPos next(final BetterBlockPos start) { | ||
this.r = (this.r - this.old_r > MAX_DIST_INCREASE()) ? this.old_r : this.r; | ||
return next(start, 0.3d); | ||
} | ||
|
||
public BetterBlockPos next(final BetterBlockPos start, final double increaseRadius) { | ||
this.r += increaseRadius; | ||
return calc(start); | ||
} | ||
} |
Oops, something went wrong.