mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Loads of bugfixes & Seed cohesion
This commit is contained in:
parent
84e81e9ce0
commit
36e5fec284
@ -17,6 +17,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -79,7 +80,8 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
public static WandController wand;
|
||||
private static String last = "";
|
||||
private BoardManager manager;
|
||||
private RollingSequence hits = new RollingSequence(20);
|
||||
public RollingSequence hits = new RollingSequence(20);
|
||||
public RollingSequence tp = new RollingSequence(100);
|
||||
public static KList<Class<? extends IrisPostBlockFilter>> postProcessors;
|
||||
|
||||
public Iris()
|
||||
@ -95,12 +97,14 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
wand = new WandController();
|
||||
postProcessors = loadPostProcessors();
|
||||
manager = new BoardManager(this, BoardSettings.builder().boardProvider(this).scoreDirection(ScoreDirection.UP).build());
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
writeDocs();
|
||||
}
|
||||
|
||||
catch(JSONException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
@ -128,9 +132,10 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
int z = player.getLocation().getBlockZ();
|
||||
BiomeResult er = g.sampleTrueBiome(x, y, z);
|
||||
IrisBiome b = er != null ? er.getBiome() : null;
|
||||
tp.put(g.getMetrics().getSpeed());
|
||||
lines.add("&7&m-----------------");
|
||||
lines.add(ChatColor.GREEN + "Speed" + ChatColor.GRAY + ": " + ChatColor.BOLD + "" + ChatColor.GRAY + Form.f(g.getMetrics().getPerSecond().getAverage(), 0) + "/s " + Form.duration(g.getMetrics().getTotal().getAverage(), 1) + "");
|
||||
lines.add(ChatColor.GREEN + "Loss" + ChatColor.GRAY + ": " + ChatColor.BOLD + "" + ChatColor.GRAY + Form.duration(g.getMetrics().getLoss().getAverage(), 4) + "");
|
||||
lines.add(ChatColor.GREEN + "Throughput" + ChatColor.GRAY + ": " + ChatColor.BOLD + "" + ChatColor.GRAY + Form.f((long) tp.getAverage()) + "");
|
||||
lines.add(ChatColor.GREEN + "Generators" + ChatColor.GRAY + ": " + Form.f(CNG.creates));
|
||||
lines.add(ChatColor.GREEN + "Noise" + ChatColor.GRAY + ": " + Form.f((int) hits.getAverage()));
|
||||
lines.add(ChatColor.GREEN + "Parallax Chunks" + ChatColor.GRAY + ": " + Form.f((int) g.getParallaxMap().getLoadedChunks().size()));
|
||||
@ -237,7 +242,7 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
{
|
||||
imsg(sender, "/iris dev [dimension] - Create a new dev world");
|
||||
imsg(sender, "/iris what <look/hand> - Data about items & blocks");
|
||||
imsg(sender, "/iris goto <name> - Fast goto biome");
|
||||
imsg(sender, "/iris goto <biome> [other-biome] [-cave] - Fast goto biome");
|
||||
imsg(sender, "/iris wand [?] - Get a wand / help");
|
||||
imsg(sender, "/iris save <name> - Save object");
|
||||
imsg(sender, "/iris load <name> - Load & place object");
|
||||
@ -245,7 +250,7 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
|
||||
if(args.length >= 1)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("goto") && args.length == 2)
|
||||
if(args[0].equalsIgnoreCase("goto") && args.length >= 2)
|
||||
{
|
||||
if(sender instanceof Player)
|
||||
{
|
||||
@ -253,11 +258,41 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
World world = p.getWorld();
|
||||
IrisChunkGenerator g = (IrisChunkGenerator) world.getGenerator();
|
||||
int tries = 10000;
|
||||
boolean cave = false;
|
||||
IrisBiome biome2 = null;
|
||||
if(args.length > 2)
|
||||
{
|
||||
if(args[2].equalsIgnoreCase("-cave"))
|
||||
{
|
||||
cave = true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
biome2 = data.getBiomeLoader().load(args[2]);
|
||||
|
||||
if(biome2 == null)
|
||||
{
|
||||
sender.sendMessage(args[2] + " is not a biome. Use the file name (without extension)");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equalsIgnoreCase("-cave"))
|
||||
{
|
||||
cave = true;
|
||||
}
|
||||
}
|
||||
|
||||
IrisBiome biome = data.getBiomeLoader().load(args[1]);
|
||||
|
||||
if(biome == null)
|
||||
{
|
||||
sender.sendMessage("Not a biome. Use the file name (without extension)");
|
||||
sender.sendMessage(args[1] + " is not a biome. Use the file name (without extension)");
|
||||
return true;
|
||||
}
|
||||
|
||||
while(tries > 0)
|
||||
@ -266,13 +301,33 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
|
||||
int xx = (int) (RNG.r.i(-29999970, 29999970));
|
||||
int zz = (int) (RNG.r.i(-29999970, 29999970));
|
||||
if(g.sampleTrueBiome(xx, zz).getBiome().getLoadKey().equals(biome.getLoadKey()))
|
||||
if((cave ? g.sampleCaveBiome(xx, zz) : g.sampleTrueBiome(xx, zz)).getBiome().getLoadKey().equals(biome.getLoadKey()))
|
||||
{
|
||||
if(biome2 != null)
|
||||
{
|
||||
for(int i = 0; i < 64; i++)
|
||||
{
|
||||
int ax = xx + RNG.r.i(-64, 32);
|
||||
int az = zz + RNG.r.i(-64, 32);
|
||||
|
||||
if((cave ? g.sampleCaveBiome(ax, az) : g.sampleTrueBiome(ax, az)).getBiome().getLoadKey().equals(biome2.getLoadKey()))
|
||||
{
|
||||
tries--;
|
||||
p.teleport(new Location(world, xx, world.getHighestBlockYAt(xx, zz), zz));
|
||||
sender.sendMessage("Found border in " + (10000 - tries) + " tries!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
p.teleport(new Location(world, xx, world.getHighestBlockYAt(xx, zz), zz));
|
||||
sender.sendMessage("Found in " + (10000 - tries) + "!");
|
||||
sender.sendMessage("Found in " + (10000 - tries) + " tries!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage("Tried to find " + biome.getName() + " looked in 10,000 places no dice.");
|
||||
|
||||
@ -776,17 +831,32 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
double last = 0;
|
||||
int req = 740;
|
||||
while(!done.get())
|
||||
{
|
||||
boolean derp = false;
|
||||
double v = (double) gx.getGenerated() / (double) req;
|
||||
|
||||
if(last > v || v > 1)
|
||||
{
|
||||
derp = true;
|
||||
v = last;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
last = v;
|
||||
}
|
||||
|
||||
for(Player i : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
imsg(i, "Generating " + Form.pc((double) gx.getGenerated() / (double) req));
|
||||
imsg(i, "Generating " + Form.pc(v) + (derp ? " (Waiting on Server...)" : ""));
|
||||
}
|
||||
J.sleep(3000);
|
||||
}
|
||||
});
|
||||
World world = Bukkit.createWorld(new WorldCreator("iris/" + UUID.randomUUID()).generator(gx));
|
||||
World world = Bukkit.createWorld(new WorldCreator("iris/" + UUID.randomUUID()).seed(1337).generator(gx).generateStructures(false).type(WorldType.NORMAL).environment(d.getEnvironment()));
|
||||
done.set(true);
|
||||
|
||||
for(Player i : Bukkit.getOnlinePlayers())
|
||||
|
@ -25,4 +25,9 @@ public class IrisMetrics
|
||||
perSecond = new RollingSequence(5);
|
||||
loss = new RollingSequence(memory);
|
||||
}
|
||||
|
||||
public double getSpeed()
|
||||
{
|
||||
return (double) Iris.instance.hits.getAverage() / (double) total.getAverage();
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import com.volmit.iris.IrisMetrics;
|
||||
import com.volmit.iris.util.BlockDataTools;
|
||||
import com.volmit.iris.util.CNG;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
@ -276,8 +277,22 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
|
||||
protected void fail(Throwable e)
|
||||
{
|
||||
if(failing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
failing = true;
|
||||
|
||||
e.printStackTrace();
|
||||
J.a(() ->
|
||||
{
|
||||
J.sleep(1000);
|
||||
Iris.error("---------------------------------------------------------------------------------------------------------");
|
||||
e.printStackTrace();
|
||||
Iris.error("---------------------------------------------------------------------------------------------------------");
|
||||
Iris.error("ERROR! Failed to generate chunk! Iris has entered a failed state!");
|
||||
Iris.error("---------------------------------------------------------------------------------------------------------");
|
||||
|
||||
for(Player i : world.getPlayers())
|
||||
{
|
||||
@ -285,8 +300,8 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
Iris.instance.imsg(i, ChatColor.RED + "- Check the console for the error.");
|
||||
Iris.instance.imsg(i, ChatColor.RED + "- Then simply run /iris dev");
|
||||
}
|
||||
});
|
||||
|
||||
e.printStackTrace();
|
||||
onFailure(e);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import com.volmit.iris.IrisContext;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.CNG;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
@ -103,6 +104,7 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
|
||||
@Override
|
||||
public void onHotloaded()
|
||||
{
|
||||
CNG.creates = 0;
|
||||
onHotload();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisBiomeMutation;
|
||||
import com.volmit.iris.object.IrisDepositGenerator;
|
||||
import com.volmit.iris.object.IrisObjectPlacement;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
@ -158,7 +159,12 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
|
||||
{
|
||||
setCaching(false);
|
||||
|
||||
if(getSliverCache().size() > 20000)
|
||||
{
|
||||
getSliverCache().clear();
|
||||
}
|
||||
|
||||
super.onPostGenerate(random, x, z, data, grid, height, biomeMap);
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
getBiomeHitCache().clear();
|
||||
@ -215,7 +221,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
protected void onGenerateParallax(RNG random, int x, int z)
|
||||
{
|
||||
String key = "par." + x + "." + "z";
|
||||
ChunkPosition rad = Iris.data.getObjectLoader().getParallaxSize();
|
||||
ChunkPosition rad = getDimension().getParallaxSize();
|
||||
KList<NastyRunnable> q = new KList<>();
|
||||
|
||||
for(int ii = x - (rad.getX() / 2); ii <= x + (rad.getX() / 2); ii++)
|
||||
@ -244,6 +250,36 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
|
||||
int g = 1;
|
||||
|
||||
searching: for(IrisBiomeMutation k : getDimension().getMutations())
|
||||
{
|
||||
for(int l = 0; l < k.getChecks(); l++)
|
||||
{
|
||||
IrisBiome sa = sampleTrueBiome(((i * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius()), ((j * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius())).getBiome();
|
||||
IrisBiome sb = sampleTrueBiome(((i * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius()), ((j * 16) + ro.nextInt(16)) + ro.i(-k.getRadius(), k.getRadius())).getBiome();
|
||||
|
||||
if(sa.getLoadKey().equals(sb.getLoadKey()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(k.getRealSideA().contains(sa.getLoadKey()) && k.getRealSideB().contains(sb.getLoadKey()))
|
||||
{
|
||||
for(IrisObjectPlacement m : k.getObjects())
|
||||
{
|
||||
int gg = g++;
|
||||
lockq.lock();
|
||||
q.add(() ->
|
||||
{
|
||||
placeObject(m, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + gg) * i * j) + i - j + 1569962));
|
||||
});
|
||||
lockq.unlock();
|
||||
}
|
||||
|
||||
continue searching;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisObjectPlacement k : b.getObjects())
|
||||
{
|
||||
int gg = g++;
|
||||
|
@ -50,7 +50,12 @@ public abstract class ParallelChunkGenerator extends BiomeChunkGenerator
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void onGenerateColumn(int cx, int cz, int wx, int wz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap);
|
||||
protected abstract void onGenerateColumn(int cx, int cz, int wx, int wz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap, int onlyY);
|
||||
|
||||
protected void onGenerateColumn(int cx, int cz, int wx, int wz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap)
|
||||
{
|
||||
onGenerateColumn(cx, cz, wx, wz, x, z, sliver, biomeMap, -1);
|
||||
}
|
||||
|
||||
protected abstract int onSampleColumnHeight(int cx, int cz, int wx, int wz, int x, int z);
|
||||
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.block.data.Bisected.Half;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.layer.GenLayerCave;
|
||||
import com.volmit.iris.object.DecorationPart;
|
||||
import com.volmit.iris.object.InferredType;
|
||||
@ -62,8 +63,19 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onGenerateColumn(int cx, int cz, int rx, int rz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap)
|
||||
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
|
||||
{
|
||||
super.onGenerate(random, x, z, data, grid);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onGenerateColumn(int cx, int cz, int rx, int rz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap, int onlyY)
|
||||
{
|
||||
if(x > 15 || x < 0 || z > 15 || z < 0)
|
||||
{
|
||||
throw new RuntimeException("Invalid OnGenerate call: x:" + x + " z:" + z);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BlockData block;
|
||||
@ -77,13 +89,27 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
int height = (int) Math.round(noise) + fluidHeight;
|
||||
IrisRegion region = sampleRegion(rx, rz);
|
||||
IrisBiome biome = sampleTrueBiome(rx, rz).getBiome();
|
||||
|
||||
if(biome == null)
|
||||
{
|
||||
throw new RuntimeException("Null Biome!");
|
||||
}
|
||||
|
||||
if(caching)
|
||||
{
|
||||
cacheLock.lock();
|
||||
try
|
||||
{
|
||||
cacheTrueBiome[(z << 4) | x] = biome;
|
||||
cacheHeightMap[(z << 4) | x] = height;
|
||||
cacheLock.unlock();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
Iris.error("Failed to write cache at " + x + " " + z + " in chunk " + cx + " " + cz);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
KList<BlockData> layers = biome.generateLayers(wx, wz, masterRandom, height, height - getFluidHeight());
|
||||
KList<BlockData> seaLayers = biome.isSea() ? biome.generateSeaLayers(wx, wz, masterRandom, fluidHeight - height) : new KList<>();
|
||||
cacheInternalBiome(x, z, biome);
|
||||
@ -100,12 +126,11 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
}
|
||||
}
|
||||
|
||||
// Set Biomes & Blocks from HEIGHT/FLUIDHEIGHT to 0
|
||||
for(int k = Math.max(height, fluidHeight); k >= 0; k--)
|
||||
{
|
||||
if(k == 0)
|
||||
{
|
||||
sliver.set(0, BEDROCK);
|
||||
sliver.set(k, BEDROCK);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -225,7 +250,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData d = i.getBlockData(getMasterRandom().nextParallelRNG(biome.hashCode() + j++), wx, wz);
|
||||
BlockData d = i.getBlockData(getMasterRandom().nextParallelRNG((int) (wx + wz + 38888 + biome.getRarity() + biome.getName().length() + j++)), wx, wz);
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
@ -254,7 +279,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
else
|
||||
{
|
||||
int stack = i.getHeight(getMasterRandom().nextParallelRNG(39456 + i.hashCode()), wx, wz);
|
||||
int stack = i.getHeight(getMasterRandom().nextParallelRNG((int) (39456 + (10000 * i.getChance()) + i.getStackMax() + i.getStackMin() + i.getZoom())), wx, wz);
|
||||
|
||||
if(stack == 1)
|
||||
{
|
||||
@ -286,7 +311,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
for(IrisBiomeDecorator i : biome.getDecorators())
|
||||
{
|
||||
BlockData d = i.getBlockData(getMasterRandom().nextParallelRNG(biome.hashCode() + j++), wx, wz);
|
||||
BlockData d = i.getBlockData(getMasterRandom().nextParallelRNG(2333877 + biome.getRarity() + biome.getName().length() + +j++), wx, wz);
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
@ -315,7 +340,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
else
|
||||
{
|
||||
int stack = i.getHeight(getMasterRandom().nextParallelRNG(39456 + i.hashCode()), wx, wz);
|
||||
int stack = i.getHeight(getMasterRandom().nextParallelRNG((int) (39456 + (1000 * i.getChance()) + i.getZoom() * 10)), wx, wz);
|
||||
|
||||
if(stack == 1)
|
||||
{
|
||||
@ -357,11 +382,11 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData d = i.getBlockData(getMasterRandom().nextParallelRNG(biome.hashCode() + j++), wx, wz);
|
||||
BlockData d = i.getBlockData(getMasterRandom().nextParallelRNG(2555 + biome.getRarity() + biome.getName().length() + j++), wx, wz);
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
int stack = i.getHeight(getMasterRandom().nextParallelRNG(39456 + i.hashCode()), wx, wz);
|
||||
int stack = i.getHeight(getMasterRandom().nextParallelRNG((int) (239456 + i.getStackMax() + i.getStackMin() + i.getVerticalZoom() + i.getZoom() + i.getBlockData().size() + j)), wx, wz);
|
||||
|
||||
if(stack == 1)
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ public class GenLayerBiome extends GenLayer
|
||||
return bridgeGenerator.getIndex(x, z, 5) == 1 ? InferredType.SEA : InferredType.LAND;
|
||||
}
|
||||
|
||||
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, CellGenerator cell, KList<String> biomes, InferredType inferredType)
|
||||
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, CellGenerator cell, KList<IrisBiome> biomes, InferredType inferredType)
|
||||
{
|
||||
if(biomes.isEmpty())
|
||||
{
|
||||
@ -128,7 +128,7 @@ public class GenLayerBiome extends GenLayer
|
||||
|
||||
double x = bx / iris.getDimension().getBiomeZoom();
|
||||
double z = bz / iris.getDimension().getBiomeZoom();
|
||||
IrisBiome biome = Iris.data.getBiomeLoader().load(biomes.get(cell.getIndex(x, z, biomes.size())));
|
||||
IrisBiome biome = biomes.get(cell.getIndex(x, z, biomes.size()));
|
||||
biome.setInferredType(inferredType);
|
||||
|
||||
return implode(bx, bz, regionData, cell, new BiomeResult(biome, cell.getDistance(x, z)));
|
||||
@ -169,19 +169,20 @@ public class GenLayerBiome extends GenLayer
|
||||
|
||||
double x = bx / iris.getDimension().getBiomeZoom();
|
||||
double z = bz / iris.getDimension().getBiomeZoom();
|
||||
|
||||
if(parent.getDistance() > regionData.getBiomeImplosionRatio())
|
||||
{
|
||||
if(!parent.getBiome().getChildren().isEmpty())
|
||||
if(!parent.getBiome().getRealChildren().isEmpty())
|
||||
{
|
||||
CellGenerator childCell = parent.getBiome().getChildrenGenerator(rng, 123, parentCell.getCellScale() * parent.getBiome().getChildShrinkFactor());
|
||||
int r = childCell.getIndex(x, z, parent.getBiome().getChildren().size() + 1);
|
||||
int r = childCell.getIndex(x, z, parent.getBiome().getRealChildren().size() + 1);
|
||||
|
||||
if(r == parent.getBiome().getChildren().size())
|
||||
if(r == parent.getBiome().getRealChildren().size())
|
||||
{
|
||||
return new BiomeResult(parent.getBiome(), childCell.getDistance(x, z));
|
||||
}
|
||||
|
||||
IrisBiome biome = Iris.data.getBiomeLoader().load(parent.getBiome().getChildren().get(r));
|
||||
IrisBiome biome = parent.getBiome().getRealChildren().get(r);
|
||||
biome.setInferredType(parent.getBiome().getInferredType());
|
||||
|
||||
return implode(bx, bz, regionData, childCell, new BiomeResult(biome, childCell.getDistance(x, z)), hits + 1);
|
||||
|
@ -5,11 +5,13 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.CNG;
|
||||
import com.volmit.iris.util.CellGenerator;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KSet;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Data;
|
||||
@ -103,6 +105,7 @@ public class IrisBiome extends IrisRegistrant
|
||||
private transient KList<CNG> layerSeaHeightGenerators;
|
||||
private transient KList<CNG> layerSurfaceGenerators;
|
||||
private transient KList<CNG> layerSeaSurfaceGenerators;
|
||||
private transient KList<IrisBiome> realChildren;
|
||||
|
||||
public IrisBiome()
|
||||
{
|
||||
@ -125,7 +128,7 @@ public class IrisBiome extends IrisRegistrant
|
||||
{
|
||||
if(biomeGenerator == null)
|
||||
{
|
||||
biomeGenerator = CNG.signature(random.nextParallelRNG(213949 + hashCode())).scale(biomeDispersion.equals(Dispersion.SCATTER) ? 1000D : 0.1D);
|
||||
biomeGenerator = CNG.signature(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length())).scale(biomeDispersion.equals(Dispersion.SCATTER) ? 1000D : 0.1D);
|
||||
}
|
||||
|
||||
return biomeGenerator;
|
||||
@ -389,6 +392,44 @@ public class IrisBiome extends IrisRegistrant
|
||||
return biomeSkyScatter.get(getBiomeGenerator(rng).fit(0, biomeSkyScatter.size() - 1, x, y, z));
|
||||
}
|
||||
|
||||
public KList<IrisBiome> getRealChildren()
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
if(realChildren == null)
|
||||
{
|
||||
realChildren = new KList<>();
|
||||
|
||||
for(String i : getChildren())
|
||||
{
|
||||
realChildren.add(Iris.data.getBiomeLoader().load(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
return realChildren;
|
||||
}
|
||||
|
||||
public KList<String> getAllChildren(int limit)
|
||||
{
|
||||
KSet<String> m = new KSet<>();
|
||||
m.addAll(getChildren());
|
||||
limit--;
|
||||
|
||||
if(limit > 0)
|
||||
{
|
||||
for(String i : getChildren())
|
||||
{
|
||||
IrisBiome b = Iris.data.getBiomeLoader().load(i);
|
||||
int l = limit;
|
||||
m.addAll(b.getAllChildren(l));
|
||||
}
|
||||
}
|
||||
|
||||
return new KList<String>(m);
|
||||
}
|
||||
|
||||
public Biome getGroundBiome(RNG rng, double x, double y, double z)
|
||||
{
|
||||
if(biomeSkyScatter.isEmpty())
|
||||
|
@ -59,7 +59,6 @@ public class IrisBiomeDecorator
|
||||
private transient KMap<Long, CNG> layerGenerators;
|
||||
private transient CNG heightGenerator;
|
||||
private transient KList<BlockData> blockData;
|
||||
private transient RNG nrng;
|
||||
|
||||
public int getHeight(RNG rng, double x, double z)
|
||||
{
|
||||
@ -121,19 +120,15 @@ public class IrisBiomeDecorator
|
||||
return null;
|
||||
}
|
||||
|
||||
if(nrng == null)
|
||||
{
|
||||
nrng = rng.nextParallelRNG(2398552 + hashCode());
|
||||
}
|
||||
|
||||
RNG nrng = rng.nextParallelRNG((int) (z - (int) ((x + 34856) * (int) (x + z + (int) (28835521 + (getChance() * 1000) + getStackMin() + getStackMax() + (getZoom() * 556))))));
|
||||
double xx = dispersion.equals(Dispersion.SCATTER) ? nrng.i(-100000, 100000) : x;
|
||||
double zz = dispersion.equals(Dispersion.SCATTER) ? nrng.i(-100000, 100000) : z;
|
||||
|
||||
if(getGenerator(rng).fitDoubleD(0D, 1D, xx, zz) <= chance)
|
||||
if(getGenerator(nrng).fitDoubleD(0D, 1D, xx, zz) <= chance)
|
||||
{
|
||||
try
|
||||
{
|
||||
return getBlockData().get(getGenerator(rng.nextParallelRNG(53)).fit(0, getBlockData().size() - 1, xx, zz));
|
||||
return getBlockData().get(getGenerator(rng.nextParallelRNG((int) (5369431 + z + x + xx + zz))).fit(0, getBlockData().size() - 1, xx, zz));
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
|
97
src/main/java/com/volmit/iris/object/IrisBiomeMutation.java
Normal file
97
src/main/java/com/volmit/iris/object/IrisBiomeMutation.java
Normal file
@ -0,0 +1,97 @@
|
||||
package com.volmit.iris.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KSet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Desc("A biome mutation if a condition is met")
|
||||
@Data
|
||||
public class IrisBiomeMutation
|
||||
{
|
||||
@DontObfuscate
|
||||
@Desc("One of The following biomes or regions must show up")
|
||||
private KList<String> sideA = new KList<>();
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("One of The following biomes or regions must show up")
|
||||
private KList<String> sideB = new KList<>();
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("The scan radius for placing this mutator")
|
||||
private int radius = 1;
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("How many tries per chunk to check for this mutation")
|
||||
private int checks = 2;
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("Objects define what schematics (iob files) iris will place in this biome mutation")
|
||||
private KList<IrisObjectPlacement> objects = new KList<IrisObjectPlacement>();
|
||||
|
||||
private transient KList<String> sideACache;
|
||||
private transient KList<String> sideBCache;
|
||||
|
||||
public KList<String> getRealSideA()
|
||||
{
|
||||
if(sideACache == null)
|
||||
{
|
||||
sideACache = processList(getSideA());
|
||||
}
|
||||
|
||||
return sideACache;
|
||||
}
|
||||
|
||||
public KList<String> getRealSideB()
|
||||
{
|
||||
if(sideBCache == null)
|
||||
{
|
||||
sideBCache = processList(getSideB());
|
||||
}
|
||||
|
||||
return sideBCache;
|
||||
}
|
||||
|
||||
public KList<String> processList(KList<String> s)
|
||||
{
|
||||
KSet<String> r = new KSet<>();
|
||||
|
||||
for(String i : s)
|
||||
{
|
||||
String q = i;
|
||||
|
||||
if(q.startsWith("^"))
|
||||
{
|
||||
r.addAll(Iris.data.getRegionLoader().load(q.substring(1)).getLandBiomes());
|
||||
continue;
|
||||
}
|
||||
|
||||
else if(q.startsWith("*"))
|
||||
{
|
||||
String name = q.substring(1);
|
||||
r.addAll(Iris.data.getBiomeLoader().load(name).getAllChildren(7));
|
||||
}
|
||||
|
||||
else if(q.startsWith("!"))
|
||||
{
|
||||
r.remove(q.substring(1));
|
||||
}
|
||||
|
||||
else if(q.startsWith("!*"))
|
||||
{
|
||||
String name = q.substring(2);
|
||||
r.removeAll(Iris.data.getBiomeLoader().load(name).getAllChildren(7));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
r.add(q);
|
||||
}
|
||||
}
|
||||
|
||||
return new KList<String>(r);
|
||||
}
|
||||
}
|
@ -97,6 +97,11 @@ public class IrisDepositGenerator
|
||||
return p;
|
||||
}
|
||||
|
||||
public int getMaxDimension()
|
||||
{
|
||||
return (int) Math.round(Math.pow(maxSize, 1D / 3D));
|
||||
}
|
||||
|
||||
private IrisObject generateClumpObject(RNG rngv)
|
||||
{
|
||||
int s = rngv.i(minSize, maxSize);
|
||||
|
@ -4,15 +4,18 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.generator.PostBlockChunkGenerator;
|
||||
import com.volmit.iris.util.BlockDataTools;
|
||||
import com.volmit.iris.util.CNG;
|
||||
import com.volmit.iris.util.ChunkPosition;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.IrisPostBlockFilter;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KSet;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Data;
|
||||
@ -171,7 +174,13 @@ public class IrisDimension extends IrisRegistrant
|
||||
@Desc("The palette of blocks for 'water'")
|
||||
private KList<String> fluidPalette = new KList<String>().qadd("WATER");
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("Define biome mutations for this dimension")
|
||||
private KList<IrisBiomeMutation> mutations = new KList<>();
|
||||
|
||||
private transient ChunkPosition parallaxSize;
|
||||
private transient ReentrantLock rockLock = new ReentrantLock();
|
||||
private transient ReentrantLock parLock = new ReentrantLock();
|
||||
private transient ReentrantLock fluidLock = new ReentrantLock();
|
||||
private transient KList<BlockData> rockData;
|
||||
private transient KList<BlockData> fluidData;
|
||||
@ -265,7 +274,7 @@ public class IrisDimension extends IrisRegistrant
|
||||
|
||||
public void cacheRockGenerator(RNG rng)
|
||||
{
|
||||
RNG rngx = rng.nextParallelRNG(getRockData().size() * hashCode());
|
||||
RNG rngx = rng.nextParallelRNG((int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
||||
|
||||
switch(dispersion)
|
||||
{
|
||||
@ -330,7 +339,7 @@ public class IrisDimension extends IrisRegistrant
|
||||
|
||||
public void cacheFluidGenerator(RNG rng)
|
||||
{
|
||||
RNG rngx = rng.nextParallelRNG(getFluidData().size() * hashCode());
|
||||
RNG rngx = rng.nextParallelRNG(getFluidData().size() * (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
||||
|
||||
switch(dispersion)
|
||||
{
|
||||
@ -394,4 +403,103 @@ public class IrisDimension extends IrisRegistrant
|
||||
|
||||
return cosr;
|
||||
}
|
||||
|
||||
public KList<IrisRegion> getAllRegions()
|
||||
{
|
||||
KList<IrisRegion> r = new KList<>();
|
||||
|
||||
for(String i : getRegions())
|
||||
{
|
||||
r.add(Iris.data.getRegionLoader().load(i));
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
public KList<IrisBiome> getAllBiomes()
|
||||
{
|
||||
KList<IrisBiome> r = new KList<>();
|
||||
|
||||
for(IrisRegion i : getAllRegions())
|
||||
{
|
||||
r.addAll(i.getAllBiomes());
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
public ChunkPosition getParallaxSize()
|
||||
{
|
||||
parLock.lock();
|
||||
|
||||
if(parallaxSize == null)
|
||||
{
|
||||
int x = 0;
|
||||
int z = 0;
|
||||
|
||||
KSet<String> objects = new KSet<>();
|
||||
KList<IrisRegion> r = getAllRegions();
|
||||
KList<IrisBiome> b = getAllBiomes();
|
||||
|
||||
for(IrisBiome i : b)
|
||||
{
|
||||
for(IrisObjectPlacement j : i.getObjects())
|
||||
{
|
||||
objects.addAll(j.getPlace());
|
||||
}
|
||||
}
|
||||
|
||||
for(String i : objects)
|
||||
{
|
||||
try
|
||||
{
|
||||
BlockVector bv = IrisObject.sampleSize(Iris.data.getObjectLoader().findFile(i));
|
||||
x = bv.getBlockX() > x ? bv.getBlockX() : x;
|
||||
z = bv.getBlockZ() > z ? bv.getBlockZ() : z;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator i : getDeposits())
|
||||
{
|
||||
int max = i.getMaxDimension();
|
||||
x = max > x ? max : x;
|
||||
z = max > z ? max : z;
|
||||
}
|
||||
|
||||
for(IrisRegion v : r)
|
||||
{
|
||||
for(IrisDepositGenerator i : v.getDeposits())
|
||||
{
|
||||
int max = i.getMaxDimension();
|
||||
x = max > x ? max : x;
|
||||
z = max > z ? max : z;
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisBiome v : b)
|
||||
{
|
||||
for(IrisDepositGenerator i : v.getDeposits())
|
||||
{
|
||||
int max = i.getMaxDimension();
|
||||
x = max > x ? max : x;
|
||||
z = max > z ? max : z;
|
||||
}
|
||||
}
|
||||
|
||||
x = (Math.max(x, 16) + 16) >> 4;
|
||||
z = (Math.max(z, 16) + 16) >> 4;
|
||||
x = x % 2 == 0 ? x + 1 : x;
|
||||
z = z % 2 == 0 ? z + 1 : z;
|
||||
parallaxSize = new ChunkPosition(x, z);
|
||||
Iris.info("Parallax Size: " + x + ", " + z);
|
||||
}
|
||||
|
||||
parLock.unlock();
|
||||
return parallaxSize;
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class IrisGenerator extends IrisRegistrant
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hc = hashCode();
|
||||
int hc = (int) ((cliffHeightMin * 10) + 10 + cliffHeightMax + interpolationScale * seed + offsetX + offsetZ);
|
||||
double h = 0;
|
||||
double tp = 0;
|
||||
|
||||
@ -93,12 +93,12 @@ public class IrisGenerator extends IrisRegistrant
|
||||
Iris.warn("Nan value on gen: " + getLoadKey() + ": H = " + h + " TP = " + tp + " OPACITY = " + opacity + " ZOOM = " + zoom);
|
||||
}
|
||||
|
||||
return hasCliffs() ? cliff(rx, rz, v, superSeed + 294596) : v;
|
||||
return hasCliffs() ? cliff(rx, rz, v, superSeed + 294596 + hc) : v;
|
||||
}
|
||||
|
||||
public double getCliffHeight(double rx, double rz, double superSeed)
|
||||
{
|
||||
int hc = hashCode();
|
||||
int hc = (int) ((cliffHeightMin * 10) + 10 + cliffHeightMax + interpolationScale * seed + offsetX + offsetZ);
|
||||
double h = cliffHeightGenerator.getNoise((long) (seed + superSeed + hc), (rx + offsetX) / zoom, (rz + offsetZ) / zoom);
|
||||
return IrisInterpolation.lerp(cliffHeightMin, cliffHeightMax, h);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
for(IrisObjectReplace j : config.getEdit())
|
||||
{
|
||||
if(j.getFind().matches(data))
|
||||
if(j.isExact() ? j.getFind().matches(data) : j.getFind().getMaterial().equals(data.getMaterial()))
|
||||
{
|
||||
data = j.getReplace();
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ public class IrisObjectReplace
|
||||
@DontObfuscate
|
||||
private String replace;
|
||||
|
||||
@DontObfuscate
|
||||
private boolean exact = false;
|
||||
|
||||
private transient ReentrantLock lock = new ReentrantLock();
|
||||
private transient BlockData findData;
|
||||
private transient BlockData replaceData;
|
||||
|
@ -107,6 +107,13 @@ public class IrisRegion extends IrisRegistrant
|
||||
private transient CNG shoreHeightGenerator;
|
||||
private transient ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
private transient KList<IrisBiome> realLandBiomes;
|
||||
private transient KList<IrisBiome> realSeaBiomes;
|
||||
private transient KList<IrisBiome> realShoreBiomes;
|
||||
private transient KList<IrisBiome> realIslandBiomes;
|
||||
private transient KList<IrisBiome> realSkylandBiomes;
|
||||
private transient KList<IrisBiome> realCaveBiomes;
|
||||
|
||||
public double getBiomeZoom(InferredType t)
|
||||
{
|
||||
switch(t)
|
||||
@ -165,7 +172,7 @@ public class IrisRegion extends IrisRegistrant
|
||||
if(shoreHeightGenerator == null)
|
||||
{
|
||||
lock.lock();
|
||||
shoreHeightGenerator = CNG.signature(new RNG(hashCode()));
|
||||
shoreHeightGenerator = CNG.signature(new RNG((long) (getName().length() + getIslandBiomes().size() + getLandBiomeZoom() + getLandBiomes().size() + 3458612)));
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
@ -202,38 +209,152 @@ public class IrisRegion extends IrisRegistrant
|
||||
return b.v();
|
||||
}
|
||||
|
||||
public KList<String> getBiomes(InferredType type)
|
||||
public KList<IrisBiome> getBiomes(InferredType type)
|
||||
{
|
||||
if(type.equals(InferredType.LAND))
|
||||
{
|
||||
return getLandBiomes();
|
||||
return getRealLandBiomes();
|
||||
}
|
||||
|
||||
else if(type.equals(InferredType.SEA))
|
||||
{
|
||||
return getSeaBiomes();
|
||||
return getRealSeaBiomes();
|
||||
}
|
||||
|
||||
else if(type.equals(InferredType.SHORE))
|
||||
{
|
||||
return getShoreBiomes();
|
||||
return getRealShoreBiomes();
|
||||
}
|
||||
|
||||
else if(type.equals(InferredType.CAVE))
|
||||
{
|
||||
return getCaveBiomes();
|
||||
return getRealCaveBiomes();
|
||||
}
|
||||
|
||||
else if(type.equals(InferredType.ISLAND))
|
||||
{
|
||||
return getIslandBiomes();
|
||||
return getRealIslandBiomes();
|
||||
}
|
||||
|
||||
else if(type.equals(InferredType.SKYLAND))
|
||||
{
|
||||
return getSkylandBiomes();
|
||||
return getRealSkylandBiomes();
|
||||
}
|
||||
|
||||
return new KList<>();
|
||||
}
|
||||
|
||||
public KList<IrisBiome> getRealCaveBiomes()
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
if(realCaveBiomes == null)
|
||||
{
|
||||
realCaveBiomes = new KList<>();
|
||||
|
||||
for(String i : getCaveBiomes())
|
||||
{
|
||||
realCaveBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
return realCaveBiomes;
|
||||
}
|
||||
|
||||
public KList<IrisBiome> getRealSkylandBiomes()
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
if(realSkylandBiomes == null)
|
||||
{
|
||||
realSkylandBiomes = new KList<>();
|
||||
|
||||
for(String i : getSkylandBiomes())
|
||||
{
|
||||
realSkylandBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
return realSkylandBiomes;
|
||||
}
|
||||
|
||||
public KList<IrisBiome> getRealIslandBiomes()
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
if(realIslandBiomes == null)
|
||||
{
|
||||
realIslandBiomes = new KList<>();
|
||||
|
||||
for(String i : getIslandBiomes())
|
||||
{
|
||||
realIslandBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
return realIslandBiomes;
|
||||
}
|
||||
|
||||
public KList<IrisBiome> getRealShoreBiomes()
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
if(realShoreBiomes == null)
|
||||
{
|
||||
realShoreBiomes = new KList<>();
|
||||
|
||||
for(String i : getShoreBiomes())
|
||||
{
|
||||
realShoreBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
return realShoreBiomes;
|
||||
}
|
||||
|
||||
public KList<IrisBiome> getRealSeaBiomes()
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
if(realSeaBiomes == null)
|
||||
{
|
||||
realSeaBiomes = new KList<>();
|
||||
|
||||
for(String i : getSeaBiomes())
|
||||
{
|
||||
realSeaBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
return realSeaBiomes;
|
||||
}
|
||||
|
||||
public KList<IrisBiome> getRealLandBiomes()
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
if(realLandBiomes == null)
|
||||
{
|
||||
realLandBiomes = new KList<>();
|
||||
|
||||
for(String i : getLandBiomes())
|
||||
{
|
||||
realLandBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
return realLandBiomes;
|
||||
}
|
||||
}
|
||||
|
@ -59,14 +59,14 @@ public class IrisRegionRidge
|
||||
{
|
||||
if(ridge == null)
|
||||
{
|
||||
ridge = new CellGenerator(rng.nextParallelRNG(165583 * hashCode()));
|
||||
ridge = new CellGenerator(rng.nextParallelRNG((int) (465583 * getChance())));
|
||||
ridge.setCellScale(scale);
|
||||
ridge.setShuffle(shuffle);
|
||||
}
|
||||
|
||||
if(spot == null)
|
||||
{
|
||||
spot = new CellGenerator(rng.nextParallelRNG(168523 * hashCode()));
|
||||
spot = new CellGenerator(rng.nextParallelRNG((int) (198523 * getChance())));
|
||||
spot.setCellScale(chanceScale);
|
||||
spot.setShuffle(shuffle);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class IrisRegionSpot
|
||||
{
|
||||
if(spot == null)
|
||||
{
|
||||
spot = new CellGenerator(rng.nextParallelRNG(168583 * hashCode()));
|
||||
spot = new CellGenerator(rng.nextParallelRNG((int) (168583 * (shuffle + 102) + rarity + (scale * 10465) + biome.length() + type.ordinal() + as.ordinal())));
|
||||
spot.setCellScale(scale);
|
||||
spot.setShuffle(shuffle);
|
||||
}
|
||||
|
@ -26,6 +26,11 @@ public class AtomicRegionData
|
||||
tag = new KMap<>();
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return tag.size();
|
||||
}
|
||||
|
||||
public void read(InputStream in) throws IOException
|
||||
{
|
||||
NBTInputStream nin = new NBTInputStream(in);
|
||||
|
@ -14,6 +14,7 @@ import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.util.BlockDataTools;
|
||||
import com.volmit.iris.util.HeightMap;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import com.volmit.iris.util.M;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -26,6 +27,7 @@ public class AtomicSliver
|
||||
private KMap<Integer, Biome> biome;
|
||||
private int highestBlock = 0;
|
||||
private int highestBiome = 0;
|
||||
private long last = M.ms();
|
||||
private int x;
|
||||
private int z;
|
||||
|
||||
@ -46,6 +48,7 @@ public class AtomicSliver
|
||||
public BlockData get(int h)
|
||||
{
|
||||
BlockData b = block.get(h);
|
||||
last = M.ms();
|
||||
|
||||
if(b == null)
|
||||
{
|
||||
@ -83,11 +86,13 @@ public class AtomicSliver
|
||||
|
||||
public Biome getBiome(int h)
|
||||
{
|
||||
last = M.ms();
|
||||
return biome.containsKey(h) ? biome.get(h) : Biome.THE_VOID;
|
||||
}
|
||||
|
||||
public IrisBiome getTrueBiome(int h)
|
||||
{
|
||||
last = M.ms();
|
||||
return truebiome.get(h);
|
||||
}
|
||||
|
||||
@ -185,4 +190,9 @@ public class AtomicSliver
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOlderThan(long m)
|
||||
{
|
||||
return M.ms() - last > m;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class AtomicWorldData
|
||||
private KMap<ChunkPosition, Long> lastRegion;
|
||||
private KMap<ChunkPosition, Long> lastChunk;
|
||||
private String prefix;
|
||||
private ChronoLatch cl = new ChronoLatch(15000);
|
||||
private ChronoLatch cl = new ChronoLatch(3000);
|
||||
|
||||
public AtomicWorldData(World world, String prefix)
|
||||
{
|
||||
@ -102,6 +102,7 @@ public class AtomicWorldData
|
||||
{
|
||||
if(!isSectionLoaded(s))
|
||||
{
|
||||
Iris.warn("Cant unload because section isnt loaded?");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -111,6 +112,7 @@ public class AtomicWorldData
|
||||
}
|
||||
|
||||
loadedSections.remove(s);
|
||||
lastRegion.remove(s);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -123,6 +125,8 @@ public class AtomicWorldData
|
||||
{
|
||||
if(!isSectionLoaded(s.getX(), s.getZ()))
|
||||
{
|
||||
Iris.warn("Cant save section " + s.getX() + " " + s.getZ() + " because section isnt loaded?");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -160,9 +164,10 @@ public class AtomicWorldData
|
||||
{
|
||||
int x = i.getX();
|
||||
int z = i.getZ();
|
||||
AtomicRegionData dat = loadSection(x >> 5, z >> 5);
|
||||
AtomicRegionData dat = loadSection(x >> 5, z >> 5, true);
|
||||
dat.set(x & 31, z & 31, loadedChunks.get(i));
|
||||
loadedChunks.remove(i);
|
||||
lastChunk.remove(i);
|
||||
}
|
||||
|
||||
public AtomicSliverMap loadChunk(int x, int z) throws IOException
|
||||
@ -186,10 +191,13 @@ public class AtomicWorldData
|
||||
return loadSection(x >> 5, z >> 5).contains(x & 31, z & 31);
|
||||
}
|
||||
|
||||
public AtomicRegionData loadSection(int x, int z) throws IOException
|
||||
public AtomicRegionData loadSection(int x, int z, boolean anonymous) throws IOException
|
||||
{
|
||||
ChunkPosition pos = new ChunkPosition(x, z);
|
||||
if(!anonymous)
|
||||
{
|
||||
lastRegion.put(pos, M.ms());
|
||||
}
|
||||
|
||||
if(isSectionLoaded(x, z))
|
||||
{
|
||||
@ -213,6 +221,11 @@ public class AtomicWorldData
|
||||
return data;
|
||||
}
|
||||
|
||||
public AtomicRegionData loadSection(int x, int z) throws IOException
|
||||
{
|
||||
return loadSection(x, z, false);
|
||||
}
|
||||
|
||||
public AtomicRegionData createSection(int x, int z)
|
||||
{
|
||||
if(isSectionLoaded(x, z))
|
||||
|
44
src/main/java/com/volmit/iris/tetris/TetrisGenerator.java
Normal file
44
src/main/java/com/volmit/iris/tetris/TetrisGenerator.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.volmit.iris.tetris;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TetrisGenerator
|
||||
{
|
||||
private int gridSize;
|
||||
|
||||
public int getGrid(int block)
|
||||
{
|
||||
return (int) Math.floor((double) block / (double) gridSize);
|
||||
}
|
||||
|
||||
public int getCenterFromGrid(int grid)
|
||||
{
|
||||
return (grid * gridSize) + (gridSize / 2);
|
||||
}
|
||||
|
||||
public int getCenterFromBlock(int block)
|
||||
{
|
||||
return getCenterFromGrid(getGrid(block));
|
||||
}
|
||||
|
||||
public int getMinFromGrid(int grid)
|
||||
{
|
||||
return (grid * gridSize);
|
||||
}
|
||||
|
||||
public int getMinFromBlock(int block)
|
||||
{
|
||||
return getMinFromGrid(getGrid(block));
|
||||
}
|
||||
|
||||
public int getMaxFromGrid(int grid)
|
||||
{
|
||||
return ((grid + 1) * gridSize) - 1;
|
||||
}
|
||||
|
||||
public int getMaxFromBlock(int block)
|
||||
{
|
||||
return getMaxFromGrid(getGrid(block));
|
||||
}
|
||||
}
|
20
src/main/java/com/volmit/iris/tetris/TetrisObject.java
Normal file
20
src/main/java/com/volmit/iris/tetris/TetrisObject.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.volmit.iris.tetris;
|
||||
|
||||
import com.volmit.iris.util.BlockPosition;
|
||||
import com.volmit.iris.util.KMap;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TetrisObject
|
||||
{
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private KMap<BlockPosition, BlockPosition> holes;
|
||||
|
||||
public TetrisObject(int x, int y, int z)
|
||||
{
|
||||
holes = new KMap<>();
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
public class ChunkPosition
|
||||
{
|
||||
private int x;
|
||||
@ -13,4 +12,45 @@ public class ChunkPosition
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x)
|
||||
{
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(int z)
|
||||
{
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!(obj instanceof ChunkPosition))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ChunkPosition other = (ChunkPosition) obj;
|
||||
return x == other.x && z == other.z;
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,11 @@ package com.volmit.iris.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.object.IrisObject;
|
||||
|
||||
public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
{
|
||||
private ChunkPosition parallaxSize;
|
||||
private ChronoLatch useFlip = new ChronoLatch(2863);
|
||||
private KMap<String, Long> useCache = new KMap<>();
|
||||
|
||||
@ -83,49 +80,9 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
Iris.info("Unloaded Object: " + v);
|
||||
}
|
||||
|
||||
public ChunkPosition getParallaxSize()
|
||||
{
|
||||
lock.lock();
|
||||
if(parallaxSize == null)
|
||||
{
|
||||
int x = 0;
|
||||
int z = 0;
|
||||
|
||||
for(File i : getFolders())
|
||||
{
|
||||
for(File j : i.listFiles())
|
||||
{
|
||||
if(j.isFile() && j.getName().endsWith(".iob"))
|
||||
{
|
||||
try
|
||||
{
|
||||
BlockVector b = IrisObject.sampleSize(j);
|
||||
x = b.getBlockX() > x ? b.getBlockX() : x;
|
||||
z = b.getBlockZ() > z ? b.getBlockZ() : z;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x = (Math.max(x, 16) + 16) >> 4;
|
||||
z = (Math.max(z, 16) + 16) >> 4;
|
||||
x = x % 2 == 0 ? x + 1 : x;
|
||||
z = z % 2 == 0 ? z + 1 : z;
|
||||
parallaxSize = new ChunkPosition(x, z);
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
|
||||
return parallaxSize;
|
||||
}
|
||||
|
||||
public IrisObject loadFile(File j, String key, String name)
|
||||
{
|
||||
lock.lock();
|
||||
try
|
||||
{
|
||||
IrisObject t = new IrisObject(0, 0, 0);
|
||||
@ -134,7 +91,6 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
Iris.hotloader.track(j);
|
||||
Iris.info("Loading " + resourceTypeName + ": " + j.getPath());
|
||||
t.setLoadKey(name);
|
||||
parallaxSize = null;
|
||||
lock.unlock();
|
||||
return t;
|
||||
}
|
||||
@ -156,6 +112,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
{
|
||||
if(j.isFile() && j.getName().endsWith(".iob") && j.getName().split("\\Q.\\E")[0].equals(name))
|
||||
{
|
||||
lock.unlock();
|
||||
return j;
|
||||
}
|
||||
}
|
||||
@ -164,6 +121,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
|
||||
if(file.exists())
|
||||
{
|
||||
lock.unlock();
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@ -193,6 +151,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
if(j.isFile() && j.getName().endsWith(".iob") && j.getName().split("\\Q.\\E")[0].equals(name))
|
||||
{
|
||||
useCache.put(key, M.ms());
|
||||
lock.unlock();
|
||||
return loadFile(j, key, name);
|
||||
}
|
||||
}
|
||||
@ -202,6 +161,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
if(file.exists())
|
||||
{
|
||||
useCache.put(key, M.ms());
|
||||
lock.unlock();
|
||||
return loadFile(file, key, name);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user