This commit is contained in:
Daniel Mills 2020-10-16 01:59:18 -04:00
parent 1a7aa1218a
commit c7f612dac0
10 changed files with 38 additions and 20 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>bytecode.ninja</groupId>
<artifactId>Iris</artifactId>
<version>1.0.12</version>
<version>1.0.13</version>
<name>Iris</name>
<properties>
<skip.copy>false</skip.copy>

View File

@ -81,6 +81,20 @@ public class Iris extends MortarPlugin
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4gb
}
public static int getThreadCount()
{
int tc = IrisSettings.get().forceThreadCount;
if(tc <= 0)
{
int p = Runtime.getRuntime().availableProcessors();
return p > 16 ? 16 : p < 4 ? 4 : p;
}
return tc;
}
private static String findNMSTag()
{
try
@ -253,7 +267,7 @@ public class Iris extends MortarPlugin
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
{
// @NoArgsConstructor
return createProvisionBukkit(IrisGenConfiguration.builder().threads(IrisSettings.get().threads).target(TerrainTarget.builder().environment(Environment.NORMAL).folder(new File(worldName)).name(worldName).seed(worldName.hashCode()).build()).build());
return createProvisionBukkit(IrisGenConfiguration.builder().threads(getThreadCount()).target(TerrainTarget.builder().environment(Environment.NORMAL).folder(new File(worldName)).name(worldName).seed(worldName.hashCode()).build()).build());
//@done
}

View File

@ -20,7 +20,7 @@ public class IrisSettings
@DontObfuscate
@Desc("Iris generator threads (must be 2 or higher). Threads in iris are not a perfect scale for performance as a lot of data has to be shared. 16 Threads is a good rule of thumb. Use 8 threads on a quad core processor.")
public int threads = 16;
public int forceThreadCount = -1;
@DontObfuscate
@Desc("The default world type incase iris doesnt have a dimension to use.")

View File

@ -8,7 +8,6 @@ import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.gen.IrisTerrainProvider;
import com.volmit.iris.gen.nms.NMSCreator;
import com.volmit.iris.gen.provisions.ProvisionBukkit;
@ -56,13 +55,13 @@ public class CommandIrisCreate extends MortarCommand
seed = i.startsWith("seed=") ? Long.valueOf(i.split("\\Q=\\E")[1]) : seed;
pregen = i.startsWith("pregen=") ? Integer.parseInt(i.split("\\Q=\\E")[1]) : pregen;
}
IrisDimension dim = Iris.proj.installIntoWorld(sender, type, folder);
//@builder
ProvisionBukkit gen = Iris.instance.createProvisionBukkit(
IrisGenConfiguration.builder()
.threads(IrisSettings.get().threads)
.threads(Iris.getThreadCount())
.dimension(dim.getLoadKey())
.target(TerrainTarget
.builder()
@ -74,7 +73,7 @@ public class CommandIrisCreate extends MortarCommand
).build());
//@done
sender.sendMessage("Generating with " + IrisSettings.get().threads + " threads per chunk");
sender.sendMessage("Generating with " + Iris.getThreadCount() + " threads per chunk");
O<Boolean> done = new O<Boolean>();
done.set(false);

View File

@ -126,11 +126,6 @@ public abstract class DimensionalTerrainProvider extends ContextualTerrainProvid
{
IrisDimension d = loadDimension(getDimensionName());
if(d == null)
{
Iris.error("Can't find dimension: " + getDimensionName());
}
return d;
}

View File

@ -9,6 +9,7 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.generator.BlockPopulator;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.gen.atomics.AtomicSliver;
import com.volmit.iris.gen.atomics.AtomicSliverMap;
@ -353,6 +354,16 @@ public abstract class ParallaxTerrainProvider extends TopographicTerrainProvider
placeObject(k, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + g++) * i * j) + i - j + 3566522));
}
if(r == null)
{
Iris.error("R Null");
}
if(r.getSurfaceObjects() == null)
{
Iris.error("Surface objects null");
}
if(r != null)
{
for(IrisObjectPlacement k : r.getSurfaceObjects())

View File

@ -15,7 +15,6 @@ import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.gen.IrisTerrainProvider;
import com.volmit.iris.gen.scaffold.HeightedFakeWorld;
import com.volmit.iris.gen.scaffold.Provisioned;
@ -38,7 +37,7 @@ public class ProvisionBukkit extends ChunkGenerator implements Provisioned
private final TerrainProvider provider;
private final KMap<ChunkPosition, TerrainChunk> precache;
private KList<ChunkPosition> regenerated = new KList<ChunkPosition>();
private Executor e = Executors.newFixedThreadPool(IrisSettings.get().getThreads());
private Executor e = Executors.newFixedThreadPool(Iris.getThreadCount());
private World cachedWorld;
public ProvisionBukkit(TerrainProvider provider)

View File

@ -131,7 +131,7 @@ public class IrisProject
//@builder
ProvisionBukkit gen = Iris.instance
.createProvisionBukkit(IrisGenConfiguration.builder()
.threads(IrisSettings.get().threads)
.threads(Iris.getThreadCount())
.dimension(getName())
.target(TerrainTarget.builder()
.environment(d.getEnvironment())
@ -144,7 +144,7 @@ public class IrisProject
IrisTerrainProvider gx = (IrisTerrainProvider) gen.getProvider();
gx.setDev(true);
sender.sendMessage("Generating with " + IrisSettings.get().threads + " threads per chunk");
sender.sendMessage("Generating with " + Iris.getThreadCount() + " threads per chunk");
O<Boolean> done = new O<Boolean>();
done.set(false);
activeProvider = gx;

View File

@ -229,8 +229,8 @@ public class IrisRegion extends IrisRegistrant implements IRare
@Desc("Generate rivers in this region")
private double riverThickness = 0.1;
private final transient AtomicCache<KList<IrisObjectPlacement>> surfaceObjectsCache = new AtomicCache<>(true);
private final transient AtomicCache<KList<IrisObjectPlacement>> carveObjectsCache = new AtomicCache<>(true);
private final transient AtomicCache<KList<IrisObjectPlacement>> surfaceObjectsCache = new AtomicCache<>();
private final transient AtomicCache<KList<IrisObjectPlacement>> carveObjectsCache = new AtomicCache<>();
private final transient AtomicCache<KList<String>> cacheRidge = new AtomicCache<>();
private final transient AtomicCache<KList<String>> cacheSpot = new AtomicCache<>();
private final transient AtomicCache<CNG> shoreHeightGenerator = new AtomicCache<>();
@ -412,7 +412,7 @@ public class IrisRegion extends IrisRegistrant implements IRare
{
continue;
}
names.add(biome.getCarvingBiome());
b.put(biome.getLoadKey(), biome);
names.addAll(biome.getChildren());

View File

@ -185,7 +185,7 @@ public class ResourceLoader<T extends IrisRegistrant>
}
}
if(warn)
if(warn && !resourceTypeName.equals("Dimension"))
{
J.a(() -> Iris.warn("Couldn't find " + resourceTypeName + ": " + name));
}