Reloading & Resource copying

This commit is contained in:
Daniel Mills
2020-01-08 19:07:28 -05:00
parent 1b88e132cc
commit da55612726
4 changed files with 33 additions and 20 deletions

View File

@@ -284,7 +284,7 @@ public class GenObject
for(BlockVector i : g.k())
{
MB mb = rotate(from, to, g.get(i));
MB mb = g.get(i);
s.put(VectorMath.rotate(from, to, i).toBlockVector(), mb);
}

View File

@@ -10,6 +10,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.generator.BlockPopulator;
import net.md_5.bungee.api.ChatColor;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.iris.controller.TimingsController;
@@ -17,6 +18,7 @@ import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.collections.GSet;
import ninja.bytecode.shuriken.logging.L;
import ninja.bytecode.shuriken.math.M;
public class GenObjectDecorator extends BlockPopulator
@@ -37,7 +39,16 @@ public class GenObjectDecorator extends BlockPopulator
for(String j : i.getSchematicGroups().k())
{
gk.put(Iris.getController(PackController.class).getGenObjectGroups().get(j), i.getSchematicGroups().get(j));
try
{
gk.put(Iris.getController(PackController.class).getGenObjectGroups().get(j), i.getSchematicGroups().get(j));
}
catch(Throwable e)
{
L.f(ChatColor.RED + "Failed to inject " + j + " into GenObjectDecorator");
L.ex(e);
}
}
populationCache.put(i.getRealBiome(), gk);
@@ -49,39 +60,39 @@ public class GenObjectDecorator extends BlockPopulator
{
Iris.getController(TimingsController.class).started("decor");
GSet<Biome> 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);
if(hits.contains(biome))
{
continue;
}
IrisBiome ibiome = biomeMap.get(biome);
if(ibiome == null)
{
continue;
}
GMap<GenObjectGroup, Double> objects = populationCache.get(biome);
if(objects == null)
{
continue;
}
hits.add(biome);
populate(world, random, source, biome, ibiome, objects);
}
Iris.getController(TimingsController.class).stopped("decor");
}
private void populate(World world, Random random, Chunk source, Biome biome, IrisBiome ibiome, GMap<GenObjectGroup, Double> objects)
{
for(GenObjectGroup i : objects.k())
@@ -92,12 +103,12 @@ public class GenObjectDecorator extends BlockPopulator
int z = (source.getZ() << 4) + random.nextInt(16);
Block b = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN);
Material t = b.getType();
if(!t.isSolid() || !ibiome.isSurface(t))
{
return;
}
i.getSchematics().get(random.nextInt(i.getSchematics().size())).place(world, x, b.getY(), z);
}
}
@@ -114,14 +125,14 @@ public class GenObjectDecorator extends BlockPopulator
{
return (int) chance;
}
int floor = (int) Math.floor(chance);
if(chance - floor > 0 && M.r(chance - floor))
{
floor++;
}
return floor;
}
}