Skip to content

Commit

Permalink
Update to 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed May 31, 2023
1 parent bcda942 commit 848aa1d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 15 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 13 additions & 4 deletions src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,6 +23,7 @@

public class RuntimeWorld extends ServerWorld {
final Style style;
private boolean flat;

protected RuntimeWorld(MinecraftServer server, RegistryKey<World> registryKey, RuntimeWorldConfig config, Style style) {
super(
Expand All @@ -33,19 +35,21 @@ protected RuntimeWorld(MinecraftServer server, RegistryKey<World> 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<World> worldKey, DimensionOptions dimensionOptions, WorldGenerationProgressListener worldGenerationProgressListener, boolean debugWorld, long seed, List<Spawner> 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<World> worldKey, DimensionOptions dimensionOptions, WorldGenerationProgressListener worldGenerationProgressListener, boolean debugWorld, long seed, List<Spawner> 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();
}
Expand All @@ -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
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/xyz/nucleoid/fantasy/RuntimeWorldConfig.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -186,4 +197,8 @@ public boolean isRaining() {
public boolean isThundering() {
return this.thundering;
}

public TriState isFlat() {
return this.flat;
}
}
6 changes: 5 additions & 1 deletion src/main/java/xyz/nucleoid/fantasy/RuntimeWorldHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"depends": {
"fabricloader": ">=0.14.0",
"minecraft": "1.19.x",
"minecraft": ">=1.20-",
"fabric-lifecycle-events-v1": "*",
"java": ">=17"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 848aa1d

Please sign in to comment.