mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-06 07:46:08 +00:00
Le Pregenerator with headless mode
This commit is contained in:
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine;
|
||||
|
||||
import com.volmit.iris.core.IrisDataManager;
|
||||
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class IrisWorldCreator {
|
||||
private String name;
|
||||
private boolean studio = false;
|
||||
private String dimensionName = null;
|
||||
private long seed = 1337;
|
||||
private int maxHeight = 256;
|
||||
private int minHeight = 0;
|
||||
|
||||
public IrisWorldCreator() {
|
||||
|
||||
}
|
||||
|
||||
public IrisWorldCreator dimension(String loadKey) {
|
||||
this.dimensionName = loadKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisWorldCreator height(int maxHeight) {
|
||||
this.maxHeight = maxHeight;
|
||||
this.minHeight = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisWorldCreator height(int minHeight, int maxHeight) {
|
||||
this.maxHeight = maxHeight;
|
||||
this.minHeight = minHeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisWorldCreator name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisWorldCreator seed(long seed) {
|
||||
this.seed = seed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisWorldCreator studioMode() {
|
||||
this.studio = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisWorldCreator productionMode() {
|
||||
this.studio = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WorldCreator create() {
|
||||
EngineCompositeGenerator g = new EngineCompositeGenerator(dimensionName, !studio);
|
||||
g.initialize(IrisWorld.builder()
|
||||
.name(name)
|
||||
.minHeight(minHeight)
|
||||
.maxHeight(maxHeight)
|
||||
.seed(seed)
|
||||
.worldFolder(new File(name))
|
||||
.environment(findEnvironment())
|
||||
.build());
|
||||
return new WorldCreator(name)
|
||||
.environment(findEnvironment())
|
||||
.generateStructures(true)
|
||||
.generator(g).seed(seed);
|
||||
}
|
||||
|
||||
private World.Environment findEnvironment() {
|
||||
IrisDimension dim = IrisDataManager.loadAnyDimension(dimensionName);
|
||||
if (dim == null || dim.getEnvironment() == null) {
|
||||
return World.Environment.NORMAL;
|
||||
} else {
|
||||
return dim.getEnvironment();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.framework.IrisAccess;
|
||||
import com.volmit.iris.engine.framework.IrisAccessProvider;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class IrisWorlds {
|
||||
private static final KMap<String, IrisAccess> provisioned = new KMap<>();
|
||||
|
||||
public static void register(World w, IrisAccess p) {
|
||||
provisioned.put(w.getUID().toString(), p);
|
||||
}
|
||||
|
||||
public static boolean isIrisWorld(World world) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (provisioned.containsKey(world.getUID().toString())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return world.getGenerator() instanceof IrisAccess || world.getGenerator() instanceof IrisAccessProvider;
|
||||
}
|
||||
|
||||
public static IrisAccess access(World world) {
|
||||
if (isIrisWorld(world)) {
|
||||
if (provisioned.containsKey(world.getUID().toString())) {
|
||||
return provisioned.get(world.getUID().toString());
|
||||
}
|
||||
|
||||
return world.getGenerator() instanceof IrisAccessProvider ? (((IrisAccessProvider) world.getGenerator()).getAccess()) : ((IrisAccess) world.getGenerator());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean evacuate(World world) {
|
||||
for (World i : Bukkit.getWorlds()) {
|
||||
if (!i.getName().equals(world.getName())) {
|
||||
for (Player j : world.getPlayers()) {
|
||||
new VolmitSender(j, Iris.instance.getTag()).sendMessage("You have been evacuated from this world.");
|
||||
j.teleport(i.getSpawnLocation());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean evacuate(World world, String m) {
|
||||
for (World i : Bukkit.getWorlds()) {
|
||||
if (!i.getName().equals(world.getName())) {
|
||||
for (Player j : world.getPlayers()) {
|
||||
new VolmitSender(j, Iris.instance.getTag()).sendMessage("You have been evacuated from this world. " + m);
|
||||
j.teleport(i.getSpawnLocation());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -26,11 +26,10 @@ import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.core.pregenerator.PregenListener;
|
||||
import com.volmit.iris.core.pregenerator.PregenTask;
|
||||
import com.volmit.iris.engine.IrisEngineCompound;
|
||||
import com.volmit.iris.engine.IrisWorlds;
|
||||
import com.volmit.iris.engine.cache.Cache;
|
||||
import com.volmit.iris.engine.data.B;
|
||||
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||
import com.volmit.iris.engine.data.mca.NBTWorld;
|
||||
import com.volmit.iris.engine.headless.HeadlessGenerator;
|
||||
import com.volmit.iris.engine.hunk.Hunk;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
@@ -78,6 +77,8 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
private final boolean production;
|
||||
private final KList<BlockPopulator> populators;
|
||||
private long mst = 0;
|
||||
private HeadlessGenerator headlessGenerator;
|
||||
private NBTWorld nbtWorld;
|
||||
private int generated = 0;
|
||||
private int lgenerated = 0;
|
||||
private final ChronoLatch hotloadcd;
|
||||
@@ -460,6 +461,26 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
return tc.getRaw();
|
||||
}
|
||||
|
||||
public void assignHeadlessGenerator(HeadlessGenerator headlessGenerator)
|
||||
{
|
||||
this.headlessGenerator = headlessGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HeadlessGenerator getHeadlessGenerator() {
|
||||
return headlessGenerator;
|
||||
}
|
||||
|
||||
public void assignHeadlessNBTWriter(NBTWorld writer)
|
||||
{
|
||||
this.nbtWorld = writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTWorld getHeadlessNBTWriter() {
|
||||
return nbtWorld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void directWriteMCA(IrisWorld w, int x, int z, NBTWorld writer, MultiBurst burst) {
|
||||
directWriteMCA(w, x, z, writer, burst, null);
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.volmit.iris.core.pregenerator.PregenListener;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.data.DataProvider;
|
||||
import com.volmit.iris.engine.data.mca.NBTWorld;
|
||||
import com.volmit.iris.engine.headless.HeadlessGenerator;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||
@@ -46,6 +47,14 @@ import java.util.function.Consumer;
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
public interface IrisAccess extends Hotloadable, DataProvider {
|
||||
|
||||
HeadlessGenerator getHeadlessGenerator();
|
||||
|
||||
default boolean isHeadless(){
|
||||
return getHeadlessGenerator() != null;
|
||||
}
|
||||
|
||||
NBTWorld getHeadlessNBTWriter();
|
||||
|
||||
void directWriteMCA(IrisWorld w, int x, int z, NBTWorld writer, MultiBurst burst);
|
||||
|
||||
void directWriteMCA(IrisWorld w, int x, int z, NBTWorld writer, MultiBurst burst, PregenListener listener);
|
||||
|
||||
@@ -37,9 +37,11 @@ public class HeadlessGenerator {
|
||||
{
|
||||
this.world = world;
|
||||
burst = new MultiBurst("Iris Headless Generator", 9, Runtime.getRuntime().availableProcessors());
|
||||
generator = new EngineCompositeGenerator(world.getDimension().getLoadKey(), true);
|
||||
generator.initialize(world.getWorld());
|
||||
writer = new NBTWorld(world.getWorld().worldFolder());
|
||||
generator = new EngineCompositeGenerator(world.getDimension().getLoadKey(), !world.isStudio());
|
||||
generator.assignHeadlessGenerator(this);
|
||||
generator.assignHeadlessNBTWriter(writer);
|
||||
generator.initialize(world.getWorld());
|
||||
}
|
||||
|
||||
public void generateChunk(int x, int z)
|
||||
|
||||
@@ -20,9 +20,8 @@ package com.volmit.iris.engine.headless;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisDataManager;
|
||||
import com.volmit.iris.engine.IrisWorlds;
|
||||
import com.volmit.iris.core.tools.IrisWorlds;
|
||||
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
|
||||
import com.volmit.iris.engine.framework.IrisAccess;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
@@ -39,11 +38,18 @@ public class HeadlessWorld {
|
||||
private final IrisDimension dimension;
|
||||
private final String worldName;
|
||||
private final IrisWorld world;
|
||||
private boolean studio = false;
|
||||
|
||||
public HeadlessWorld(String worldName, IrisDimension dimension, long seed)
|
||||
{
|
||||
this(worldName, dimension, seed, false);
|
||||
}
|
||||
|
||||
public HeadlessWorld(String worldName, IrisDimension dimension, long seed, boolean studio)
|
||||
{
|
||||
this.worldName = worldName;
|
||||
this.dimension = dimension;
|
||||
this.studio = studio;
|
||||
world = IrisWorld.builder()
|
||||
.environment(dimension.getEnvironment())
|
||||
.worldFolder(new File(worldName))
|
||||
@@ -55,7 +61,7 @@ public class HeadlessWorld {
|
||||
world.worldFolder().mkdirs();
|
||||
new File(world.worldFolder(), "region").mkdirs();
|
||||
|
||||
if(!new File(world.worldFolder(), "iris").exists())
|
||||
if(!studio && !new File(world.worldFolder(), "iris").exists())
|
||||
{
|
||||
Iris.proj.installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag("Headless")), dimension.getLoadKey(), world.worldFolder());
|
||||
}
|
||||
@@ -71,7 +77,7 @@ public class HeadlessWorld {
|
||||
return new WorldCreator(worldName)
|
||||
.environment(dimension.getEnvironment())
|
||||
.seed(world.seed())
|
||||
.generator(new EngineCompositeGenerator(dimension.getLoadKey(), true))
|
||||
.generator(new EngineCompositeGenerator(dimension.getLoadKey(), !studio))
|
||||
.createWorld();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package com.volmit.iris.engine.jigsaw;
|
||||
|
||||
import com.volmit.iris.core.IrisDataManager;
|
||||
import com.volmit.iris.engine.IrisWorlds;
|
||||
import com.volmit.iris.core.tools.IrisWorlds;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.IrisAccess;
|
||||
import com.volmit.iris.engine.object.*;
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.volmit.iris.engine.jigsaw;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisDataManager;
|
||||
import com.volmit.iris.engine.IrisWorlds;
|
||||
import com.volmit.iris.core.tools.IrisWorlds;
|
||||
import com.volmit.iris.engine.framework.EngineParallaxManager;
|
||||
import com.volmit.iris.engine.framework.IrisAccess;
|
||||
import com.volmit.iris.engine.interpolation.InterpolationMethod;
|
||||
|
||||
Reference in New Issue
Block a user