Fixes for biome derivatives

This commit is contained in:
Daniel Mills 2020-01-16 01:49:19 -05:00
parent 84e49a266d
commit 3b90a58418

View File

@ -5,7 +5,6 @@ import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.generator.BlockPopulator;
@ -26,20 +25,18 @@ import ninja.bytecode.shuriken.math.M;
public class GenObjectDecorator extends BlockPopulator
{
private GMap<Biome, IrisBiome> biomeMap;
private GMap<Biome, GMap<GenObjectGroup, Double>> populationCache;
private GMap<IrisBiome, GMap<GenObjectGroup, Double>> populationCache;
private IPlacer placer;
private IrisGenerator g;
private ChronoLatch cl = new ChronoLatch(250);
public GenObjectDecorator(IrisGenerator generator)
{
biomeMap = new GMap<>();
this.g = generator;
populationCache = new GMap<>();
for(IrisBiome i : generator.getLoadedBiomes())
{
biomeMap.put(i.getRealBiome(), i);
GMap<GenObjectGroup, Double> gc = new GMap<>();
for(String j : i.getSchematicGroups().k())
@ -62,7 +59,7 @@ public class GenObjectDecorator extends BlockPopulator
if(!gc.isEmpty())
{
populationCache.put(i.getRealBiome(), gc);
populationCache.put(i, gc);
}
}
}
@ -74,26 +71,19 @@ public class GenObjectDecorator extends BlockPopulator
{
Random random = new Random(((source.getX() - 32) * (source.getZ() + 54)) + world.getSeed());
Iris.getController(TimingsController.class).started("decor");
GSet<Biome> hits = new GSet<>();
GSet<IrisBiome> hits = new GSet<>();
for(int i = 0; i < Iris.settings.performance.decorationAccuracy; i++)
{
int x = (source.getX() << 4) + random.nextInt(16);
int z = (source.getZ() << 4) + random.nextInt(16);
Biome biome = world.getBiome(x, z);
IrisBiome biome = g.getBiome(x, z);
if(hits.contains(biome))
{
continue;
}
IrisBiome ibiome = biomeMap.get(biome);
if(ibiome == null)
{
continue;
}
GMap<GenObjectGroup, Double> objects = populationCache.get(biome);
if(objects == null)
@ -102,7 +92,7 @@ public class GenObjectDecorator extends BlockPopulator
}
hits.add(biome);
populate(world, random, source, biome, ibiome, objects);
populate(world, random, source, biome, objects);
}
Iris.getController(TimingsController.class).stopped("decor");
@ -114,7 +104,7 @@ public class GenObjectDecorator extends BlockPopulator
}
}
private void populate(World world, Random random, Chunk source, Biome biome, IrisBiome ibiome, GMap<GenObjectGroup, Double> objects)
private void populate(World world, Random random, Chunk source, IrisBiome biome, GMap<GenObjectGroup, Double> objects)
{
for(GenObjectGroup i : objects.k())
{
@ -125,7 +115,7 @@ public class GenObjectDecorator extends BlockPopulator
Block b = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN);
Material t = b.getType();
if(!t.isSolid() || !ibiome.isSurface(t))
if(!t.isSolid() || !biome.isSurface(t))
{
continue;
}