9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-29 20:19:06 +00:00

Region rarity

This commit is contained in:
Daniel Mills
2020-08-07 13:36:41 -04:00
parent e5384509cf
commit c158e74fb5
19 changed files with 356 additions and 44 deletions

View File

@@ -0,0 +1,6 @@
package com.volmit.iris.util;
public interface IRare
{
public int getRarity();
}

View File

@@ -20,18 +20,22 @@ public class PregenJob
public static int task = -1;
private PrecisionStopwatch s;
private ChronoLatch cl;
private MortarSender sender;
private Runnable onDone;
public PregenJob(World world, int size)
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
{
this.s = PrecisionStopwatch.start();
this.world = world;
this.size = size;
this.onDone = onDone;
world.getWorldBorder().setCenter(0, 0);
world.getWorldBorder().setWarningDistance(64);
world.getWorldBorder().setSize(size);
mcaX = mca(min());
mcaZ = mca(min());
rcx = 0;
this.sender = sender;
cl = new ChronoLatch(3000);
rcz = 0;
total = (size / 16) * (size / 16);
@@ -83,7 +87,12 @@ public class PregenJob
private void tickMetrics()
{
long eta = (long) ((total - genned) * (s.getMilliseconds() / (double) genned));
Iris.info("Pregen: Generating: " + Form.pc(Math.min((double) genned / (double) total, 1.0), 0) + ", Elapsed: " + Form.duration((long) s.getMilliseconds()) + ", ETA: " + (genned >= total - 5 ? "Any second..." : s.getMilliseconds() < 25000 ? "Calculating..." : Form.duration(eta)) + " MS: " + Form.duration((s.getMilliseconds() / (double) genned), 2));
String ss = "Pregen: " + Form.pc(Math.min((double) genned / (double) total, 1.0), 0) + ", Elapsed: " + Form.duration((long) s.getMilliseconds()) + ", ETA: " + (genned >= total - 5 ? "Any second..." : s.getMilliseconds() < 25000 ? "Calculating..." : Form.duration(eta)) + " MS: " + Form.duration((s.getMilliseconds() / (double) genned), 2);
Iris.info(ss);
if(sender.isPlayer() && sender.player().isOnline())
{
sender.sendMessage(ss);
}
}
public void tick()
@@ -117,6 +126,10 @@ public class PregenJob
completed = true;
stop();
Iris.info("Pregen Completed!");
if(sender.isPlayer() && sender.player().isOnline())
{
sender.sendMessage("Pregen Completed!");
}
for(Chunk i : world.getLoadedChunks())
{
@@ -124,6 +137,8 @@ public class PregenJob
}
world.save();
onDone.run();
return;
}
@@ -149,6 +164,12 @@ public class PregenJob
catch(Throwable e)
{
Iris.warn("Pregen Crash!");
if(sender.isPlayer() && sender.player().isOnline())
{
sender.sendMessage("Pregen Completed!");
}
onDone.run();
e.printStackTrace();
stop();
}

View File

@@ -1,15 +1,13 @@
package com.volmit.iris.util;
import com.volmit.iris.object.IrisBiome;
public class RarityCellGenerator extends CellGenerator
public class RarityCellGenerator<T extends IRare> extends CellGenerator
{
public RarityCellGenerator(RNG rng)
{
super(rng);
}
public IrisBiome get(double x, double z, KList<IrisBiome> b)
public T get(double x, double z, KList<T> b)
{
if(b.size() == 0)
{
@@ -21,10 +19,10 @@ public class RarityCellGenerator extends CellGenerator
return b.get(0);
}
KList<IrisBiome> rarityMapped = new KList<>();
KList<T> rarityMapped = new KList<>();
boolean o = false;
int max = 1;
for(IrisBiome i : b)
for(T i : b)
{
if(i.getRarity() > max)
{
@@ -34,7 +32,7 @@ public class RarityCellGenerator extends CellGenerator
max++;
for(IrisBiome i : b)
for(T i : b)
{
for(int j = 0; j < max - i.getRarity(); j++)
{

View File

@@ -6,6 +6,9 @@ import com.google.gson.Gson;
import com.volmit.iris.Iris;
import com.volmit.iris.object.IrisRegistrant;
import lombok.Data;
@Data
public class ResourceLoader<T extends IrisRegistrant>
{
protected File root;