mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 23:36:12 +00:00
Loads of fixes
This commit is contained in:
@@ -133,6 +133,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
@Override
|
||||
public Biome genColumn(int wxx, int wzx, int x, int z, ChunkPlan plan)
|
||||
{
|
||||
int highest = 0;
|
||||
int seaLevel = Iris.settings.gen.seaLevel;
|
||||
double wx = Math.round((double) wxx * Iris.settings.gen.horizontalZoom);
|
||||
double wz = Math.round((double) wzx * Iris.settings.gen.horizontalZoom);
|
||||
@@ -144,7 +145,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
int max = Math.max(height, seaLevel);
|
||||
IrisBiome override = null;
|
||||
|
||||
if(height > 61 && height < 65)
|
||||
if(height > 61 && height < 65 + (glLNoise.getHeight(wz, wx) * 24D))
|
||||
{
|
||||
override = biome("Beach");
|
||||
}
|
||||
@@ -191,6 +192,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
if(!mbx.material.equals(Material.AIR))
|
||||
{
|
||||
setBlock(x, i + 1, z, mbx.material, mbx.data);
|
||||
highest = i > highest ? i : highest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,10 +207,11 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
}
|
||||
|
||||
setBlock(x, i, z, mb.material, mb.data);
|
||||
highest = i > highest ? i : highest;
|
||||
}
|
||||
|
||||
glCaves.genCaves(wxx, wzx, x, z, height, this);
|
||||
|
||||
plan.setRealHeight(x, z, highest);
|
||||
return biome.getRealBiome();
|
||||
}
|
||||
|
||||
@@ -221,7 +224,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
@Override
|
||||
public void onPostChunk(World world, int x, int z, Random random, AtomicChunkData data, ChunkPlan plan)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -229,7 +232,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
GList<BlockPopulator> p = new GList<>();
|
||||
|
||||
if(Iris.settings.gen.doSchematics)
|
||||
if(Iris.settings.gen.genObjects)
|
||||
{
|
||||
p.add(new GenObjectDecorator(this));
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.placer.NMSPlacer;
|
||||
import ninja.bytecode.iris.util.Direction;
|
||||
import ninja.bytecode.iris.util.IPlacer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
@@ -35,12 +36,14 @@ public class GenObject
|
||||
private BlockVector mount;
|
||||
private int mountHeight;
|
||||
private BlockVector shift;
|
||||
private boolean cascading;
|
||||
|
||||
public GenObject(int w, int h, int d)
|
||||
{
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.d = d;
|
||||
cascading = false;
|
||||
shift = new BlockVector();
|
||||
s = new GMap<>();
|
||||
centeredHeight = false;
|
||||
@@ -121,6 +124,41 @@ public class GenObject
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return w;
|
||||
}
|
||||
|
||||
public int getDepth()
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
public int getAntiCascadeWidth()
|
||||
{
|
||||
if(isCascading())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 16 - w;
|
||||
}
|
||||
|
||||
public int getAntiCascadeDepth()
|
||||
{
|
||||
if(isCascading())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 16 - d;
|
||||
}
|
||||
|
||||
public boolean isCascading()
|
||||
{
|
||||
return cascading;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void read(InputStream in) throws IOException
|
||||
@@ -130,6 +168,7 @@ public class GenObject
|
||||
w = din.readInt();
|
||||
h = din.readInt();
|
||||
d = din.readInt();
|
||||
cascading = w > Iris.settings.performance.cascadeLimit || d > Iris.settings.performance.cascadeLimit;
|
||||
int l = din.readInt();
|
||||
clear();
|
||||
|
||||
@@ -203,12 +242,12 @@ public class GenObject
|
||||
int m = (g / 2);
|
||||
return g % 2 == 0 ? m : m + 1;
|
||||
}
|
||||
|
||||
|
||||
public void place(Location l)
|
||||
{
|
||||
place(l, Iris.settings.performance.placerType.get(l.getWorld()));
|
||||
place(l, new NMSPlacer(l.getWorld()));
|
||||
}
|
||||
|
||||
|
||||
public void place(Location l, IPlacer placer)
|
||||
{
|
||||
place(l.getBlockX(), l.getBlockY(), l.getBlockZ(), placer);
|
||||
|
||||
@@ -15,10 +15,12 @@ import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.controller.PackController;
|
||||
import ninja.bytecode.iris.controller.TimingsController;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.placer.NMSPlacer;
|
||||
import ninja.bytecode.iris.pack.IrisBiome;
|
||||
import ninja.bytecode.iris.util.IPlacer;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.collections.GSet;
|
||||
import ninja.bytecode.shuriken.execution.ChronoLatch;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
|
||||
@@ -26,7 +28,9 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
{
|
||||
private GMap<Biome, IrisBiome> biomeMap;
|
||||
private GMap<Biome, GMap<GenObjectGroup, Double>> populationCache;
|
||||
private IPlacer cascadingPlacer;
|
||||
private IPlacer placer;
|
||||
private ChronoLatch cl = new ChronoLatch(1000);
|
||||
|
||||
public GenObjectDecorator(IrisGenerator generator)
|
||||
{
|
||||
@@ -37,13 +41,14 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
{
|
||||
biomeMap.put(i.getRealBiome(), i);
|
||||
|
||||
GMap<GenObjectGroup, Double> gk = new GMap<>();
|
||||
GMap<GenObjectGroup, Double> gc = new GMap<>();
|
||||
|
||||
for(String j : i.getSchematicGroups().k())
|
||||
{
|
||||
try
|
||||
{
|
||||
gk.put(Iris.getController(PackController.class).getGenObjectGroups().get(j), i.getSchematicGroups().get(j));
|
||||
GenObjectGroup g = Iris.getController(PackController.class).getGenObjectGroups().get(j);
|
||||
gc.put(g, i.getSchematicGroups().get(j));
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
@@ -53,13 +58,17 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
}
|
||||
}
|
||||
|
||||
populationCache.put(i.getRealBiome(), gk);
|
||||
if(!gc.isEmpty())
|
||||
{
|
||||
populationCache.put(i.getRealBiome(), gc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(World world, Random random, Chunk source)
|
||||
public void populate(World world, Random rnotusingyou, Chunk source)
|
||||
{
|
||||
Random random = new Random(((source.getX() - 32) * (source.getZ() + 54)) + world.getSeed());
|
||||
Iris.getController(TimingsController.class).started("decor");
|
||||
GSet<Biome> hits = new GSet<>();
|
||||
|
||||
@@ -108,17 +117,22 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
|
||||
if(!t.isSolid() || !ibiome.isSurface(t))
|
||||
{
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(placer == null)
|
||||
if(cascadingPlacer == null)
|
||||
{
|
||||
placer = Iris.settings.performance.placerType.get(world);
|
||||
cascadingPlacer = new NMSPlacer(world);
|
||||
}
|
||||
|
||||
i.getSchematics().get(random.nextInt(i.getSchematics().size())).place(x, b.getY(), z, placer);
|
||||
|
||||
i.getSchematics().get(random.nextInt(i.getSchematics().size())).place(x, b.getY(), z, cascadingPlacer);
|
||||
}
|
||||
}
|
||||
|
||||
if(placer != null && cl.flip())
|
||||
{
|
||||
placer.flush();
|
||||
}
|
||||
}
|
||||
|
||||
public int getTries(double chance)
|
||||
|
||||
@@ -21,6 +21,7 @@ public class GenObjectGroup
|
||||
private GList<String> flags;
|
||||
private String name;
|
||||
private int priority;
|
||||
private boolean noCascade;
|
||||
|
||||
public GenObjectGroup(String name)
|
||||
{
|
||||
@@ -28,6 +29,7 @@ public class GenObjectGroup
|
||||
this.flags = new GList<>();
|
||||
priority = 0;
|
||||
this.name = name;
|
||||
this.noCascade = false;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@@ -85,7 +87,6 @@ public class GenObjectGroup
|
||||
|
||||
for(File i : folder.listFiles())
|
||||
{
|
||||
|
||||
if(i.getName().endsWith(".ifl"))
|
||||
{
|
||||
try
|
||||
@@ -162,7 +163,18 @@ public class GenObjectGroup
|
||||
|
||||
gg.execute();
|
||||
ex.close();
|
||||
L.i(ChatColor.LIGHT_PURPLE + "Processed " + ChatColor.WHITE + F.f(schematics.size()) + ChatColor.LIGHT_PURPLE + " Schematics in " + ChatColor.WHITE + name);
|
||||
noCascade = true;
|
||||
|
||||
for(GenObject i : getSchematics())
|
||||
{
|
||||
if(i.isCascading())
|
||||
{
|
||||
noCascade = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
L.i(ChatColor.LIGHT_PURPLE + "Processed " + ChatColor.WHITE + F.f(schematics.size()) + ChatColor.LIGHT_PURPLE + " Schematics in " + ChatColor.WHITE + name + (noCascade ? ChatColor.AQUA + "*" : ChatColor.YELLOW + "^"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -204,4 +216,9 @@ public class GenObjectGroup
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isCascading()
|
||||
{
|
||||
return !noCascade;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,29 +40,29 @@ public class GenLayerBiome extends GenLayer
|
||||
pathCheck = new CNG(rng.nextParallelRNG(31), 1D, 1).scale(0.00096);
|
||||
roads = new MaxingGenerator(rng.nextParallelRNG(32), 5, 0.00055, 8, factory);
|
||||
//@done
|
||||
|
||||
|
||||
GMap<String, IrisRegion> regions = new GMap<>();
|
||||
|
||||
|
||||
for(IrisBiome i : biomes)
|
||||
{
|
||||
if(!regions.containsKey(i.getRegion()))
|
||||
{
|
||||
regions.put(i.getRegion(), new IrisRegion(i.getRegion()));
|
||||
}
|
||||
|
||||
|
||||
regions.get(i.getRegion()).getBiomes().add(i);
|
||||
}
|
||||
|
||||
int v = 85034;
|
||||
regionGenerator = new EnumMaxingGenerator<IrisRegion>(rng.nextParallelRNG(v), 0.00522 * Iris.settings.gen.biomeScale * 0.189, 1, regions.v().toArray(new IrisRegion[regions.v().size()]), factory);
|
||||
|
||||
|
||||
for(IrisRegion i : regions.v())
|
||||
{
|
||||
v += 13 - i.getName().length();
|
||||
i.setGen(new EnumMaxingGenerator<IrisBiome>(rng.nextParallelRNG(33 + v), 0.000755 * i.getBiomes().size() * Iris.settings.gen.biomeScale, 1, i.getBiomes().toArray(new IrisBiome[i.getBiomes().size()]), factory));
|
||||
i.setGen(new EnumMaxingGenerator<IrisBiome>(rng.nextParallelRNG(33 + v), 0.000255 * i.getBiomes().size() * Iris.settings.gen.biomeScale, 1, i.getBiomes().toArray(new IrisBiome[i.getBiomes().size()]), factory));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public EnumMaxingGenerator<IrisBiome> getRegionGenerator(double xx, double zz)
|
||||
{
|
||||
return regionGenerator.getChoice(xx, zz).getGen();
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package ninja.bytecode.iris.generator.placer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.util.AtomicChunkData;
|
||||
import ninja.bytecode.iris.util.ChunkPlan;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.iris.util.Placer;
|
||||
|
||||
public class AtomicPlacer extends Placer
|
||||
{
|
||||
private AtomicChunkData data;
|
||||
private ChunkPlan plan;
|
||||
|
||||
public AtomicPlacer(World world)
|
||||
{
|
||||
super(world);
|
||||
}
|
||||
|
||||
public void bind(AtomicChunkData data, ChunkPlan plan)
|
||||
{
|
||||
this.data = data;
|
||||
this.plan = plan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MB get(Location l)
|
||||
{
|
||||
return MB.of(data.getType(l.getBlockX(), l.getBlockY(), l.getBlockZ()), data.getData(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void set(Location l, MB mb)
|
||||
{
|
||||
data.setBlock(l.getBlockX(), l.getBlockY(), l.getBlockZ(), mb.material.getId(), mb.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestY(Location l)
|
||||
{
|
||||
return plan.getRealHeight(l.getBlockX(), l.getBlockZ());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package ninja.bytecode.iris.generator.placer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.iris.util.Placer;
|
||||
|
||||
public class BukkitPlacer extends Placer
|
||||
{
|
||||
private final boolean applyPhysics;
|
||||
|
||||
public BukkitPlacer(World world, boolean applyPhysics)
|
||||
{
|
||||
super(world);
|
||||
this.applyPhysics = applyPhysics;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public MB get(Location l)
|
||||
{
|
||||
Block b = world.getBlockAt(l);
|
||||
return MB.of(b.getType(), b.getData());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void set(Location l, MB mb)
|
||||
{
|
||||
l.getBlock().setTypeIdAndData(mb.material.getId(), mb.data, applyPhysics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestY(Location l)
|
||||
{
|
||||
return world.getHighestBlockYAt(l);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package ninja.bytecode.iris.generator.placer;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mortar.api.nms.Catalyst;
|
||||
import mortar.api.nms.NMP;
|
||||
import mortar.api.world.MaterialBlock;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.iris.util.Placer;
|
||||
import ninja.bytecode.shuriken.collections.GSet;
|
||||
|
||||
public class NMSPlacer extends Placer
|
||||
{
|
||||
private GSet<Chunk> c;
|
||||
|
||||
public NMSPlacer(World world)
|
||||
{
|
||||
super(world);
|
||||
c = new GSet<>();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public MB get(Location l)
|
||||
{
|
||||
Block b = world.getBlockAt(l);
|
||||
return MB.of(b.getType(), b.getData());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void set(Location l, MB mb)
|
||||
{
|
||||
Catalyst.host.setBlock(l, new MaterialBlock(mb.material.getId(), mb.data));
|
||||
c.add(l.getChunk());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestY(Location l)
|
||||
{
|
||||
return world.getHighestBlockYAt(l);
|
||||
}
|
||||
|
||||
public void flush()
|
||||
{
|
||||
for(Chunk i : c)
|
||||
{
|
||||
for(Player j : NMP.CHUNK.nearbyPlayers(i))
|
||||
{
|
||||
NMP.CHUNK.refresh(j, i);
|
||||
}
|
||||
}
|
||||
|
||||
c.clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user