Public Access
This commit is contained in:
1 parent
04006ee36a
commit
8bb5e16720
5 files changed
+29
-3
No files matched your search
@@ -21,7 +21,7 @@ public record AgeDefinition(
|
||||
public static final ResourceLocation RANDOM_VANILLA_PROFILE = ResourceLocation.fromNamespaceAndPath(
|
||||
Rivencraft.MOD_ID, "random_vanilla"
|
||||
);
|
||||
public static final int CURRENT_GENERATION_VERSION = 5;
|
||||
public static final int CURRENT_GENERATION_VERSION = 6;
|
||||
|
||||
public AgeDefinition {
|
||||
Objects.requireNonNull(id, "id");
|
||||
|
||||
@@ -46,11 +46,14 @@ public final class AgeDimensionService {
|
||||
DynamicDimensionLoadCallback.register((server, loader) -> {
|
||||
ServerLevel overworld = server.overworld();
|
||||
for (AgeDefinition age : AgeRegistrySavedData.get(overworld).definitions()) {
|
||||
loader.loadDynamicDimension(
|
||||
ServerLevel level = loader.loadDynamicDimension(
|
||||
age.dimensionId(),
|
||||
createGenerator(server, age),
|
||||
createDimensionType(age)
|
||||
);
|
||||
if (level != null) {
|
||||
applyCelestialClock(level, age);
|
||||
}
|
||||
}
|
||||
synchronizeImmersivePortals(server);
|
||||
});
|
||||
@@ -65,6 +68,7 @@ public final class AgeDimensionService {
|
||||
|
||||
BlockPos spawn = definition.spawn();
|
||||
if (spawn == null) {
|
||||
applyInitialCelestialPhase(level, definition);
|
||||
spawn = createSafeSpawn(level, definition);
|
||||
definition = AgeRegistrySavedData.get(level).setSpawn(definition.id(), spawn);
|
||||
}
|
||||
@@ -79,6 +83,7 @@ public final class AgeDimensionService {
|
||||
ResourceKey<Level> key = dimensionKey(definition);
|
||||
ServerLevel existing = server.getLevel(key);
|
||||
if (existing != null) {
|
||||
applyCelestialClock(existing, definition);
|
||||
return existing;
|
||||
}
|
||||
|
||||
@@ -91,11 +96,21 @@ public final class AgeDimensionService {
|
||||
if (loaded == null) {
|
||||
Rivencraft.LOGGER.error("Failed to load Age {} as {}", definition.id(), definition.dimensionId());
|
||||
} else {
|
||||
applyCelestialClock(loaded, definition);
|
||||
synchronizeImmersivePortals(server);
|
||||
}
|
||||
return loaded;
|
||||
}
|
||||
|
||||
private static void applyCelestialClock(ServerLevel level, AgeDefinition age) {
|
||||
level.setDayTimePerTick((float)(1.0D / age.traits().celestialPeriod()));
|
||||
}
|
||||
|
||||
private static void applyInitialCelestialPhase(ServerLevel level, AgeDefinition age) {
|
||||
long phaseTime = (long)(age.traits().celestialPhase() * Level.TICKS_PER_DAY);
|
||||
level.setDayTime(phaseTime);
|
||||
}
|
||||
|
||||
private static void synchronizeImmersivePortals(MinecraftServer server) {
|
||||
if (ModList.get().isLoaded("immersive_portals_core")) {
|
||||
ImmersivePortalsChunkLoaders.dimensionsChanged(server);
|
||||
|
||||
@@ -186,6 +186,9 @@ public final class LinkingGameTests {
|
||||
? 0.25F : 0.0F;
|
||||
helper.assertTrue(Math.abs(level.dimensionType().ambientLight() - expectedAmbientLight) < 0.0001F,
|
||||
"The runtime dimension must apply the persisted lighting trait");
|
||||
float expectedDaySpeed = (float)(1.0D / definition.traits().celestialPeriod());
|
||||
helper.assertTrue(Math.abs(level.getDayTimePerTick() - expectedDaySpeed) < 0.0001F,
|
||||
"The runtime dimension must apply the persisted celestial period");
|
||||
}
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user