mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-21 11:43:27 +00:00
implement complete world height isolation
This commit is contained in:
parent
9c151abac7
commit
3415e7c7af
@ -26,7 +26,6 @@ import com.volmit.iris.core.nms.datapack.IDataFixer;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisBiomeCustom;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.IrisRange;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
@ -34,8 +33,8 @@ import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.misc.ServerProperties;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -45,12 +44,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicIntegerArray;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.volmit.iris.core.nms.datapack.IDataFixer.Dimension.*;
|
||||
|
||||
public class ServerConfigurator {
|
||||
public static void configure() {
|
||||
IrisSettings.IrisSettingsAutoconfiguration s = IrisSettings.get().getAutoConfiguration();
|
||||
@ -112,14 +111,16 @@ public class ServerConfigurator {
|
||||
KList<File> folders = getDatapacksFolder();
|
||||
KMap<String, KSet<String>> biomes = new KMap<>();
|
||||
|
||||
allPacks().flatMap(height::merge)
|
||||
.parallel()
|
||||
.forEach(dim -> {
|
||||
Iris.verbose(" Checking Dimension " + dim.getLoadFile().getPath());
|
||||
dim.installBiomes(fixer, dim::getLoader, folders, biomes.computeIfAbsent(dim.getLoadKey(), k -> new KSet<>()));
|
||||
});
|
||||
try (Stream<IrisData> stream = allPacks()) {
|
||||
stream.flatMap(height::merge)
|
||||
.parallel()
|
||||
.forEach(dim -> {
|
||||
Iris.verbose(" Checking Dimension " + dim.getLoadFile().getPath());
|
||||
dim.installBiomes(fixer, dim::getLoader, folders, biomes.computeIfAbsent(dim.getLoadKey(), k -> new KSet<>()));
|
||||
dim.installDimensionType(fixer, folders);
|
||||
});
|
||||
}
|
||||
IrisDimension.writeShared(folders, height);
|
||||
|
||||
Iris.info("Data Packs Setup!");
|
||||
|
||||
if (fullInstall)
|
||||
@ -127,19 +128,21 @@ public class ServerConfigurator {
|
||||
}
|
||||
|
||||
private static void verifyDataPacksPost(boolean allowRestarting) {
|
||||
boolean bad = allPacks()
|
||||
.map(data -> {
|
||||
Iris.verbose("Checking Pack: " + data.getDataFolder().getPath());
|
||||
var loader = data.getDimensionLoader();
|
||||
return loader.loadAll(loader.getPossibleKeys())
|
||||
.stream()
|
||||
.map(ServerConfigurator::verifyDataPackInstalled)
|
||||
.toList()
|
||||
.contains(false);
|
||||
})
|
||||
.toList()
|
||||
.contains(true);
|
||||
if (!bad) return;
|
||||
try (Stream<IrisData> stream = allPacks()) {
|
||||
boolean bad = stream
|
||||
.map(data -> {
|
||||
Iris.verbose("Checking Pack: " + data.getDataFolder().getPath());
|
||||
var loader = data.getDimensionLoader();
|
||||
return loader.loadAll(loader.getPossibleKeys())
|
||||
.stream()
|
||||
.map(ServerConfigurator::verifyDataPackInstalled)
|
||||
.toList()
|
||||
.contains(false);
|
||||
})
|
||||
.toList()
|
||||
.contains(true);
|
||||
if (!bad) return;
|
||||
}
|
||||
|
||||
|
||||
if (allowRestarting) {
|
||||
@ -239,20 +242,24 @@ public class ServerConfigurator {
|
||||
return path.substring(worldContainer.length(), path.length() - l);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static Stream<File> listFiles(File parent) {
|
||||
var files = parent.listFiles();
|
||||
return files == null ? Stream.empty() : Arrays.stream(files);
|
||||
if (!parent.isDirectory()) return Stream.empty();
|
||||
return Files.walk(parent.toPath()).map(Path::toFile);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class DimensionHeight {
|
||||
private final IDataFixer fixer;
|
||||
private IrisRange overworld = new IrisRange();
|
||||
private IrisRange nether = new IrisRange();
|
||||
private IrisRange end = new IrisRange();
|
||||
private int logicalOverworld = 0;
|
||||
private int logicalNether = 0;
|
||||
private int logicalEnd = 0;
|
||||
private final AtomicIntegerArray[] dimensions = new AtomicIntegerArray[3];
|
||||
|
||||
public DimensionHeight(IDataFixer fixer) {
|
||||
this.fixer = fixer;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
dimensions[i] = new AtomicIntegerArray(new int[]{
|
||||
Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public Stream<IrisDimension> merge(IrisData data) {
|
||||
Iris.verbose("Checking Pack: " + data.getDataFolder().getPath());
|
||||
@ -263,25 +270,29 @@ public class ServerConfigurator {
|
||||
}
|
||||
|
||||
public void merge(IrisDimension dimension) {
|
||||
overworld.merge(dimension.getDimensionHeight());
|
||||
nether.merge(dimension.getDimensionHeight());
|
||||
end.merge(dimension.getDimensionHeight());
|
||||
|
||||
logicalOverworld = Math.max(logicalOverworld, dimension.getLogicalHeight());
|
||||
logicalNether = Math.max(logicalNether, dimension.getLogicalHeightNether());
|
||||
logicalEnd = Math.max(logicalEnd, dimension.getLogicalHeightEnd());
|
||||
AtomicIntegerArray array = dimensions[dimension.getBaseDimension().ordinal()];
|
||||
array.updateAndGet(0, min -> Math.min(min, dimension.getMinHeight()));
|
||||
array.updateAndGet(1, max -> Math.max(max, dimension.getMaxHeight()));
|
||||
array.updateAndGet(2, logical -> Math.max(logical, dimension.getLogicalHeight()));
|
||||
}
|
||||
|
||||
public String overworldType() {
|
||||
return fixer.createDimension(OVERRWORLD, overworld, logicalOverworld).toString(4);
|
||||
public String[] jsonStrings() {
|
||||
var dims = IDataFixer.Dimension.values();
|
||||
var arr = new String[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
arr[i] = jsonString(dims[i]);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public String netherType() {
|
||||
return fixer.createDimension(NETHER, nether, logicalNether).toString(4);
|
||||
}
|
||||
|
||||
public String endType() {
|
||||
return fixer.createDimension(THE_END, end, logicalEnd).toString(4);
|
||||
public String jsonString(IDataFixer.Dimension dimension) {
|
||||
var data = dimensions[dimension.ordinal()];
|
||||
int minY = data.get(0);
|
||||
int maxY = data.get(1);
|
||||
int logicalHeight = data.get(2);
|
||||
if (minY == Integer.MAX_VALUE || maxY == Integer.MIN_VALUE || Integer.MIN_VALUE == logicalHeight)
|
||||
return null;
|
||||
return fixer.createDimension(dimension, minY, maxY, logicalHeight).toString(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.volmit.iris.core.nms.datapack;
|
||||
|
||||
import com.volmit.iris.engine.object.IrisBiomeCustom;
|
||||
import com.volmit.iris.engine.object.IrisRange;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
|
||||
public interface IDataFixer {
|
||||
@ -12,17 +11,17 @@ public interface IDataFixer {
|
||||
|
||||
JSONObject rawDimension(Dimension dimension);
|
||||
|
||||
default JSONObject createDimension(Dimension dimension, IrisRange height, int logicalHeight) {
|
||||
default JSONObject createDimension(Dimension dimension, int minY, int maxY, int logicalHeight) {
|
||||
JSONObject obj = rawDimension(dimension);
|
||||
obj.put("min_y", height.getMin());
|
||||
obj.put("height", height.getMax() - height.getMin());
|
||||
obj.put("min_y", minY);
|
||||
obj.put("height", maxY - minY);
|
||||
obj.put("logical_height", logicalHeight);
|
||||
return obj;
|
||||
}
|
||||
|
||||
enum Dimension {
|
||||
OVERRWORLD,
|
||||
OVERWORLD,
|
||||
NETHER,
|
||||
THE_END
|
||||
END
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.util.Map;
|
||||
public class DataFixerV1192 implements IDataFixer {
|
||||
|
||||
private static final Map<Dimension, String> DIMENSIONS = Map.of(
|
||||
Dimension.OVERRWORLD, """
|
||||
Dimension.OVERWORLD, """
|
||||
{
|
||||
"ambient_light": 0.0,
|
||||
"bed_works": true,
|
||||
@ -48,7 +48,7 @@ public class DataFixerV1192 implements IDataFixer {
|
||||
"respawn_anchor_works": true,
|
||||
"ultrawarm": true
|
||||
}""",
|
||||
Dimension.THE_END, """
|
||||
Dimension.END, """
|
||||
{
|
||||
"ambient_light": 0.0,
|
||||
"bed_works": false,
|
||||
|
@ -25,11 +25,13 @@ import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.core.nms.datapack.IDataFixer;
|
||||
import com.volmit.iris.core.nms.datapack.IDataFixer.Dimension;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.data.DataProvider;
|
||||
import com.volmit.iris.util.data.Varint;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
@ -45,6 +47,8 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@ -74,10 +78,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@MaxNumber(2032)
|
||||
@Desc("Maximum height at which players can be teleported to through gameplay.")
|
||||
private int logicalHeight = 256;
|
||||
@Desc("Maximum height at which players can be teleported to through gameplay.")
|
||||
private int logicalHeightEnd = 256;
|
||||
@Desc("Maximum height at which players can be teleported to through gameplay.")
|
||||
private int logicalHeightNether = 256;
|
||||
@RegistryListResource(IrisJigsawStructure.class)
|
||||
@Desc("If defined, Iris will place the given jigsaw structure where minecraft should place the overworld stronghold.")
|
||||
private String stronghold;
|
||||
@ -166,10 +166,6 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private int fluidHeight = 63;
|
||||
@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 dimensionHeight = 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.")
|
||||
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.")
|
||||
private IrisRange dimensionHeightNether = new IrisRange(-64, 320);
|
||||
@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.")
|
||||
private String focus = "";
|
||||
@ -410,6 +406,40 @@ public class IrisDimension extends IrisRegistrant {
|
||||
});
|
||||
}
|
||||
|
||||
public Dimension getBaseDimension() {
|
||||
return switch (getEnvironment()) {
|
||||
case NETHER -> Dimension.NETHER;
|
||||
case THE_END -> Dimension.END;
|
||||
default -> Dimension.OVERWORLD;
|
||||
};
|
||||
}
|
||||
|
||||
public String getDimensionTypeKey() {
|
||||
return getDimensionTypeKey(getBaseDimension(), getMinHeight(), getMaxHeight(), getLogicalHeight());
|
||||
}
|
||||
|
||||
public void installDimensionType(IDataFixer fixer, KList<File> folders) {
|
||||
String key = getDimensionTypeKey();
|
||||
String json = fixer.createDimension(
|
||||
getBaseDimension(),
|
||||
getMinHeight(),
|
||||
getMaxHeight(),
|
||||
getLogicalHeight()
|
||||
).toString(4);
|
||||
|
||||
Iris.verbose(" Installing Data Pack Dimension Type: \"iris:" + key + '"');
|
||||
for (File datapacks : folders) {
|
||||
File output = new File(datapacks, "iris/data/iris/dimension_type/" + key + ".json");
|
||||
output.getParentFile().mkdirs();
|
||||
try {
|
||||
IO.writeAll(output, json);
|
||||
} catch (IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "dimensions";
|
||||
@ -426,11 +456,12 @@ public class IrisDimension extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public static void writeShared(KList<File> folders, DimensionHeight height) {
|
||||
Iris.verbose(" Installing Data Pack Dimension Types: \"iris:overworld\", \"iris:the_nether\", \"iris:the_end\"");
|
||||
Iris.verbose(" Installing Data Pack Vanilla Dimension Types");
|
||||
String[] jsonStrings = height.jsonStrings();
|
||||
for (File datapacks : folders) {
|
||||
write(datapacks, "overworld", height.overworldType());
|
||||
write(datapacks, "the_nether", height.netherType());
|
||||
write(datapacks, "the_end", height.endType());
|
||||
write(datapacks, "overworld", jsonStrings[0]);
|
||||
write(datapacks, "the_nether", jsonStrings[1]);
|
||||
write(datapacks, "the_end", jsonStrings[2]);
|
||||
}
|
||||
|
||||
String raw = """
|
||||
@ -454,18 +485,24 @@ public class IrisDimension extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
|
||||
private static void write(File datapacks, String type, String json) {
|
||||
File dimType = new File(datapacks, "iris/data/iris/dimension_type/" + type + ".json");
|
||||
File dimTypeVanilla = new File(datapacks, "iris/data/minecraft/dimension_type/" + type + ".json");
|
||||
|
||||
dimType.getParentFile().mkdirs();
|
||||
try {
|
||||
IO.writeAll(dimType, json);
|
||||
public static String getDimensionTypeKey(Dimension dimension, int minY, int maxY, int logicalHeight) {
|
||||
var stream = new ByteArrayOutputStream(13);
|
||||
try (var dos = new DataOutputStream(stream)) {
|
||||
dos.writeByte(dimension.ordinal());
|
||||
Varint.writeUnsignedVarInt(logicalHeight, dos);
|
||||
Varint.writeUnsignedVarInt(maxY - minY, dos);
|
||||
Varint.writeSignedVarInt(minY, dos);
|
||||
} catch (IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("This is impossible", e);
|
||||
}
|
||||
|
||||
return IO.encode(stream.toByteArray()).replace("=", ".").toLowerCase();
|
||||
}
|
||||
|
||||
private static void write(File datapacks, String type, String json) {
|
||||
if (json == null) return;
|
||||
File dimTypeVanilla = new File(datapacks, "iris/data/minecraft/dimension_type/" + type + ".json");
|
||||
|
||||
if (IrisSettings.get().getGeneral().adjustVanillaHeight || dimTypeVanilla.exists()) {
|
||||
dimTypeVanilla.getParentFile().mkdirs();
|
||||
try {
|
||||
|
@ -24,6 +24,7 @@ import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.core.nms.container.AutoClosing;
|
||||
import com.volmit.iris.core.service.StudioSVC;
|
||||
import com.volmit.iris.engine.IrisEngine;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineTarget;
|
||||
@ -86,6 +87,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
private final boolean studio;
|
||||
private final AtomicInteger a = new AtomicInteger(0);
|
||||
private final CompletableFuture<Integer> spawnChunks = new CompletableFuture<>();
|
||||
private final AtomicCache<EngineTarget> targetCache = new AtomicCache<>();
|
||||
private Engine engine;
|
||||
private Looper hotloader;
|
||||
private StudioMode lastMode;
|
||||
@ -158,37 +160,48 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
}
|
||||
|
||||
private void setupEngine() {
|
||||
IrisData data = IrisData.get(dataLocation);
|
||||
IrisDimension dimension = data.getDimensionLoader().load(dimensionKey);
|
||||
lastMode = StudioMode.NORMAL;
|
||||
engine = new IrisEngine(getTarget(), studio);
|
||||
populators.clear();
|
||||
targetCache.reset();
|
||||
}
|
||||
|
||||
if (dimension == null) {
|
||||
Iris.error("Oh No! There's no pack in " + data.getDataFolder().getPath() + " or... there's no dimension for the key " + dimensionKey);
|
||||
IrisDimension test = IrisData.loadAnyDimension(dimensionKey);
|
||||
@NotNull
|
||||
@Override
|
||||
public EngineTarget getTarget() {
|
||||
if (engine != null) return engine.getTarget();
|
||||
|
||||
if (test != null) {
|
||||
Iris.warn("Looks like " + dimensionKey + " exists in " + test.getLoadFile().getPath() + " ");
|
||||
Iris.service(StudioSVC.class).installIntoWorld(Iris.getSender(), dimensionKey, dataLocation.getParentFile().getParentFile());
|
||||
Iris.warn("Attempted to install into " + data.getDataFolder().getPath());
|
||||
data.dump();
|
||||
data.clearLists();
|
||||
test = data.getDimensionLoader().load(dimensionKey);
|
||||
return targetCache.aquire(() -> {
|
||||
IrisData data = IrisData.get(dataLocation);
|
||||
IrisDimension dimension = data.getDimensionLoader().load(dimensionKey);
|
||||
|
||||
if (dimension == null) {
|
||||
Iris.error("Oh No! There's no pack in " + data.getDataFolder().getPath() + " or... there's no dimension for the key " + dimensionKey);
|
||||
IrisDimension test = IrisData.loadAnyDimension(dimensionKey);
|
||||
|
||||
if (test != null) {
|
||||
Iris.success("Woo! Patched the Engine!");
|
||||
dimension = test;
|
||||
Iris.warn("Looks like " + dimensionKey + " exists in " + test.getLoadFile().getPath() + " ");
|
||||
Iris.service(StudioSVC.class).installIntoWorld(Iris.getSender(), dimensionKey, dataLocation.getParentFile().getParentFile());
|
||||
Iris.warn("Attempted to install into " + data.getDataFolder().getPath());
|
||||
data.dump();
|
||||
data.clearLists();
|
||||
test = data.getDimensionLoader().load(dimensionKey);
|
||||
|
||||
if (test != null) {
|
||||
Iris.success("Woo! Patched the Engine!");
|
||||
dimension = test;
|
||||
} else {
|
||||
Iris.error("Failed to patch dimension!");
|
||||
throw new RuntimeException("Missing Dimension: " + dimensionKey);
|
||||
}
|
||||
} else {
|
||||
Iris.error("Failed to patch dimension!");
|
||||
Iris.error("Nope, you don't have an installation containing " + dimensionKey + " try downloading it?");
|
||||
throw new RuntimeException("Missing Dimension: " + dimensionKey);
|
||||
}
|
||||
} else {
|
||||
Iris.error("Nope, you don't have an installation containing " + dimensionKey + " try downloading it?");
|
||||
throw new RuntimeException("Missing Dimension: " + dimensionKey);
|
||||
}
|
||||
}
|
||||
|
||||
lastMode = StudioMode.NORMAL;
|
||||
engine = new IrisEngine(new EngineTarget(world, dimension, data), studio);
|
||||
populators.clear();
|
||||
return new EngineTarget(world, dimension, data);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,21 +24,23 @@ import com.volmit.iris.engine.framework.EngineTarget;
|
||||
import com.volmit.iris.engine.framework.Hotloadable;
|
||||
import com.volmit.iris.util.data.DataProvider;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface PlatformChunkGenerator extends Hotloadable, DataProvider {
|
||||
@Nullable
|
||||
Engine getEngine();
|
||||
|
||||
@Override
|
||||
default IrisData getData() {
|
||||
return getEngine().getData();
|
||||
return getTarget().getData();
|
||||
}
|
||||
|
||||
default EngineTarget getTarget() {
|
||||
return getEngine().getTarget();
|
||||
}
|
||||
@NotNull
|
||||
EngineTarget getTarget();
|
||||
|
||||
void injectChunkReplacement(World world, int x, int z, Consumer<Runnable> jobs);
|
||||
|
||||
|
@ -7,6 +7,7 @@ import com.volmit.iris.core.nms.INMSBinding;
|
||||
import com.volmit.iris.core.nms.container.BiomeColor;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
import com.volmit.iris.util.agent.Agent;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
@ -22,7 +23,6 @@ import com.volmit.iris.util.nbt.mca.palette.*;
|
||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import lombok.SneakyThrows;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
@ -49,7 +49,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.flat.FlatLayerInfo;
|
||||
@ -78,6 +77,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
@ -700,18 +700,13 @@ public class NMSBinding implements INMSBinding {
|
||||
return new ResourceLocation("iris", key.location().getPath());
|
||||
}
|
||||
|
||||
public LevelStem levelStem(RegistryAccess access, World.Environment env) {
|
||||
if (env == World.Environment.CUSTOM)
|
||||
env = World.Environment.NORMAL;
|
||||
return stems.computeIfAbsent(env, key -> new LevelStem(dimensionType(access, key), chunkGenerator(access)));
|
||||
}
|
||||
public LevelStem levelStem(RegistryAccess access, ChunkGenerator raw) {
|
||||
if (!(raw instanceof PlatformChunkGenerator gen))
|
||||
throw new IllegalStateException("Generator is not platform chunk generator!");
|
||||
|
||||
private Holder.Reference<DimensionType> dimensionType(RegistryAccess access, World.Environment env) {
|
||||
return access.registryOrThrow(Registries.DIMENSION_TYPE).getHolderOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, new ResourceLocation("iris", switch (env) {
|
||||
case NORMAL, CUSTOM -> "overworld";
|
||||
case NETHER -> "the_nether";
|
||||
case THE_END -> "the_end";
|
||||
})));
|
||||
var dimensionKey = new ResourceLocation("iris", gen.getTarget().getDimension().getDimensionTypeKey());
|
||||
var dimensionType = access.lookupOrThrow(Registries.DIMENSION_TYPE).getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, dimensionKey));
|
||||
return new LevelStem(dimensionType, chunkGenerator(access));
|
||||
}
|
||||
|
||||
private net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator(RegistryAccess access) {
|
||||
@ -722,7 +717,6 @@ public class NMSBinding implements INMSBinding {
|
||||
}
|
||||
|
||||
private static class ServerLevelAdvice {
|
||||
@SneakyThrows
|
||||
@Advice.OnMethodEnter
|
||||
static void enter(
|
||||
@Advice.Argument(0) MinecraftServer server,
|
||||
@ -734,15 +728,20 @@ public class NMSBinding implements INMSBinding {
|
||||
if (gen == null || !gen.getClass().getPackageName().startsWith("com.volmit.iris"))
|
||||
return;
|
||||
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, World.Environment.class)
|
||||
.invoke(bindings, server.registryAccess(), env);
|
||||
levelData.customDimensions = null;
|
||||
try {
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, ChunkGenerator.class)
|
||||
.invoke(bindings, server.registryAccess(), gen);
|
||||
|
||||
levelData.customDimensions = null;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Iris failed to replace the levelStem", e instanceof InvocationTargetException ex ? ex.getCause() : e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.volmit.iris.core.nms.v1_20_R2;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
@ -11,11 +12,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.volmit.iris.core.nms.container.BiomeColor;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
import com.volmit.iris.util.agent.Agent;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.misc.ServerProperties;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import lombok.SneakyThrows;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
@ -32,7 +33,6 @@ import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.flat.FlatLayerInfo;
|
||||
@ -704,18 +704,13 @@ public class NMSBinding implements INMSBinding {
|
||||
return new ResourceLocation("iris", key.location().getPath());
|
||||
}
|
||||
|
||||
public LevelStem levelStem(RegistryAccess access, World.Environment env) {
|
||||
if (env == World.Environment.CUSTOM)
|
||||
env = World.Environment.NORMAL;
|
||||
return stems.computeIfAbsent(env, key -> new LevelStem(dimensionType(access, key), chunkGenerator(access)));
|
||||
}
|
||||
public LevelStem levelStem(RegistryAccess access, ChunkGenerator raw) {
|
||||
if (!(raw instanceof PlatformChunkGenerator gen))
|
||||
throw new IllegalStateException("Generator is not platform chunk generator!");
|
||||
|
||||
private Holder.Reference<DimensionType> dimensionType(RegistryAccess access, World.Environment env) {
|
||||
return access.registryOrThrow(Registries.DIMENSION_TYPE).getHolderOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, new ResourceLocation("iris", switch (env) {
|
||||
case NORMAL, CUSTOM -> "overworld";
|
||||
case NETHER -> "the_nether";
|
||||
case THE_END -> "the_end";
|
||||
})));
|
||||
var dimensionKey = new ResourceLocation("iris", gen.getTarget().getDimension().getDimensionTypeKey());
|
||||
var dimensionType = access.lookupOrThrow(Registries.DIMENSION_TYPE).getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, dimensionKey));
|
||||
return new LevelStem(dimensionType, chunkGenerator(access));
|
||||
}
|
||||
|
||||
private net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator(RegistryAccess access) {
|
||||
@ -726,7 +721,6 @@ public class NMSBinding implements INMSBinding {
|
||||
}
|
||||
|
||||
private static class ServerLevelAdvice {
|
||||
@SneakyThrows
|
||||
@Advice.OnMethodEnter
|
||||
static void enter(
|
||||
@Advice.Argument(0) MinecraftServer server,
|
||||
@ -738,15 +732,20 @@ public class NMSBinding implements INMSBinding {
|
||||
if (gen == null || !gen.getClass().getPackageName().startsWith("com.volmit.iris"))
|
||||
return;
|
||||
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, World.Environment.class)
|
||||
.invoke(bindings, server.registryAccess(), env);
|
||||
levelData.customDimensions = null;
|
||||
try {
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, ChunkGenerator.class)
|
||||
.invoke(bindings, server.registryAccess(), gen);
|
||||
|
||||
levelData.customDimensions = null;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Iris failed to replace the levelStem", e instanceof InvocationTargetException ex ? ex.getCause() : e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.volmit.iris.core.nms.v1_20_R3;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
@ -11,11 +12,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.volmit.iris.core.nms.container.BiomeColor;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
import com.volmit.iris.util.agent.Agent;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.misc.ServerProperties;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import lombok.SneakyThrows;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
@ -32,7 +33,6 @@ import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.flat.FlatLayerInfo;
|
||||
@ -705,18 +705,13 @@ public class NMSBinding implements INMSBinding {
|
||||
return new ResourceLocation("iris", key.location().getPath());
|
||||
}
|
||||
|
||||
public LevelStem levelStem(RegistryAccess access, World.Environment env) {
|
||||
if (env == World.Environment.CUSTOM)
|
||||
env = World.Environment.NORMAL;
|
||||
return stems.computeIfAbsent(env, key -> new LevelStem(dimensionType(access, key), chunkGenerator(access)));
|
||||
}
|
||||
public LevelStem levelStem(RegistryAccess access, ChunkGenerator raw) {
|
||||
if (!(raw instanceof PlatformChunkGenerator gen))
|
||||
throw new IllegalStateException("Generator is not platform chunk generator!");
|
||||
|
||||
private Holder.Reference<DimensionType> dimensionType(RegistryAccess access, World.Environment env) {
|
||||
return access.registryOrThrow(Registries.DIMENSION_TYPE).getHolderOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, new ResourceLocation("iris", switch (env) {
|
||||
case NORMAL, CUSTOM -> "overworld";
|
||||
case NETHER -> "the_nether";
|
||||
case THE_END -> "the_end";
|
||||
})));
|
||||
var dimensionKey = new ResourceLocation("iris", gen.getTarget().getDimension().getDimensionTypeKey());
|
||||
var dimensionType = access.lookupOrThrow(Registries.DIMENSION_TYPE).getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, dimensionKey));
|
||||
return new LevelStem(dimensionType, chunkGenerator(access));
|
||||
}
|
||||
|
||||
private net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator(RegistryAccess access) {
|
||||
@ -727,7 +722,6 @@ public class NMSBinding implements INMSBinding {
|
||||
}
|
||||
|
||||
private static class ServerLevelAdvice {
|
||||
@SneakyThrows
|
||||
@Advice.OnMethodEnter
|
||||
static void enter(
|
||||
@Advice.Argument(0) MinecraftServer server,
|
||||
@ -739,15 +733,20 @@ public class NMSBinding implements INMSBinding {
|
||||
if (gen == null || !gen.getClass().getPackageName().startsWith("com.volmit.iris"))
|
||||
return;
|
||||
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, World.Environment.class)
|
||||
.invoke(bindings, server.registryAccess(), env);
|
||||
levelData.customDimensions = null;
|
||||
try {
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, ChunkGenerator.class)
|
||||
.invoke(bindings, server.registryAccess(), gen);
|
||||
|
||||
levelData.customDimensions = null;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Iris failed to replace the levelStem", e instanceof InvocationTargetException ex ? ex.getCause() : e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.volmit.iris.core.nms.v1_20_R4;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
@ -12,12 +13,12 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.volmit.iris.core.nms.container.BiomeColor;
|
||||
import com.volmit.iris.core.nms.datapack.DataVersion;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
import com.volmit.iris.util.agent.Agent;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.misc.ServerProperties;
|
||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import lombok.SneakyThrows;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
@ -46,7 +47,6 @@ import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.flat.FlatLayerInfo;
|
||||
@ -733,18 +733,13 @@ public class NMSBinding implements INMSBinding {
|
||||
return new ResourceLocation("iris", key.location().getPath());
|
||||
}
|
||||
|
||||
public LevelStem levelStem(RegistryAccess access, World.Environment env) {
|
||||
if (env == World.Environment.CUSTOM)
|
||||
env = World.Environment.NORMAL;
|
||||
return stems.computeIfAbsent(env, key -> new LevelStem(dimensionType(access, key), chunkGenerator(access)));
|
||||
}
|
||||
public LevelStem levelStem(RegistryAccess access, ChunkGenerator raw) {
|
||||
if (!(raw instanceof PlatformChunkGenerator gen))
|
||||
throw new IllegalStateException("Generator is not platform chunk generator!");
|
||||
|
||||
private Holder.Reference<DimensionType> dimensionType(RegistryAccess access, World.Environment env) {
|
||||
return access.registryOrThrow(Registries.DIMENSION_TYPE).getHolderOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, new ResourceLocation("iris", switch (env) {
|
||||
case NORMAL, CUSTOM -> "overworld";
|
||||
case NETHER -> "the_nether";
|
||||
case THE_END -> "the_end";
|
||||
})));
|
||||
var dimensionKey = new ResourceLocation("iris", gen.getTarget().getDimension().getDimensionTypeKey());
|
||||
var dimensionType = access.lookupOrThrow(Registries.DIMENSION_TYPE).getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, dimensionKey));
|
||||
return new LevelStem(dimensionType, chunkGenerator(access));
|
||||
}
|
||||
|
||||
private net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator(RegistryAccess access) {
|
||||
@ -755,7 +750,6 @@ public class NMSBinding implements INMSBinding {
|
||||
}
|
||||
|
||||
private static class ServerLevelAdvice {
|
||||
@SneakyThrows
|
||||
@Advice.OnMethodEnter
|
||||
static void enter(
|
||||
@Advice.Argument(0) MinecraftServer server,
|
||||
@ -767,15 +761,20 @@ public class NMSBinding implements INMSBinding {
|
||||
if (gen == null || !gen.getClass().getPackageName().startsWith("com.volmit.iris"))
|
||||
return;
|
||||
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, World.Environment.class)
|
||||
.invoke(bindings, server.registryAccess(), env);
|
||||
levelData.customDimensions = null;
|
||||
try {
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, ChunkGenerator.class)
|
||||
.invoke(bindings, server.registryAccess(), gen);
|
||||
|
||||
levelData.customDimensions = null;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Iris failed to replace the levelStem", e instanceof InvocationTargetException ex ? ex.getCause() : e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.volmit.iris.core.nms.v1_21_R1;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
@ -12,11 +13,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.volmit.iris.core.nms.container.BiomeColor;
|
||||
import com.volmit.iris.core.nms.datapack.DataVersion;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
import com.volmit.iris.util.agent.Agent;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.misc.ServerProperties;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import lombok.SneakyThrows;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
@ -37,7 +38,6 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.status.WorldGenContext;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.flat.FlatLayerInfo;
|
||||
@ -733,18 +733,15 @@ public class NMSBinding implements INMSBinding {
|
||||
return ResourceLocation.fromNamespaceAndPath("iris", key.location().getPath());
|
||||
}
|
||||
|
||||
public LevelStem levelStem(RegistryAccess access, World.Environment env) {
|
||||
if (env == World.Environment.CUSTOM)
|
||||
env = World.Environment.NORMAL;
|
||||
return stems.computeIfAbsent(env, key -> new LevelStem(dimensionType(access, key), chunkGenerator(access)));
|
||||
}
|
||||
|
||||
private Holder.Reference<DimensionType> dimensionType(RegistryAccess access, World.Environment env) {
|
||||
return access.registryOrThrow(Registries.DIMENSION_TYPE).getHolderOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, ResourceLocation.fromNamespaceAndPath("iris", switch (env) {
|
||||
case NORMAL, CUSTOM -> "overworld";
|
||||
case NETHER -> "the_nether";
|
||||
case THE_END -> "the_end";
|
||||
})));
|
||||
|
||||
public LevelStem levelStem(RegistryAccess access, ChunkGenerator raw) {
|
||||
if (!(raw instanceof PlatformChunkGenerator gen))
|
||||
throw new IllegalStateException("Generator is not platform chunk generator!");
|
||||
|
||||
var dimensionKey = ResourceLocation.fromNamespaceAndPath("iris", gen.getTarget().getDimension().getDimensionTypeKey());
|
||||
var dimensionType = access.lookupOrThrow(Registries.DIMENSION_TYPE).getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, dimensionKey));
|
||||
return new LevelStem(dimensionType, chunkGenerator(access));
|
||||
}
|
||||
|
||||
private net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator(RegistryAccess access) {
|
||||
@ -755,7 +752,6 @@ public class NMSBinding implements INMSBinding {
|
||||
}
|
||||
|
||||
private static class ServerLevelAdvice {
|
||||
@SneakyThrows
|
||||
@Advice.OnMethodEnter
|
||||
static void enter(
|
||||
@Advice.Argument(0) MinecraftServer server,
|
||||
@ -767,15 +763,20 @@ public class NMSBinding implements INMSBinding {
|
||||
if (gen == null || !gen.getClass().getPackageName().startsWith("com.volmit.iris"))
|
||||
return;
|
||||
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, World.Environment.class)
|
||||
.invoke(bindings, server.registryAccess(), env);
|
||||
levelData.customDimensions = null;
|
||||
try {
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, ChunkGenerator.class)
|
||||
.invoke(bindings, server.registryAccess(), gen);
|
||||
|
||||
levelData.customDimensions = null;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Iris failed to replace the levelStem", e instanceof InvocationTargetException ex ? ex.getCause() : e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.volmit.iris.core.nms.v1_21_R2;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
@ -11,11 +12,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.volmit.iris.core.nms.container.BiomeColor;
|
||||
import com.volmit.iris.core.nms.datapack.DataVersion;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
import com.volmit.iris.util.agent.Agent;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.misc.ServerProperties;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import lombok.SneakyThrows;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
@ -36,7 +37,6 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.status.WorldGenContext;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.flat.FlatLayerInfo;
|
||||
@ -732,18 +732,13 @@ public class NMSBinding implements INMSBinding {
|
||||
return ResourceLocation.fromNamespaceAndPath("iris", key.location().getPath());
|
||||
}
|
||||
|
||||
public LevelStem levelStem(RegistryAccess access, World.Environment env) {
|
||||
if (env == World.Environment.CUSTOM)
|
||||
env = World.Environment.NORMAL;
|
||||
return stems.computeIfAbsent(env, key -> new LevelStem(dimensionType(access, key), chunkGenerator(access)));
|
||||
}
|
||||
public LevelStem levelStem(RegistryAccess access, ChunkGenerator raw) {
|
||||
if (!(raw instanceof PlatformChunkGenerator gen))
|
||||
throw new IllegalStateException("Generator is not platform chunk generator!");
|
||||
|
||||
private Holder.Reference<DimensionType> dimensionType(RegistryAccess access, World.Environment env) {
|
||||
return access.lookupOrThrow(Registries.DIMENSION_TYPE).getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, ResourceLocation.fromNamespaceAndPath("iris", switch (env) {
|
||||
case NORMAL, CUSTOM -> "overworld";
|
||||
case NETHER -> "the_nether";
|
||||
case THE_END -> "the_end";
|
||||
})));
|
||||
var dimensionKey = ResourceLocation.fromNamespaceAndPath("iris", gen.getTarget().getDimension().getDimensionTypeKey());
|
||||
var dimensionType = access.lookupOrThrow(Registries.DIMENSION_TYPE).getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, dimensionKey));
|
||||
return new LevelStem(dimensionType, chunkGenerator(access));
|
||||
}
|
||||
|
||||
private net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator(RegistryAccess access) {
|
||||
@ -754,7 +749,6 @@ public class NMSBinding implements INMSBinding {
|
||||
}
|
||||
|
||||
private static class ServerLevelAdvice {
|
||||
@SneakyThrows
|
||||
@Advice.OnMethodEnter
|
||||
static void enter(
|
||||
@Advice.Argument(0) MinecraftServer server,
|
||||
@ -766,15 +760,20 @@ public class NMSBinding implements INMSBinding {
|
||||
if (gen == null || !gen.getClass().getPackageName().startsWith("com.volmit.iris"))
|
||||
return;
|
||||
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, World.Environment.class)
|
||||
.invoke(bindings, server.registryAccess(), env);
|
||||
levelData.customDimensions = null;
|
||||
try {
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, ChunkGenerator.class)
|
||||
.invoke(bindings, server.registryAccess(), gen);
|
||||
|
||||
levelData.customDimensions = null;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Iris failed to replace the levelStem", e instanceof InvocationTargetException ex ? ex.getCause() : e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.volmit.iris.core.nms.container.BiomeColor;
|
||||
import com.volmit.iris.core.nms.datapack.DataVersion;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
import com.volmit.iris.util.agent.Agent;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
@ -16,13 +17,11 @@ import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.math.Vector3d;
|
||||
import com.volmit.iris.util.matter.MatterBiomeInject;
|
||||
import com.volmit.iris.util.misc.ServerProperties;
|
||||
import com.volmit.iris.util.nbt.mca.NBTWorld;
|
||||
import com.volmit.iris.util.nbt.mca.palette.*;
|
||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import lombok.SneakyThrows;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
@ -53,7 +52,6 @@ import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.status.WorldGenContext;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.flat.FlatLayerInfo;
|
||||
@ -81,6 +79,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
@ -731,18 +730,13 @@ public class NMSBinding implements INMSBinding {
|
||||
return ResourceLocation.fromNamespaceAndPath("iris", key.location().getPath());
|
||||
}
|
||||
|
||||
public LevelStem levelStem(RegistryAccess access, World.Environment env) {
|
||||
if (env == World.Environment.CUSTOM)
|
||||
env = World.Environment.NORMAL;
|
||||
return stems.computeIfAbsent(env, key -> new LevelStem(dimensionType(access, key), chunkGenerator(access)));
|
||||
}
|
||||
public LevelStem levelStem(RegistryAccess access, ChunkGenerator raw) {
|
||||
if (!(raw instanceof PlatformChunkGenerator gen))
|
||||
throw new IllegalStateException("Generator is not platform chunk generator!");
|
||||
|
||||
private Holder.Reference<DimensionType> dimensionType(RegistryAccess access, World.Environment env) {
|
||||
return access.lookupOrThrow(Registries.DIMENSION_TYPE).getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, ResourceLocation.fromNamespaceAndPath("iris", switch (env) {
|
||||
case NORMAL, CUSTOM -> "overworld";
|
||||
case NETHER -> "the_nether";
|
||||
case THE_END -> "the_end";
|
||||
})));
|
||||
var dimensionKey = ResourceLocation.fromNamespaceAndPath("iris", gen.getTarget().getDimension().getDimensionTypeKey());
|
||||
var dimensionType = access.lookupOrThrow(Registries.DIMENSION_TYPE).getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, dimensionKey));
|
||||
return new LevelStem(dimensionType, chunkGenerator(access));
|
||||
}
|
||||
|
||||
private net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator(RegistryAccess access) {
|
||||
@ -753,7 +747,6 @@ public class NMSBinding implements INMSBinding {
|
||||
}
|
||||
|
||||
private static class ServerLevelAdvice {
|
||||
@SneakyThrows
|
||||
@Advice.OnMethodEnter
|
||||
static void enter(
|
||||
@Advice.Argument(0) MinecraftServer server,
|
||||
@ -765,15 +758,20 @@ public class NMSBinding implements INMSBinding {
|
||||
if (gen == null || !gen.getClass().getPackageName().startsWith("com.volmit.iris"))
|
||||
return;
|
||||
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, World.Environment.class)
|
||||
.invoke(bindings, server.registryAccess(), env);
|
||||
levelData.customDimensions = null;
|
||||
try {
|
||||
Object bindings = Class.forName("com.volmit.iris.core.nms.INMS", true, Bukkit.getPluginManager().getPlugin("Iris")
|
||||
.getClass()
|
||||
.getClassLoader())
|
||||
.getDeclaredMethod("get")
|
||||
.invoke(null);
|
||||
levelStem = (LevelStem) bindings.getClass()
|
||||
.getDeclaredMethod("levelStem", RegistryAccess.class, ChunkGenerator.class)
|
||||
.invoke(bindings, server.registryAccess(), gen);
|
||||
|
||||
levelData.customDimensions = null;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Iris failed to replace the levelStem", e instanceof InvocationTargetException ex ? ex.getCause() : e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user