mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-04 06:46:09 +00:00
Cleanup
This commit is contained in:
@@ -35,7 +35,13 @@ import com.volmit.iris.engine.framework.EngineWorldManager;
|
||||
import com.volmit.iris.engine.framework.SeedManager;
|
||||
import com.volmit.iris.engine.framework.WrongEngineBroException;
|
||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||
import com.volmit.iris.engine.object.*;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
|
||||
import com.volmit.iris.engine.object.IrisDecorator;
|
||||
import com.volmit.iris.engine.object.IrisEngineData;
|
||||
import com.volmit.iris.engine.object.IrisJigsawStructure;
|
||||
import com.volmit.iris.engine.object.IrisObjectPlacement;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
||||
import com.volmit.iris.util.atomics.AtomicRollingSequence;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
@@ -132,18 +138,18 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
private void verifySeed() {
|
||||
if (getEngineData().getSeed() != null && getEngineData().getSeed() != target.getWorld().getRawWorldSeed()) {
|
||||
if(getEngineData().getSeed() != null && getEngineData().getSeed() != target.getWorld().getRawWorldSeed()) {
|
||||
target.getWorld().setRawWorldSeed(getEngineData().getSeed());
|
||||
}
|
||||
}
|
||||
|
||||
private void tickRandomPlayer() {
|
||||
if (perSecondBudLatch.flip()) {
|
||||
if(perSecondBudLatch.flip()) {
|
||||
buds.set(bud.get());
|
||||
bud.set(0);
|
||||
}
|
||||
|
||||
if (effects != null) {
|
||||
if(effects != null) {
|
||||
effects.tickRandomPlayer();
|
||||
}
|
||||
}
|
||||
@@ -168,7 +174,7 @@ public class IrisEngine implements Engine {
|
||||
effects = new IrisEngineEffects(this);
|
||||
setupMode();
|
||||
J.a(this::computeBiomeMaxes);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.error("FAILED TO SETUP ENGINE!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -177,7 +183,7 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
private void setupMode() {
|
||||
if (mode != null) {
|
||||
if(mode != null) {
|
||||
mode.close();
|
||||
}
|
||||
|
||||
@@ -200,8 +206,8 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
private void warmupChunk(int x, int z) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
for(int i = 0; i < 16; i++) {
|
||||
for(int j = 0; j < 16; j++) {
|
||||
int xx = x + (i << 4);
|
||||
int zz = z + (z << 4);
|
||||
getComplex().getTrueBiomeStream().get(xx, zz);
|
||||
@@ -237,18 +243,18 @@ public class IrisEngine implements Engine {
|
||||
//TODO: Method this file
|
||||
File f = new File(getWorld().worldFolder(), "iris/engine-data/" + getDimension().getLoadKey() + ".json");
|
||||
|
||||
if (!f.exists()) {
|
||||
if(!f.exists()) {
|
||||
try {
|
||||
f.getParentFile().mkdirs();
|
||||
IO.writeAll(f, new Gson().toJson(new IrisEngineData()));
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return new Gson().fromJson(IO.readAll(f), IrisEngineData.class);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -263,11 +269,11 @@ public class IrisEngine implements Engine {
|
||||
|
||||
@Override
|
||||
public double getGeneratedPerSecond() {
|
||||
if (perSecondLatch.flip()) {
|
||||
if(perSecondLatch.flip()) {
|
||||
double g = generated.get() - generatedLast.get();
|
||||
generatedLast.set(generated.get());
|
||||
|
||||
if (g == 0) {
|
||||
if(g == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -285,24 +291,24 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
private void computeBiomeMaxes() {
|
||||
for (IrisBiome i : getDimension().getAllBiomes(this)) {
|
||||
for(IrisBiome i : getDimension().getAllBiomes(this)) {
|
||||
double density = 0;
|
||||
|
||||
for (IrisObjectPlacement j : i.getObjects()) {
|
||||
for(IrisObjectPlacement j : i.getObjects()) {
|
||||
density += j.getDensity() * j.getChance();
|
||||
}
|
||||
|
||||
maxBiomeObjectDensity = Math.max(maxBiomeObjectDensity, density);
|
||||
density = 0;
|
||||
|
||||
for (IrisDecorator j : i.getDecorators()) {
|
||||
for(IrisDecorator j : i.getDecorators()) {
|
||||
density += Math.max(j.getStackMax(), 1) * j.getChance();
|
||||
}
|
||||
|
||||
maxBiomeDecoratorDensity = Math.max(maxBiomeDecoratorDensity, density);
|
||||
density = 0;
|
||||
|
||||
for (IrisBiomePaletteLayer j : i.getLayers()) {
|
||||
for(IrisBiomePaletteLayer j : i.getLayers()) {
|
||||
density++;
|
||||
}
|
||||
|
||||
@@ -323,11 +329,11 @@ public class IrisEngine implements Engine {
|
||||
double totalWeight = 0;
|
||||
double wallClock = getMetrics().getTotal().getAverage();
|
||||
|
||||
for (double j : timings.values()) {
|
||||
for(double j : timings.values()) {
|
||||
totalWeight += j;
|
||||
}
|
||||
|
||||
for (String j : timings.k()) {
|
||||
for(String j : timings.k()) {
|
||||
weights.put(getName() + "." + j, (wallClock / totalWeight) * timings.get(j));
|
||||
}
|
||||
|
||||
@@ -335,33 +341,33 @@ public class IrisEngine implements Engine {
|
||||
|
||||
double mtotals = 0;
|
||||
|
||||
for (double i : totals.values()) {
|
||||
for(double i : totals.values()) {
|
||||
mtotals += i;
|
||||
}
|
||||
|
||||
for (String i : totals.k()) {
|
||||
for(String i : totals.k()) {
|
||||
totals.put(i, (masterWallClock / mtotals) * totals.get(i));
|
||||
}
|
||||
|
||||
double v = 0;
|
||||
|
||||
for (double i : weights.values()) {
|
||||
for(double i : weights.values()) {
|
||||
v += i;
|
||||
}
|
||||
|
||||
for (String i : weights.k()) {
|
||||
for(String i : weights.k()) {
|
||||
weights.put(i, weights.get(i) / v);
|
||||
}
|
||||
|
||||
sender.sendMessage("Total: " + C.BOLD + C.WHITE + Form.duration(masterWallClock, 0));
|
||||
|
||||
for (String i : totals.k()) {
|
||||
for(String i : totals.k()) {
|
||||
sender.sendMessage(" Engine " + C.UNDERLINE + C.GREEN + i + C.RESET + ": " + C.BOLD + C.WHITE + Form.duration(totals.get(i), 0));
|
||||
}
|
||||
|
||||
sender.sendMessage("Details: ");
|
||||
|
||||
for (String i : weights.sortKNumber().reverse()) {
|
||||
for(String i : weights.sortKNumber().reverse()) {
|
||||
String befb = C.UNDERLINE + "" + C.GREEN + "" + i.split("\\Q[\\E")[0] + C.RESET + C.GRAY + "[";
|
||||
String num = C.GOLD + i.split("\\Q[\\E")[1].split("]")[0] + C.RESET + C.GRAY + "].";
|
||||
String afb = C.ITALIC + "" + C.AQUA + i.split("\\Q]\\E")[1].substring(1) + C.RESET + C.GRAY;
|
||||
@@ -395,11 +401,11 @@ public class IrisEngine implements Engine {
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
if (!cleanLatch.flip()) {
|
||||
if(!cleanLatch.flip()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cleaning.get()) {
|
||||
if(cleaning.get()) {
|
||||
cleanLatch.flipDown();
|
||||
return;
|
||||
}
|
||||
@@ -410,7 +416,7 @@ public class IrisEngine implements Engine {
|
||||
try {
|
||||
getMantle().trim();
|
||||
getData().getObjectLoader().clean();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.error("Cleanup failed! Enable debug to see stacktrace.");
|
||||
}
|
||||
@@ -422,7 +428,7 @@ public class IrisEngine implements Engine {
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes, boolean multicore) throws WrongEngineBroException {
|
||||
if (closed) {
|
||||
if(closed) {
|
||||
throw new WrongEngineBroException();
|
||||
}
|
||||
|
||||
@@ -432,9 +438,9 @@ public class IrisEngine implements Engine {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Hunk<BlockData> blocks = vblocks.listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t));
|
||||
|
||||
if (getDimension().isDebugChunkCrossSections() && ((x >> 4) % getDimension().getDebugCrossSectionsMod() == 0 || (z >> 4) % getDimension().getDebugCrossSectionsMod() == 0)) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
if(getDimension().isDebugChunkCrossSections() && ((x >> 4) % getDimension().getDebugCrossSectionsMod() == 0 || (z >> 4) % getDimension().getDebugCrossSectionsMod() == 0)) {
|
||||
for(int i = 0; i < 16; i++) {
|
||||
for(int j = 0; j < 16; j++) {
|
||||
blocks.set(i, 0, j, Material.CRYING_OBSIDIAN.createBlockData());
|
||||
}
|
||||
}
|
||||
@@ -446,7 +452,7 @@ public class IrisEngine implements Engine {
|
||||
getMetrics().getTotal().put(p.getMilliseconds());
|
||||
generated.incrementAndGet();
|
||||
recycle();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
fail("Failed to generate " + x + ", " + z, e);
|
||||
}
|
||||
@@ -460,7 +466,7 @@ public class IrisEngine implements Engine {
|
||||
try {
|
||||
IO.writeAll(f, new Gson().toJson(getEngineData()));
|
||||
Iris.debug("Saved Engine Data");
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
Iris.error("Failed to save Engine Data");
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -473,7 +479,7 @@ public class IrisEngine implements Engine {
|
||||
|
||||
@Override
|
||||
public IrisBiome getFocus() {
|
||||
if (getDimension().getFocus() == null || getDimension().getFocus().trim().isEmpty()) {
|
||||
if(getDimension().getFocus() == null || getDimension().getFocus().trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -482,12 +488,13 @@ public class IrisEngine implements Engine {
|
||||
|
||||
@Override
|
||||
public IrisRegion getFocusRegion() {
|
||||
if (getDimension().getFocusRegion() == null || getDimension().getFocusRegion().trim().isEmpty()) {
|
||||
if(getDimension().getFocusRegion() == null || getDimension().getFocusRegion().trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getData().getRegionLoader().load(getDimension().getFocusRegion());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String error, Throwable e) {
|
||||
failing = true;
|
||||
|
||||
Reference in New Issue
Block a user