Added config for biomes

This commit is contained in:
Aleksey 2020-09-22 17:10:04 +03:00
parent 41e0d1e42a
commit d382a965e9
10 changed files with 322 additions and 267 deletions

View file

@ -0,0 +1,51 @@
package ru.betterend.util;
import java.util.Random;
public class MHelper {
public static final float PI2 = (float) (Math.PI * 2);
private static final int ALPHA = 255 << 24;
public static final Random RANDOM = new Random();
public static int color(int r, int g, int b) {
return ALPHA | (r << 16) | (g << 8) | b;
}
public static int randRange(int min, int max, Random random) {
return min + random.nextInt(max - min + 1);
}
public static float randRange(float min, float max, Random random) {
return min + random.nextFloat() * (max - min);
}
public static byte setBit(byte source, int pos, boolean value) {
return value ? setBitTrue(source, pos) : setBitFalse(source, pos);
}
public static byte setBitTrue(byte source, int pos) {
source |= 1 << pos;
return source;
}
public static byte setBitFalse(byte source, int pos) {
source &= ~(1 << pos);
return source;
}
public static boolean getBit(byte source, int pos) {
return ((source >> pos) & 1) == 1;
}
public static int floor(float x) {
return x < 0 ? (int) (x - 1) : (int) x;
}
public static float wrap(float x, float side) {
return x - floor(x / side) * side;
}
public static int floor(double x) {
return x < 0 ? (int) (x - 1) : (int) x;
}
}