Skip to content

3.6.5 #1181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 26, 2025
Merged

3.6.5 #1181

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/src/main/java/com/volmit/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,17 @@ private void enable() {
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
INMS.get();
IO.delete(new File("iris"));
compat = IrisCompat.configured(getDataFile("compat.json"));
ServerConfigurator.configure();
new IrisContextInjector();
IrisSafeguard.IrisSafeguardSystem();
getSender().setTag(getTag());
compat = IrisCompat.configured(getDataFile("compat.json"));
IrisSafeguard.earlySplash();
linkMultiverseCore = new MultiverseCoreLink();
linkMythicMobs = new MythicMobsLink();
configWatcher = new FileWatcher(getDataFile("settings.json"));
services.values().forEach(IrisService::onEnable);
services.values().forEach(this::registerListener);
registerListener(new IrisContextInjector());
J.s(() -> {
J.a(() -> PaperLib.suggestPaper(this));
J.a(() -> IO.delete(getTemp()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;
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;
Expand Down Expand Up @@ -97,6 +98,7 @@ private static KList<File> getDatapacksFolder() {
}
KList<File> worlds = new KList<>();
Bukkit.getServer().getWorlds().forEach(w -> worlds.add(new File(w.getWorldFolder(), "datapacks")));
if (worlds.isEmpty()) worlds.add(new File(Bukkit.getWorldContainer(), ServerProperties.LEVEL_NAME + "/datapacks"));
return worlds;
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/volmit/iris/core/nms/INMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class INMS {
"1.21.4", "v1_21_R3"
);
private static final List<Version> PACKS = List.of(
new Version(21, 4, "31010"),
new Version(21, 4, "31020"),
new Version(21, 2, "31000"),
new Version(20, 1, "3910")
);
Expand Down
16 changes: 7 additions & 9 deletions core/src/main/java/com/volmit/iris/core/nms/INMSBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@
import com.volmit.iris.util.nbt.tag.CompoundTag;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.entity.Dolphin;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.generator.structure.Structure;
import org.bukkit.inventory.ItemStack;

import java.awt.*;
import java.awt.Color;

public interface INMSBinding {
Expand Down Expand Up @@ -93,6 +90,9 @@ public interface INMSBinding {
MCABiomeContainer newBiomeContainer(int min, int max);

default World createWorld(WorldCreator c) {
if (missingDimensionTypes(true, true, true))
throw new IllegalStateException("Missing dimenstion types to create world");

try (var ignored = injectLevelStems()) {
return c.createWorld();
}
Expand Down Expand Up @@ -130,11 +130,9 @@ default int getSpawnChunkCount(World world) {

KList<String> getStructureKeys();

default AutoClosing injectLevelStems() {
return new AutoClosing(() -> {});
}
AutoClosing injectLevelStems();

default Pair<Integer, AutoClosing> injectUncached(boolean overworld, boolean nether, boolean end) {
return new Pair<>(0, injectLevelStems());
}
Pair<Integer, AutoClosing> injectUncached(boolean overworld, boolean nether, boolean end);

boolean missingDimensionTypes(boolean overworld, boolean nether, boolean end);
}
17 changes: 17 additions & 0 deletions core/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.core.nms.container.AutoClosing;
import com.volmit.iris.core.nms.container.BiomeColor;
import com.volmit.iris.core.nms.container.Pair;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
Expand Down Expand Up @@ -118,6 +120,21 @@ public KList<String> getStructureKeys() {
return new KList<>(list);
}

@Override
public AutoClosing injectLevelStems() {
return new AutoClosing(() -> {});
}

@Override
public Pair<Integer, AutoClosing> injectUncached(boolean overworld, boolean nether, boolean end) {
return new Pair<>(0, new AutoClosing(() -> {}));
}

@Override
public boolean missingDimensionTypes(boolean overworld, boolean nether, boolean end) {
return false;
}

@Override
public CompoundTag serializeEntity(Entity location) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.volmit.iris.core.safeguard;

import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;

public class IrisSafeguard {
public static boolean unstablemode = false;
Expand All @@ -11,5 +12,13 @@ public static void IrisSafeguardSystem() {
Iris.info("Enabled Iris SafeGuard");
ServerBootSFG.BootCheck();
}

public static void earlySplash() {
if (ServerBootSFG.safeguardPassed || IrisSettings.get().getGeneral().DoomsdayAnnihilationSelfDestructMode)
return;

Iris.instance.splash();
UtilsSFG.splash();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import com.volmit.iris.engine.object.IrisContextInjector;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
Expand All @@ -29,6 +30,7 @@ public class ServerBootSFG {
public static boolean isJRE = false;
public static boolean hasPrivileges = true;
public static boolean unsuportedversion = false;
public static boolean missingDimensionTypes = false;
protected static boolean safeguardPassed;
public static boolean passedserversoftware = true;
protected static int count;
Expand Down Expand Up @@ -110,6 +112,12 @@ public static void BootCheck() {
severityMedium++;
}

if (IrisContextInjector.isMissingDimensionTypes()) {
missingDimensionTypes = true;
joiner.add("Missing Dimension Types");
severityHigh++;
}

allIncompatibilities = joiner.toString();

safeguardPassed = (severityHigh == 0 && severityMedium == 0 && severityLow == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public static void printIncompatibleWarnings() {
Iris.safeguard(C.RED + "Server Version");
Iris.safeguard(C.RED + "- Iris only supports 1.20.1 > 1.21.4");
}
if (ServerBootSFG.missingDimensionTypes) {
Iris.safeguard(C.RED + "Dimension Types");
Iris.safeguard(C.RED + "- Required Iris dimension types were not loaded.");
Iris.safeguard(C.RED + "- If this still happens after a restart please contact support.");
}
if (!ServerBootSFG.passedserversoftware) {
Iris.safeguard(C.YELLOW + "Unsupported Server Software");
Iris.safeguard(C.YELLOW + "- Please consider using Paper or Purpur instead.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.nms.container.AutoClosing;
import com.volmit.iris.util.misc.ServerProperties;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
Expand All @@ -15,6 +16,8 @@
import static com.volmit.iris.Iris.instance;

public class IrisContextInjector implements Listener {
@Getter
private static boolean missingDimensionTypes = false;
private AutoClosing autoClosing = null;
private final int totalWorlds;
private int worldCounter = 0;
Expand All @@ -35,13 +38,20 @@ public IrisContextInjector() {
if (Bukkit.getAllowNether()) i++;
if (Bukkit.getAllowEnd()) i++;

if (INMS.get().missingDimensionTypes(overworld, nether, end)) {
missingDimensionTypes = true;
totalWorlds = 0;
return;
}

if (overworld || nether || end) {
var pair = INMS.get().injectUncached(overworld, nether, end);
i += pair.getA() - 3;
autoClosing = pair.getB();
}

totalWorlds = i;
instance.registerListener(this);
}

@EventHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ServerProperties {
public static final File SERVER_PROPERTIES;
public static final File BUKKIT_YML;

public static final String LEVEL_NAME = DATA.getProperty("level-name", "world");
public static final String LEVEL_NAME;

static {
String[] args = ProcessHandle.current()
Expand All @@ -20,11 +20,13 @@ public class ServerProperties {

String propertiesPath = "server.properties";
String bukkitYml = "bukkit.yml";
String levelName = null;

for (int i = 0; i < args.length - 1; i++) {
switch (args[i]) {
case "-c", "--config" -> propertiesPath = args[i + 1];
case "-b", "--bukkit-settings" -> bukkitYml = args[i + 1];
case "-w", "--level-name", "--world" -> levelName = args[i + 1];
}
}

Expand All @@ -35,5 +37,8 @@ public class ServerProperties {
} catch (IOException e) {
throw new RuntimeException(e);
}

if (levelName != null) LEVEL_NAME = levelName;
else LEVEL_NAME = DATA.getProperty("level-name", "world");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -47,6 +49,9 @@
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;
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
Expand Down Expand Up @@ -673,6 +678,15 @@ public com.volmit.iris.core.nms.container.Pair<Integer, AutoClosing> injectUncac
}));
}

@Override
public boolean missingDimensionTypes(boolean overworld, boolean nether, boolean end) {
var registry = registry().registryOrThrow(Registries.DIMENSION_TYPE);
if (overworld) overworld = !registry.containsKey(createIrisKey(LevelStem.OVERWORLD));
if (nether) nether = !registry.containsKey(createIrisKey(LevelStem.NETHER));
if (end) end = !registry.containsKey(createIrisKey(LevelStem.END));
return overworld || nether || end;
}

private WorldLoader.DataLoadContext supplier(WorldLoader.DataLoadContext old) {
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
old.resources(),
Expand Down Expand Up @@ -703,23 +717,32 @@ private AutoClosing inject(Function<WorldLoader.DataLoadContext, WorldLoader.Dat
private RegistryAccess.Frozen createRegistryAccess(RegistryAccess.Frozen datapack, boolean copy, boolean overworld, boolean nether, boolean end) {
var access = registry();
var dimensions = access.registryOrThrow(Registries.DIMENSION_TYPE);
var levelStems = access.registryOrThrow(Registries.LEVEL_STEM);

var settings = new FlatLevelGeneratorSettings(
Optional.empty(),
access.lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.THE_VOID),
List.of()
);
settings.getLayersInfo().add(new FlatLayerInfo(1, Blocks.AIR));
settings.updateLayers();

var source = new FlatLevelSource(settings);
var fake = new MappedRegistry<>(Registries.LEVEL_STEM, Lifecycle.experimental());
if (overworld) register(fake, levelStems, dimensions, LevelStem.OVERWORLD);
if (nether) register(fake, levelStems, dimensions, LevelStem.NETHER);
if (end) register(fake, levelStems, dimensions, LevelStem.END);
if (overworld) register(fake, dimensions, source, LevelStem.OVERWORLD);
if (nether) register(fake, dimensions, source, LevelStem.NETHER);
if (end) register(fake, dimensions, source, LevelStem.END);
copy(fake, datapack.registry(Registries.LEVEL_STEM).orElse(null));

if (copy) copy(fake, levelStems);
if (copy) copy(fake, access.registryOrThrow(Registries.LEVEL_STEM));

return new RegistryAccess.Frozen.ImmutableRegistryAccess(List.of(fake.freeze())).freeze();
}

private void register(MappedRegistry<LevelStem> target, Registry<LevelStem> levelStems, Registry<DimensionType> dimensions, ResourceKey<LevelStem> key) {
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
var loc = createIrisKey(key);
target.register(key, new LevelStem(
dimensions.getHolderOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, new ResourceLocation("iris", key.location().getPath()))),
levelStems.getOrThrow(key).generator()
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
source
), Lifecycle.stable());
}

Expand All @@ -732,4 +755,8 @@ private void copy(MappedRegistry<LevelStem> target, Registry<LevelStem> source)
target.register(key, value, info);
});
}

private ResourceLocation createIrisKey(ResourceKey<LevelStem> key) {
return new ResourceLocation("iris", key.location().getPath());
}
}
Loading