mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 23:47:21 +00:00
remove "smart" vanilla height (#1150)
This commit is contained in:
parent
4f6da95d8e
commit
66c66e82c1
@ -779,7 +779,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
service(StudioSVC.class).installIntoWorld(getSender(), dim.getLoadKey(), w.worldFolder());
|
service(StudioSVC.class).installIntoWorld(getSender(), dim.getLoadKey(), w.worldFolder());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey(), false);
|
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void splash() {
|
public void splash() {
|
||||||
|
@ -20,9 +20,7 @@ package com.volmit.iris.core.commands;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.ServerConfigurator;
|
|
||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.nms.datapack.DataVersion;
|
|
||||||
import com.volmit.iris.core.pregenerator.ChunkUpdater;
|
import com.volmit.iris.core.pregenerator.ChunkUpdater;
|
||||||
import com.volmit.iris.core.service.StudioSVC;
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
import com.volmit.iris.core.tools.IrisBenchmarking;
|
import com.volmit.iris.core.tools.IrisBenchmarking;
|
||||||
@ -43,9 +41,7 @@ import com.volmit.iris.util.format.C;
|
|||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Difficulty;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -55,10 +51,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.io.Console;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -94,9 +88,7 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
@Param(aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "default")
|
@Param(aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "default")
|
||||||
IrisDimension type,
|
IrisDimension type,
|
||||||
@Param(description = "The seed to generate the world with", defaultValue = "1337")
|
@Param(description = "The seed to generate the world with", defaultValue = "1337")
|
||||||
long seed,
|
long seed
|
||||||
@Param(description = "If it should convert the dimension to match the vanilla height system.", defaultValue = "false")
|
|
||||||
boolean vanillaheight
|
|
||||||
) {
|
) {
|
||||||
if(sender() instanceof Player) {
|
if(sender() instanceof Player) {
|
||||||
if (incompatibilities.get("Multiverse-Core")) {
|
if (incompatibilities.get("Multiverse-Core")) {
|
||||||
@ -140,7 +132,6 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
.seed(seed)
|
.seed(seed)
|
||||||
.sender(sender())
|
.sender(sender())
|
||||||
.studio(false)
|
.studio(false)
|
||||||
.smartVanillaHeight(vanillaheight)
|
|
||||||
.create();
|
.create();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
sender().sendMessage(C.RED + "Exception raised during creation. See the console for more details.");
|
sender().sendMessage(C.RED + "Exception raised during creation. See the console for more details.");
|
||||||
@ -649,6 +640,6 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
ff.mkdirs();
|
ff.mkdirs();
|
||||||
service(StudioSVC.class).installIntoWorld(sender, dim.getLoadKey(), ff.getParentFile());
|
service(StudioSVC.class).installIntoWorld(sender, dim.getLoadKey(), ff.getParentFile());
|
||||||
}
|
}
|
||||||
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey(), false);
|
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,6 @@ public class IrisCreator {
|
|||||||
* Benchmark mode
|
* Benchmark mode
|
||||||
*/
|
*/
|
||||||
private boolean benchmark = false;
|
private boolean benchmark = false;
|
||||||
private boolean smartVanillaHeight = false;
|
|
||||||
|
|
||||||
public static boolean removeFromBukkitYml(String name) throws IOException {
|
public static boolean removeFromBukkitYml(String name) throws IOException {
|
||||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML);
|
YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML);
|
||||||
@ -137,7 +136,6 @@ public class IrisCreator {
|
|||||||
.name(name)
|
.name(name)
|
||||||
.seed(seed)
|
.seed(seed)
|
||||||
.studio(studio)
|
.studio(studio)
|
||||||
.smartVanillaHeight(smartVanillaHeight)
|
|
||||||
.create();
|
.create();
|
||||||
ServerConfigurator.installDataPacks(false);
|
ServerConfigurator.installDataPacks(false);
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ public class IrisWorldCreator {
|
|||||||
private String name;
|
private String name;
|
||||||
private boolean studio = false;
|
private boolean studio = false;
|
||||||
private String dimensionName = null;
|
private String dimensionName = null;
|
||||||
private boolean smartVanillaHeight = false;
|
|
||||||
private long seed = 1337;
|
private long seed = 1337;
|
||||||
|
|
||||||
public IrisWorldCreator() {
|
public IrisWorldCreator() {
|
||||||
@ -64,11 +63,6 @@ public class IrisWorldCreator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisWorldCreator smartVanillaHeight(boolean smartVanillaHeight) {
|
|
||||||
this.smartVanillaHeight = smartVanillaHeight;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorldCreator create() {
|
public WorldCreator create() {
|
||||||
IrisDimension dim = IrisData.loadAnyDimension(dimensionName);
|
IrisDimension dim = IrisData.loadAnyDimension(dimensionName);
|
||||||
|
|
||||||
@ -82,7 +76,7 @@ public class IrisWorldCreator {
|
|||||||
.build();
|
.build();
|
||||||
ChunkGenerator g = new BukkitChunkGenerator(w, studio, studio
|
ChunkGenerator g = new BukkitChunkGenerator(w, studio, studio
|
||||||
? dim.getLoader().getDataFolder() :
|
? dim.getLoader().getDataFolder() :
|
||||||
new File(w.worldFolder(), "iris/pack"), dimensionName, smartVanillaHeight);
|
new File(w.worldFolder(), "iris/pack"), dimensionName);
|
||||||
|
|
||||||
|
|
||||||
return new WorldCreator(name)
|
return new WorldCreator(name)
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
|
||||||
import com.volmit.iris.engine.object.annotations.*;
|
import com.volmit.iris.engine.object.annotations.*;
|
||||||
import com.volmit.iris.util.data.DataProvider;
|
import com.volmit.iris.util.data.DataProvider;
|
||||||
import com.volmit.iris.util.interpolation.IrisInterpolation;
|
import com.volmit.iris.util.interpolation.IrisInterpolation;
|
||||||
@ -39,18 +37,16 @@ public class IrisBiomeGeneratorLink {
|
|||||||
@RegistryListResource(IrisGenerator.class)
|
@RegistryListResource(IrisGenerator.class)
|
||||||
@Desc("The generator id")
|
@Desc("The generator id")
|
||||||
private String generator = "default";
|
private String generator = "default";
|
||||||
@DependsOn({ "min", "max" })
|
@DependsOn({"min", "max"})
|
||||||
@Required
|
@Required
|
||||||
@MinNumber(-2032) // TODO: WARNING HEIGHT
|
@MinNumber(-2032) // TODO: WARNING HEIGHT
|
||||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||||
@Desc("The min block value (value + fluidHeight)")
|
@Desc("The min block value (value + fluidHeight)")
|
||||||
@Getter(AccessLevel.NONE)
|
|
||||||
private int min = 0;
|
private int min = 0;
|
||||||
@DependsOn({ "min", "max" })
|
@DependsOn({"min", "max"})
|
||||||
@Required
|
@Required
|
||||||
@MinNumber(-2032) // TODO: WARNING HEIGHT
|
@MinNumber(-2032) // TODO: WARNING HEIGHT
|
||||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||||
@Getter(AccessLevel.NONE)
|
|
||||||
@Desc("The max block value (value + fluidHeight)")
|
@Desc("The max block value (value + fluidHeight)")
|
||||||
private int max = 0;
|
private int max = 0;
|
||||||
|
|
||||||
@ -66,70 +62,6 @@ public class IrisBiomeGeneratorLink {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] getBiomeGeneratorsRaw(Engine engine) {
|
|
||||||
int max = engine.getDimension().getMinHeight();
|
|
||||||
int min = engine.getDimension().getMaxHeight();
|
|
||||||
for (IrisBiome biome : engine.getAllBiomes()) {
|
|
||||||
for (IrisBiomeGeneratorLink i : biome.getGenerators()) {
|
|
||||||
int biomeRawMax = i.getMaxRaw();
|
|
||||||
int biomeRawMin = i.getMinRaw();
|
|
||||||
if (max < biomeRawMax)
|
|
||||||
max = biomeRawMax;
|
|
||||||
if (min > biomeRawMin)
|
|
||||||
min = biomeRawMin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new int[] { min, max };
|
|
||||||
}
|
|
||||||
|
|
||||||
private int calculateHeight(Engine engine, int option) {
|
|
||||||
int dmx = engine.getDimension().getMaxHeight();
|
|
||||||
int dmn = engine.getDimension().getMinHeight();
|
|
||||||
int[] heights = getBiomeGeneratorsRaw(engine);
|
|
||||||
int gmx = heights[1];
|
|
||||||
int gmn = heights[0];
|
|
||||||
|
|
||||||
int mx = getMaxRaw();
|
|
||||||
int mn = getMinRaw();
|
|
||||||
if (engine.getDimension().isSmartVanillaHeight()) {
|
|
||||||
if (mx > 0)
|
|
||||||
mx = Math.min((int) (((float) mx / (float) gmx) * 300.0f), 300);
|
|
||||||
if (mx < 0)
|
|
||||||
mx = Math.min((int) (((float) mx / (float) gmn) * 300.0f), 56);
|
|
||||||
|
|
||||||
if (mn > 0)
|
|
||||||
mn = Math.min((int) (((float) mn / (float) gmx) * 300.0f), 300);
|
|
||||||
if (mn < 0)
|
|
||||||
mn = Math.min((int) (((float) mn / (float) gmn) * 300.0f), 56);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (option == 1) {
|
|
||||||
return mx;
|
|
||||||
}
|
|
||||||
if (option == 0) {
|
|
||||||
return mn;
|
|
||||||
}
|
|
||||||
Iris.error("Fatal Generator error!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMax(Engine engine) {
|
|
||||||
return calculateHeight(engine, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMin(Engine engine) {
|
|
||||||
return calculateHeight(engine, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getMaxRaw() {
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getMinRaw() {
|
|
||||||
return min;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getHeight(DataProvider xg, double x, double z, long seed) {
|
public double getHeight(DataProvider xg, double x, double z, long seed) {
|
||||||
double g = getCachedGenerator(xg).getHeight(x, z, seed);
|
double g = getCachedGenerator(xg).getHeight(x, z, seed);
|
||||||
g = g < 0 ? 0 : g;
|
g = g < 0 ? 0 : g;
|
||||||
|
@ -234,8 +234,6 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
private IrisRange dimensionHeightEnd = new IrisRange(-64, 320);
|
private IrisRange dimensionHeightEnd = new IrisRange(-64, 320);
|
||||||
@Desc("Define the min and max Y bounds of this dimension. Please keep in mind that Iris internally generates from 0 to (max - min). \n\nFor example at -64 to 320, Iris is internally generating to 0 to 384, then on outputting chunks, it shifts it down by the min height (64 blocks). The default is -64 to 320. \n\nThe fluid height is placed at (fluid height + min height). So a fluid height of 63 would actually show up in the world at 1.")
|
@Desc("Define the min and max Y bounds of this dimension. Please keep in mind that Iris internally generates from 0 to (max - min). \n\nFor example at -64 to 320, Iris is internally generating to 0 to 384, then on outputting chunks, it shifts it down by the min height (64 blocks). The default is -64 to 320. \n\nThe fluid height is placed at (fluid height + min height). So a fluid height of 63 would actually show up in the world at 1.")
|
||||||
private IrisRange dimensionHeightNether = new IrisRange(-64, 320);
|
private IrisRange dimensionHeightNether = new IrisRange(-64, 320);
|
||||||
@Desc("Enable smart vanilla height")
|
|
||||||
private boolean smartVanillaHeight = false;
|
|
||||||
@RegistryListResource(IrisBiome.class)
|
@RegistryListResource(IrisBiome.class)
|
||||||
@Desc("Keep this either undefined or empty. Setting any biome name into this will force iris to only generate the specified biome. Great for testing.")
|
@Desc("Keep this either undefined or empty. Setting any biome name into this will force iris to only generate the specified biome. Great for testing.")
|
||||||
private String focus = "";
|
private String focus = "";
|
||||||
|
@ -58,8 +58,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -86,7 +84,6 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
private final boolean studio;
|
private final boolean studio;
|
||||||
private final AtomicInteger a = new AtomicInteger(0);
|
private final AtomicInteger a = new AtomicInteger(0);
|
||||||
private final CompletableFuture<Integer> spawnChunks = new CompletableFuture<>();
|
private final CompletableFuture<Integer> spawnChunks = new CompletableFuture<>();
|
||||||
private final boolean smartVanillaHeight;
|
|
||||||
private Engine engine;
|
private Engine engine;
|
||||||
private Looper hotloader;
|
private Looper hotloader;
|
||||||
private StudioMode lastMode;
|
private StudioMode lastMode;
|
||||||
@ -96,7 +93,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
|
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
|
|
||||||
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey, boolean smartVanillaHeight) {
|
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
|
||||||
setup = new AtomicBoolean(false);
|
setup = new AtomicBoolean(false);
|
||||||
studioGenerator = null;
|
studioGenerator = null;
|
||||||
dummyBiomeProvider = new DummyBiomeProvider();
|
dummyBiomeProvider = new DummyBiomeProvider();
|
||||||
@ -108,7 +105,6 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
this.dataLocation = dataLocation;
|
this.dataLocation = dataLocation;
|
||||||
this.dimensionKey = dimensionKey;
|
this.dimensionKey = dimensionKey;
|
||||||
this.folder = new ReactiveFolder(dataLocation, (_a, _b, _c) -> hotload());
|
this.folder = new ReactiveFolder(dataLocation, (_a, _b, _c) -> hotload());
|
||||||
this.smartVanillaHeight = smartVanillaHeight;
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(this, Iris.instance);
|
Bukkit.getServer().getPluginManager().registerEvents(this, Iris.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,14 +182,6 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
throw new RuntimeException("Missing Dimension: " + dimensionKey);
|
throw new RuntimeException("Missing Dimension: " + dimensionKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (smartVanillaHeight) {
|
|
||||||
dimension.setSmartVanillaHeight(true);
|
|
||||||
try (FileWriter writer = new FileWriter(data.getDimensionLoader().fileFor(dimension))) {
|
|
||||||
writer.write(data.getGson().toJson(dimension));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lastMode = StudioMode.NORMAL;
|
lastMode = StudioMode.NORMAL;
|
||||||
engine = new IrisEngine(new EngineTarget(world, dimension, data), studio);
|
engine = new IrisEngine(new EngineTarget(world, dimension, data), studio);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user