Skip to content

Commit

Permalink
Pull & Use 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
pisaiah committed Jun 13, 2024
2 parents 8d5ae8c + c8dd252 commit 042a578
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 180 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx2G

# Fabric Properties

minecraft_version=1.21-rc1
yarn_mappings=1.21-rc1+build.1
minecraft_version=1.21
yarn_mappings=1.21+build.1
loader_version=0.15.11

# Mod Properties
mod_version=0.6.0
mod_version=0.6.2
maven_group=xyz.nucleoid
archives_base_name=fantasy

# Dependencies
fabric_version=0.100.0+1.21
fabric_version=0.100.1+1.21
2 changes: 2 additions & 0 deletions src/main/java/xyz/nucleoid/fantasy/FantasyInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import xyz.nucleoid.fantasy.util.TransientChunkGenerator;
import xyz.nucleoid.fantasy.util.VoidChunkGenerator;

public final class FantasyInitializer implements ModInitializer {
@Override
public void onInitialize() {
Registry.register(Registries.CHUNK_GENERATOR, Identifier.of(Fantasy.ID, "void"), VoidChunkGenerator.CODEC);
Registry.register(Registries.CHUNK_GENERATOR, Identifier.of(Fantasy.ID, "transient"), TransientChunkGenerator.CODEC);
}
}
174 changes: 0 additions & 174 deletions src/main/java/xyz/nucleoid/fantasy/util/FilteredRegistry.java

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/java/xyz/nucleoid/fantasy/util/SafeIterator.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package xyz.nucleoid.fantasy.util;

import org.jetbrains.annotations.ApiStatus;

import java.util.Collection;
import java.util.Iterator;

@ApiStatus.Internal
public final class SafeIterator<T> implements Iterator<T> {
private final Object[] values;
private int index = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package xyz.nucleoid.fantasy.util;

import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.registry.RegistryOps;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeKeys;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import xyz.nucleoid.fantasy.RuntimeWorldConfig;

import java.util.function.Function;

/**
* A {@link ChunkGenerator} instance that does not know how to be, and does not care to be serialized.
* This is particularly useful when creating a temporary world with Fantasy.
* <p>
* If serialized, however, it will be loaded as a {@link VoidChunkGenerator void world}.
*
* @see xyz.nucleoid.fantasy.Fantasy#openTemporaryWorld(RuntimeWorldConfig)
*/
public abstract class TransientChunkGenerator extends ChunkGenerator {
public static final MapCodec<? extends ChunkGenerator> CODEC = RecordCodecBuilder.mapCodec(i -> i.group(
RegistryOps.getEntryCodec(BiomeKeys.THE_VOID)
).apply(i, VoidChunkGenerator::new));

public TransientChunkGenerator(BiomeSource biomeSource) {
super(biomeSource);
}

public TransientChunkGenerator(BiomeSource biomeSource, Function<RegistryEntry<Biome>, GenerationSettings> generationSettingsGetter) {
super(biomeSource, generationSettingsGetter);
}

@Override
protected final MapCodec<? extends ChunkGenerator> getCodec() {
return CODEC;
}
}
11 changes: 9 additions & 2 deletions src/main/java/xyz/nucleoid/fantasy/util/VoidChunkGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,24 @@ public VoidChunkGenerator(Registry<Biome> biomeRegistry) {
}

public VoidChunkGenerator(Registry<Biome> biomeRegistry, RegistryKey<Biome> biome) {
this(biomeRegistry.getEntry(biome).get());
this(biomeRegistry.getEntry(biome).orElseThrow());
}

// Create an empty (void) world!
public VoidChunkGenerator(MinecraftServer server) {
this(server.getRegistryManager().get(RegistryKeys.BIOME), BiomeKeys.THE_VOID);
}

// Create a world with a given Biome (as an ID)
public VoidChunkGenerator(MinecraftServer server, Identifier biome) {
this(server.getRegistryManager().get(RegistryKeys.BIOME), RegistryKey.of(RegistryKeys.BIOME, biome));
this(server, RegistryKey.of(RegistryKeys.BIOME, biome));
}

// Create a world with a given Biome (as a RegistryKey)
public VoidChunkGenerator(MinecraftServer server, RegistryKey<Biome> biome) {
this(server.getRegistryManager().get(RegistryKeys.BIOME), biome);
}

@Override
protected MapCodec<? extends ChunkGenerator> getCodec() {
return CODEC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import net.minecraft.server.WorldGenerationProgressListener;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.chunk.ChunkStatus;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

@ApiStatus.Internal
public final class VoidWorldProgressListener implements WorldGenerationProgressListener {
public static final VoidWorldProgressListener INSTANCE = new VoidWorldProgressListener();

Expand Down

0 comments on commit 042a578

Please sign in to comment.