mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Fixed Rarity map, Fixed missing blocks
This commit is contained in:
parent
24408e53a3
commit
8bbf98979e
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ import static org.bukkit.Material.*;
|
||||
|
||||
public class B {
|
||||
private static final Material AIR_MATERIAL = Material.AIR;
|
||||
private static final ReentrantLock createLock = new ReentrantLock();
|
||||
private static final BlockData AIR = AIR_MATERIAL.createBlockData();
|
||||
private static final IntSet foliageCache = buildFoliageCache();
|
||||
private static final IntSet deepslateCache = buildDeepslateCache();
|
||||
@ -441,31 +440,8 @@ public class B {
|
||||
return AIR;
|
||||
}
|
||||
|
||||
private static BlockData createBlockData(String s) {
|
||||
BlockData be = null;
|
||||
try {
|
||||
be = Bukkit.createBlockData(s);
|
||||
} catch (Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
if (be == null) {
|
||||
try {
|
||||
createLock.lock();
|
||||
be = Bukkit.createBlockData(s);
|
||||
createLock.unlock();
|
||||
if (be != null) {
|
||||
Iris.info("We have fixed: " + s);
|
||||
}
|
||||
return be;
|
||||
|
||||
} catch (Throwable ee) {
|
||||
|
||||
}
|
||||
Iris.error("Oh no... " + s);
|
||||
|
||||
}
|
||||
return be;
|
||||
private static synchronized BlockData createBlockData(String s) {
|
||||
return Bukkit.createBlockData(s);
|
||||
}
|
||||
|
||||
private static BlockData parseBlockData(String ix) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user