mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-02-16 02:20:44 +00:00
add safeguard for missing dimension types to prevent world corruption
This commit is contained in:
committed by
Julian Krings
parent
06a45056d9
commit
24355064ff
@@ -459,15 +459,17 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
|
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
|
||||||
INMS.get();
|
INMS.get();
|
||||||
IO.delete(new File("iris"));
|
IO.delete(new File("iris"));
|
||||||
|
compat = IrisCompat.configured(getDataFile("compat.json"));
|
||||||
|
ServerConfigurator.configure();
|
||||||
|
new IrisContextInjector();
|
||||||
IrisSafeguard.IrisSafeguardSystem();
|
IrisSafeguard.IrisSafeguardSystem();
|
||||||
getSender().setTag(getTag());
|
getSender().setTag(getTag());
|
||||||
compat = IrisCompat.configured(getDataFile("compat.json"));
|
IrisSafeguard.earlySplash();
|
||||||
linkMultiverseCore = new MultiverseCoreLink();
|
linkMultiverseCore = new MultiverseCoreLink();
|
||||||
linkMythicMobs = new MythicMobsLink();
|
linkMythicMobs = new MythicMobsLink();
|
||||||
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
||||||
services.values().forEach(IrisService::onEnable);
|
services.values().forEach(IrisService::onEnable);
|
||||||
services.values().forEach(this::registerListener);
|
services.values().forEach(this::registerListener);
|
||||||
registerListener(new IrisContextInjector());
|
|
||||||
J.s(() -> {
|
J.s(() -> {
|
||||||
J.a(() -> PaperLib.suggestPaper(this));
|
J.a(() -> PaperLib.suggestPaper(this));
|
||||||
J.a(() -> IO.delete(getTemp()));
|
J.a(() -> IO.delete(getTemp()));
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import com.volmit.iris.util.collection.KList;
|
|||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
import com.volmit.iris.util.format.C;
|
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.plugin.VolmitSender;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -97,6 +98,7 @@ public class ServerConfigurator {
|
|||||||
}
|
}
|
||||||
KList<File> worlds = new KList<>();
|
KList<File> worlds = new KList<>();
|
||||||
Bukkit.getServer().getWorlds().forEach(w -> worlds.add(new File(w.getWorldFolder(), "datapacks")));
|
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;
|
return worlds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,15 +32,12 @@ import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess;
|
|||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.entity.Dolphin;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.generator.structure.Structure;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
public interface INMSBinding {
|
public interface INMSBinding {
|
||||||
@@ -93,6 +90,9 @@ public interface INMSBinding {
|
|||||||
MCABiomeContainer newBiomeContainer(int min, int max);
|
MCABiomeContainer newBiomeContainer(int min, int max);
|
||||||
|
|
||||||
default World createWorld(WorldCreator c) {
|
default World createWorld(WorldCreator c) {
|
||||||
|
if (missingDimensionTypes(true, true, true))
|
||||||
|
throw new IllegalStateException("Missing dimenstion types to create world");
|
||||||
|
|
||||||
try (var ignored = injectLevelStems()) {
|
try (var ignored = injectLevelStems()) {
|
||||||
return c.createWorld();
|
return c.createWorld();
|
||||||
}
|
}
|
||||||
@@ -130,11 +130,9 @@ public interface INMSBinding {
|
|||||||
|
|
||||||
KList<String> getStructureKeys();
|
KList<String> getStructureKeys();
|
||||||
|
|
||||||
default AutoClosing injectLevelStems() {
|
AutoClosing injectLevelStems();
|
||||||
return new AutoClosing(() -> {});
|
|
||||||
}
|
|
||||||
|
|
||||||
default Pair<Integer, AutoClosing> injectUncached(boolean overworld, boolean nether, boolean end) {
|
Pair<Integer, AutoClosing> injectUncached(boolean overworld, boolean nether, boolean end);
|
||||||
return new Pair<>(0, injectLevelStems());
|
|
||||||
}
|
boolean missingDimensionTypes(boolean overworld, boolean nether, boolean end);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ package com.volmit.iris.core.nms.v1X;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.nms.INMSBinding;
|
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.BiomeColor;
|
||||||
|
import com.volmit.iris.core.nms.container.Pair;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
@@ -118,6 +120,21 @@ public class NMSBinding1X implements INMSBinding {
|
|||||||
return new KList<>(list);
|
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
|
@Override
|
||||||
public CompoundTag serializeEntity(Entity location) {
|
public CompoundTag serializeEntity(Entity location) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.volmit.iris.core.safeguard;
|
package com.volmit.iris.core.safeguard;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisSettings;
|
||||||
|
|
||||||
public class IrisSafeguard {
|
public class IrisSafeguard {
|
||||||
public static boolean unstablemode = false;
|
public static boolean unstablemode = false;
|
||||||
@@ -11,5 +12,13 @@ public class IrisSafeguard {
|
|||||||
Iris.info("Enabled Iris SafeGuard");
|
Iris.info("Enabled Iris SafeGuard");
|
||||||
ServerBootSFG.BootCheck();
|
ServerBootSFG.BootCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void earlySplash() {
|
||||||
|
if (ServerBootSFG.safeguardPassed || IrisSettings.get().getGeneral().DoomsdayAnnihilationSelfDestructMode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Iris.instance.splash();
|
||||||
|
UtilsSFG.splash();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.volmit.iris.core.safeguard;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
|
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
|
||||||
|
import com.volmit.iris.engine.object.IrisContextInjector;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@@ -29,6 +30,7 @@ public class ServerBootSFG {
|
|||||||
public static boolean isJRE = false;
|
public static boolean isJRE = false;
|
||||||
public static boolean hasPrivileges = true;
|
public static boolean hasPrivileges = true;
|
||||||
public static boolean unsuportedversion = false;
|
public static boolean unsuportedversion = false;
|
||||||
|
public static boolean missingDimensionTypes = false;
|
||||||
protected static boolean safeguardPassed;
|
protected static boolean safeguardPassed;
|
||||||
public static boolean passedserversoftware = true;
|
public static boolean passedserversoftware = true;
|
||||||
protected static int count;
|
protected static int count;
|
||||||
@@ -110,6 +112,12 @@ public class ServerBootSFG {
|
|||||||
severityMedium++;
|
severityMedium++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IrisContextInjector.isMissingDimensionTypes()) {
|
||||||
|
missingDimensionTypes = true;
|
||||||
|
joiner.add("Missing Dimension Types");
|
||||||
|
severityHigh++;
|
||||||
|
}
|
||||||
|
|
||||||
allIncompatibilities = joiner.toString();
|
allIncompatibilities = joiner.toString();
|
||||||
|
|
||||||
safeguardPassed = (severityHigh == 0 && severityMedium == 0 && severityLow == 0);
|
safeguardPassed = (severityHigh == 0 && severityMedium == 0 && severityLow == 0);
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ public class UtilsSFG {
|
|||||||
Iris.safeguard(C.RED + "Server Version");
|
Iris.safeguard(C.RED + "Server Version");
|
||||||
Iris.safeguard(C.RED + "- Iris only supports 1.20.1 > 1.21.4");
|
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) {
|
if (!ServerBootSFG.passedserversoftware) {
|
||||||
Iris.safeguard(C.YELLOW + "Unsupported Server Software");
|
Iris.safeguard(C.YELLOW + "Unsupported Server Software");
|
||||||
Iris.safeguard(C.YELLOW + "- Please consider using Paper or Purpur instead.");
|
Iris.safeguard(C.YELLOW + "- Please consider using Paper or Purpur instead.");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.volmit.iris.engine.object;
|
|||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.core.nms.container.AutoClosing;
|
import com.volmit.iris.core.nms.container.AutoClosing;
|
||||||
import com.volmit.iris.util.misc.ServerProperties;
|
import com.volmit.iris.util.misc.ServerProperties;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@@ -15,6 +16,8 @@ import java.util.List;
|
|||||||
import static com.volmit.iris.Iris.instance;
|
import static com.volmit.iris.Iris.instance;
|
||||||
|
|
||||||
public class IrisContextInjector implements Listener {
|
public class IrisContextInjector implements Listener {
|
||||||
|
@Getter
|
||||||
|
private static boolean missingDimensionTypes = false;
|
||||||
private AutoClosing autoClosing = null;
|
private AutoClosing autoClosing = null;
|
||||||
private final int totalWorlds;
|
private final int totalWorlds;
|
||||||
private int worldCounter = 0;
|
private int worldCounter = 0;
|
||||||
@@ -35,6 +38,12 @@ public class IrisContextInjector implements Listener {
|
|||||||
if (Bukkit.getAllowNether()) i++;
|
if (Bukkit.getAllowNether()) i++;
|
||||||
if (Bukkit.getAllowEnd()) i++;
|
if (Bukkit.getAllowEnd()) i++;
|
||||||
|
|
||||||
|
if (INMS.get().missingDimensionTypes(overworld, nether, end)) {
|
||||||
|
missingDimensionTypes = true;
|
||||||
|
totalWorlds = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (overworld || nether || end) {
|
if (overworld || nether || end) {
|
||||||
var pair = INMS.get().injectUncached(overworld, nether, end);
|
var pair = INMS.get().injectUncached(overworld, nether, end);
|
||||||
i += pair.getA() - 3;
|
i += pair.getA() - 3;
|
||||||
@@ -42,6 +51,7 @@ public class IrisContextInjector implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
totalWorlds = i;
|
totalWorlds = i;
|
||||||
|
instance.registerListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class ServerProperties {
|
|||||||
public static final File SERVER_PROPERTIES;
|
public static final File SERVER_PROPERTIES;
|
||||||
public static final File BUKKIT_YML;
|
public static final File BUKKIT_YML;
|
||||||
|
|
||||||
public static final String LEVEL_NAME = DATA.getProperty("level-name", "world");
|
public static final String LEVEL_NAME;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
String[] args = ProcessHandle.current()
|
String[] args = ProcessHandle.current()
|
||||||
@@ -20,11 +20,13 @@ public class ServerProperties {
|
|||||||
|
|
||||||
String propertiesPath = "server.properties";
|
String propertiesPath = "server.properties";
|
||||||
String bukkitYml = "bukkit.yml";
|
String bukkitYml = "bukkit.yml";
|
||||||
|
String levelName = null;
|
||||||
|
|
||||||
for (int i = 0; i < args.length - 1; i++) {
|
for (int i = 0; i < args.length - 1; i++) {
|
||||||
switch (args[i]) {
|
switch (args[i]) {
|
||||||
case "-c", "--config" -> propertiesPath = args[i + 1];
|
case "-c", "--config" -> propertiesPath = args[i + 1];
|
||||||
case "-b", "--bukkit-settings" -> bukkitYml = args[i + 1];
|
case "-b", "--bukkit-settings" -> bukkitYml = args[i + 1];
|
||||||
|
case "-w", "--level-name", "--world" -> levelName = args[i + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,5 +37,8 @@ public class ServerProperties {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (levelName != null) LEVEL_NAME = levelName;
|
||||||
|
else LEVEL_NAME = DATA.getProperty("level-name", "world");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -678,6 +678,15 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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) {
|
private WorldLoader.DataLoadContext supplier(WorldLoader.DataLoadContext old) {
|
||||||
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
||||||
old.resources(),
|
old.resources(),
|
||||||
@@ -730,7 +739,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
||||||
var loc = new ResourceLocation("iris", key.location().getPath());
|
var loc = createIrisKey(key);
|
||||||
target.register(key, new LevelStem(
|
target.register(key, new LevelStem(
|
||||||
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
||||||
source
|
source
|
||||||
@@ -746,4 +755,8 @@ public class NMSBinding implements INMSBinding {
|
|||||||
target.register(key, value, info);
|
target.register(key, value, info);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ResourceLocation createIrisKey(ResourceKey<LevelStem> key) {
|
||||||
|
return new ResourceLocation("iris", key.location().getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -679,6 +679,15 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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) {
|
private WorldLoader.DataLoadContext supplier(WorldLoader.DataLoadContext old) {
|
||||||
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
||||||
old.resources(),
|
old.resources(),
|
||||||
@@ -731,7 +740,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
||||||
var loc = new ResourceLocation("iris", key.location().getPath());
|
var loc = createIrisKey(key);
|
||||||
target.register(key, new LevelStem(
|
target.register(key, new LevelStem(
|
||||||
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
||||||
source
|
source
|
||||||
@@ -747,4 +756,8 @@ public class NMSBinding implements INMSBinding {
|
|||||||
target.register(key, value, info);
|
target.register(key, value, info);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ResourceLocation createIrisKey(ResourceKey<LevelStem> key) {
|
||||||
|
return new ResourceLocation("iris", key.location().getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -680,6 +680,15 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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) {
|
private WorldLoader.DataLoadContext supplier(WorldLoader.DataLoadContext old) {
|
||||||
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
||||||
old.resources(),
|
old.resources(),
|
||||||
@@ -732,7 +741,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
||||||
var loc = new ResourceLocation("iris", key.location().getPath());
|
var loc = createIrisKey(key);
|
||||||
target.register(key, new LevelStem(
|
target.register(key, new LevelStem(
|
||||||
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
||||||
source
|
source
|
||||||
@@ -748,4 +757,8 @@ public class NMSBinding implements INMSBinding {
|
|||||||
target.register(key, value, info);
|
target.register(key, value, info);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ResourceLocation createIrisKey(ResourceKey<LevelStem> key) {
|
||||||
|
return new ResourceLocation("iris", key.location().getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -705,6 +705,15 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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) {
|
private WorldLoader.DataLoadContext supplier(WorldLoader.DataLoadContext old) {
|
||||||
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
||||||
old.resources(),
|
old.resources(),
|
||||||
@@ -757,7 +766,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
||||||
var loc = new ResourceLocation("iris", key.location().getPath());
|
var loc = createIrisKey(key);
|
||||||
target.register(key, new LevelStem(
|
target.register(key, new LevelStem(
|
||||||
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
||||||
source
|
source
|
||||||
@@ -773,4 +782,8 @@ public class NMSBinding implements INMSBinding {
|
|||||||
target.register(key, value, info);
|
target.register(key, value, info);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ResourceLocation createIrisKey(ResourceKey<LevelStem> key) {
|
||||||
|
return new ResourceLocation("iris", key.location().getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -709,6 +709,15 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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) {
|
private WorldLoader.DataLoadContext supplier(WorldLoader.DataLoadContext old) {
|
||||||
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
||||||
old.resources(),
|
old.resources(),
|
||||||
@@ -761,7 +770,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
||||||
var loc = ResourceLocation.fromNamespaceAndPath("iris", key.location().getPath());
|
var loc = createIrisKey(key);
|
||||||
target.register(key, new LevelStem(
|
target.register(key, new LevelStem(
|
||||||
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
dimensions.getHolder(ResourceKey.create(Registries.DIMENSION_TYPE, loc)).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
||||||
source
|
source
|
||||||
@@ -777,4 +786,8 @@ public class NMSBinding implements INMSBinding {
|
|||||||
target.register(key, value, info);
|
target.register(key, value, info);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ResourceLocation createIrisKey(ResourceKey<LevelStem> key) {
|
||||||
|
return ResourceLocation.fromNamespaceAndPath("iris", key.location().getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -699,6 +699,15 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean missingDimensionTypes(boolean overworld, boolean nether, boolean end) {
|
||||||
|
var registry = registry().lookupOrThrow(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) {
|
private WorldLoader.DataLoadContext supplier(WorldLoader.DataLoadContext old) {
|
||||||
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
||||||
old.resources(),
|
old.resources(),
|
||||||
@@ -751,7 +760,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
||||||
var loc = ResourceLocation.fromNamespaceAndPath("iris", key.location().getPath());
|
var loc = createIrisKey(key);
|
||||||
target.register(key, new LevelStem(
|
target.register(key, new LevelStem(
|
||||||
dimensions.get(loc).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
dimensions.get(loc).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
||||||
source
|
source
|
||||||
@@ -767,4 +776,8 @@ public class NMSBinding implements INMSBinding {
|
|||||||
target.register(key, value, info);
|
target.register(key, value, info);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ResourceLocation createIrisKey(ResourceKey<LevelStem> key) {
|
||||||
|
return ResourceLocation.fromNamespaceAndPath("iris", key.location().getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -698,6 +698,15 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean missingDimensionTypes(boolean overworld, boolean nether, boolean end) {
|
||||||
|
var registry = registry().lookupOrThrow(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) {
|
private WorldLoader.DataLoadContext supplier(WorldLoader.DataLoadContext old) {
|
||||||
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
return dataLoadContext.aquire(() -> new WorldLoader.DataLoadContext(
|
||||||
old.resources(),
|
old.resources(),
|
||||||
@@ -750,7 +759,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
private void register(MappedRegistry<LevelStem> target, Registry<DimensionType> dimensions, FlatLevelSource source, ResourceKey<LevelStem> key) {
|
||||||
var loc = ResourceLocation.fromNamespaceAndPath("iris", key.location().getPath());
|
var loc = createIrisKey(key);
|
||||||
target.register(key, new LevelStem(
|
target.register(key, new LevelStem(
|
||||||
dimensions.get(loc).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
dimensions.get(loc).orElseThrow(() -> new IllegalStateException("Missing dimension type " + loc + " in " + dimensions.keySet())),
|
||||||
source
|
source
|
||||||
@@ -766,4 +775,8 @@ public class NMSBinding implements INMSBinding {
|
|||||||
target.register(key, value, info);
|
target.register(key, value, info);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ResourceLocation createIrisKey(ResourceKey<LevelStem> key) {
|
||||||
|
return ResourceLocation.fromNamespaceAndPath("iris", key.location().getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user