diff --git a/gradle.properties b/gradle.properties index a8cf493..afc48b5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,14 +2,14 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties -minecraft_version=1.19.4 -yarn_mappings=1.19.4+build.1 -loader_version=0.14.19 +minecraft_version=1.20-rc1 +yarn_mappings=1.20-rc1+build.2 +loader_version=0.14.21 # Mod Properties -mod_version=0.4.10 +mod_version=0.4.11 maven_group=xyz.nucleoid archives_base_name=fantasy # Dependencies -fabric_version=0.79.0+1.19.4 +fabric_version=0.83.0+1.20 diff --git a/src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java b/src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java index be7325e..8b7ea06 100644 --- a/src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java +++ b/src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java @@ -7,6 +7,7 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.util.ProgressListener; import net.minecraft.util.Util; +import net.minecraft.util.math.random.RandomSequencesState; import net.minecraft.world.World; import net.minecraft.world.biome.source.BiomeAccess; import net.minecraft.world.dimension.DimensionOptions; @@ -22,6 +23,7 @@ public class RuntimeWorld extends ServerWorld { final Style style; + private boolean flat; protected RuntimeWorld(MinecraftServer server, RegistryKey registryKey, RuntimeWorldConfig config, Style style) { super( @@ -33,19 +35,21 @@ protected RuntimeWorld(MinecraftServer server, RegistryKey registryKey, R false, BiomeAccess.hashSeed(config.getSeed()), ImmutableList.of(), - config.shouldTickTime() + config.shouldTickTime(), + null ); this.style = style; + this.flat = config.isFlat().orElse(super.isFlat()); } - protected RuntimeWorld(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey worldKey, DimensionOptions dimensionOptions, WorldGenerationProgressListener worldGenerationProgressListener, boolean debugWorld, long seed, List spawners, boolean shouldTickTime, Style style) { - super(server, workerExecutor, session, properties, worldKey, dimensionOptions, worldGenerationProgressListener, debugWorld, seed, spawners, shouldTickTime); + protected RuntimeWorld(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey worldKey, DimensionOptions dimensionOptions, WorldGenerationProgressListener worldGenerationProgressListener, boolean debugWorld, long seed, List spawners, boolean shouldTickTime, @Nullable RandomSequencesState randomSequencesState, Style style) { + super(server, workerExecutor, session, properties, worldKey, dimensionOptions, worldGenerationProgressListener, debugWorld, seed, spawners, shouldTickTime, randomSequencesState); this.style = style; } - @Override + @Override public long getSeed() { return ((RuntimeWorldProperties) this.properties).config.getSeed(); } @@ -57,6 +61,11 @@ public void save(@Nullable ProgressListener progressListener, boolean flush, boo } } + @Override + public boolean isFlat() { + return this.flat; + } + public enum Style { PERSISTENT, TEMPORARY diff --git a/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldConfig.java b/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldConfig.java index ae26ecf..c33a23c 100644 --- a/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldConfig.java +++ b/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldConfig.java @@ -1,6 +1,7 @@ package xyz.nucleoid.fantasy; import com.google.common.base.Preconditions; +import net.fabricmc.fabric.api.util.TriState; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; @@ -35,6 +36,7 @@ public final class RuntimeWorldConfig { private int rainTime; private boolean thundering; private int thunderTime; + private TriState flat = TriState.DEFAULT; public RuntimeWorldConfig setSeed(long seed) { this.seed = seed; @@ -124,6 +126,15 @@ public RuntimeWorldConfig setThundering(boolean thundering) { return this; } + public RuntimeWorldConfig setFlat(TriState state) { + this.flat = state; + return this; + } + + public RuntimeWorldConfig setFlat(boolean state) { + return this.setFlat(TriState.of(state)); + } + public long getSeed() { return this.seed; } @@ -186,4 +197,8 @@ public boolean isRaining() { public boolean isThundering() { return this.thundering; } + + public TriState isFlat() { + return this.flat; + } } diff --git a/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldHandle.java b/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldHandle.java index f3f480b..d101f9f 100644 --- a/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldHandle.java +++ b/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldHandle.java @@ -28,7 +28,11 @@ public void delete() { * Unloads the world. It only deletes the files if world is temporary. */ public void unload() { - this.fantasy.enqueueWorldUnloading(this.world); + if (this.world instanceof RuntimeWorld runtimeWorld && runtimeWorld.style == RuntimeWorld.Style.TEMPORARY) { + this.fantasy.enqueueWorldDeletion(this.world); + } else { + this.fantasy.enqueueWorldUnloading(this.world); + } } public ServerWorld asWorld() { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0eea21c..633219a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,7 +20,7 @@ }, "depends": { "fabricloader": ">=0.14.0", - "minecraft": "1.19.x", + "minecraft": ">=1.20-", "fabric-lifecycle-events-v1": "*", "java": ">=17" } diff --git a/src/testmod/java/xyz/nucleoid/fantasy/test/FantasyInitializer.java b/src/testmod/java/xyz/nucleoid/fantasy/test/FantasyInitializer.java index 86de559..71cefb4 100644 --- a/src/testmod/java/xyz/nucleoid/fantasy/test/FantasyInitializer.java +++ b/src/testmod/java/xyz/nucleoid/fantasy/test/FantasyInitializer.java @@ -51,13 +51,18 @@ public void onInitialize() { .setGenerator(context.getSource().getServer().getOverworld().getChunkManager().getChunkGenerator()) .setSeed(id.hashCode()) ); - context.getSource().sendFeedback(Text.literal("WorldCreate: " + (System.currentTimeMillis() - t)), false); - + { + var text = Text.literal("WorldCreate: " + (System.currentTimeMillis() - t)); + context.getSource().sendFeedback(() -> text, false); + } worlds.put(id, x); + t = System.currentTimeMillis(); FabricDimensions.teleport(context.getSource().getEntity(), x.asWorld(), new TeleportTarget(new Vec3d(0, 100 ,0) , Vec3d.ZERO, 0, 0)); - context.getSource().sendFeedback(Text.literal("Teleport: " + (System.currentTimeMillis() - t)), false); - } catch (Throwable e) { + { + var text = Text.literal("Teleport: " + (System.currentTimeMillis() - t)); + context.getSource().sendFeedback(() -> text, false); + } } catch (Throwable e) { e.printStackTrace(); }