mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 19:19:07 +00:00
Fixed Rarity map, Fixed missing blocks
This commit is contained in:
@@ -27,40 +27,35 @@ import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.stream.arithmetic.FittedStream;
|
||||
import com.volmit.iris.util.stream.interpolation.Interpolated;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public interface IRare {
|
||||
static <T extends IRare> ProceduralStream<T> stream(ProceduralStream<Double> noise, List<T> possibilities)
|
||||
{
|
||||
static <T extends IRare> ProceduralStream<T> stream(ProceduralStream<Double> noise, List<T> possibilities) {
|
||||
return ProceduralStream.of((x, z) -> pick(possibilities, noise.get(x, z)),
|
||||
(x, y, z) -> pick(possibilities, noise.get(x, y, z)),
|
||||
new Interpolated<T>() {
|
||||
@Override
|
||||
public double toDouble(T t) {
|
||||
return 0;
|
||||
}
|
||||
(x, y, z) -> pick(possibilities, noise.get(x, y, z)),
|
||||
new Interpolated<T>() {
|
||||
@Override
|
||||
public double toDouble(T t) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public T fromDouble(double d) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static <T extends IRare> T pickSlowly(List<T> possibilities, double noiseValue)
|
||||
{
|
||||
if(possibilities.isEmpty())
|
||||
{
|
||||
|
||||
static <T extends IRare> T pickSlowly(List<T> possibilities, double noiseValue) {
|
||||
if (possibilities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(possibilities.size() == 1)
|
||||
{
|
||||
if (possibilities.size() == 1) {
|
||||
return possibilities.get(0);
|
||||
}
|
||||
|
||||
@@ -77,23 +72,44 @@ public interface IRare {
|
||||
return rarityTypes.get((int) (noiseValue * rarityTypes.last()));
|
||||
}
|
||||
|
||||
static <T extends IRare> T pick(List<T> possibilities, double noiseValue)
|
||||
{
|
||||
if(possibilities.isEmpty())
|
||||
{
|
||||
static <T extends IRare> T pick(List<T> possibilities, double noiseValue) {
|
||||
if (possibilities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(possibilities.size() == 1)
|
||||
{
|
||||
if (possibilities.size() == 1) {
|
||||
return possibilities.get(0);
|
||||
}
|
||||
int totalWeight = 0; // This is he baseline
|
||||
int buffer = 0;
|
||||
for (T i : possibilities) { // Im adding all of the rarity together
|
||||
totalWeight += i.getRarity();
|
||||
}
|
||||
double threshold = totalWeight * (possibilities.size() - 1) * noiseValue;
|
||||
for (T i : possibilities) {
|
||||
buffer += totalWeight - i.getRarity();
|
||||
|
||||
if (buffer >= threshold) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return possibilities.get(possibilities.size() - 1);
|
||||
}
|
||||
|
||||
|
||||
static <T extends IRare> T pickOld(List<T> possibilities, double noiseValue) {
|
||||
if (possibilities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (possibilities.size() == 1) {
|
||||
return possibilities.get(0);
|
||||
}
|
||||
|
||||
double completeWeight = 0.0;
|
||||
double highestWeight = 0.0;
|
||||
|
||||
for (T item : possibilities)
|
||||
{
|
||||
for (T item : possibilities) {
|
||||
double weight = Math.max(item.getRarity(), 1);
|
||||
highestWeight = Math.max(highestWeight, weight);
|
||||
completeWeight += weight;
|
||||
@@ -105,8 +121,7 @@ public interface IRare {
|
||||
for (T item : possibilities) {
|
||||
double weight = Math.max(highestWeight - Math.max(item.getRarity(), 1), 1);
|
||||
countWeight += weight;
|
||||
if (countWeight >= r)
|
||||
{
|
||||
if (countWeight >= r) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user