Skip to content

Commit

Permalink
small QoL stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ToCraft committed Oct 31, 2024
1 parent 988a368 commit b2df808
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// 1.20.1 2024-10-30T16:59:23.271237421 CTGen/Registries
// 1.20.1 2024-10-31T08:40:04.240776243 CTGen/Registries
09917112f8476aaef3e39f5780a478b955edc3e7 data/ctgen/worldgen/map_based/zones/plains.json
fc93d44fc964204f73808d4a6b8c33961b64610c data/ctgen/worldgen/map_based/zones/badlands_mountains.json
ea8abee99ec67bf274bec024eff481325863952a data/ctgen/worldgen/map_based/zones/stony_flats.json
4e10b1b02ad79d86538524c470d56dedf8c779f1 data/ctgen/worldgen/map_based/zones/desert.json
166eb560b75b90c63217a66b4eac9cf59dcb8f9e data/ctgen/worldgen/map_based/zones/lake.json
b24dcc94b75a2092b2386357c78a1f93808fd7f8 data/ctgen/worldgen/map_based/zones/river.json
786353e42c828bf1348fb727db3e60adec29c18d data/ctgen/worldgen/map_based/zones/forest.json
a78f910d231a5d843042462e8517155aab8b5ca2 data/ctgen/worldgen/map_based/zones/snowy_mountains.json
786353e42c828bf1348fb727db3e60adec29c18d data/ctgen/worldgen/map_based/zones/forest.json
3fcf216d906f96f57ba447df2dab0a13157af1ce data/ctgen/worldgen/map_based/zones/snowy_slopes.json
4c3211676a9ddc326773659b60f0e221ccad2216 data/ctgen/worldgen/map_based/zones/badlands.json
10fbdfeee308b501bed36a2d800c40b11810ce63 data/ctgen/worldgen/map_based/zones/ocean.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.jetbrains.annotations.NotNull;

@SuppressWarnings("unused")
public class CTerrainGeneration {
public final class CTerrainGeneration {
public static final String MODID = "ctgen";

@Contract("_ -> new")
Expand Down
4 changes: 1 addition & 3 deletions common/src/main/java/dev/tocraft/ctgen/util/Codecs.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;

import java.awt.*;
Expand All @@ -27,5 +25,5 @@ public final class Codecs {
}
});

public static final Codec<Block> BLOCK = ResourceLocation.CODEC.comapFlatMap(id -> BuiltInRegistries.BLOCK.containsKey(id) ? DataResult.success(BuiltInRegistries.BLOCK.get(id)) : DataResult.error(() -> String.format("Block %s not found!", id)), BuiltInRegistries.BLOCK::getKey).stable();
public static final Codec<Block> BLOCK = BuiltInRegistries.BLOCK.byNameCodec().stable();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public boolean is(SimplexNoise noise, int x, int y, int z, Zone zone, int minY,
BlockPlacer.CODEC.fieldOf("fallback").forGetter(BlockLayer::getFallback)
).apply(instance, instance.stable(SurfaceLayer::new)));

public static final ResourceLocation ID = CTerrainGeneration.id("sea");
public static final ResourceLocation ID = CTerrainGeneration.id("surface");

@Override
protected Codec<SurfaceLayer> codec() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BasicSurface extends TerrainHeight {
public static final BasicSurface DEFAULT = new BasicSurface(Noise.DEFAULT);

public static final Codec<BasicSurface> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Noise.CODEC.fieldOf("noise").forGetter(o -> o.noise)
Noise.CODEC.optionalFieldOf("noise", Noise.DEFAULT).forGetter(o -> o.noise)
).apply(instance, BasicSurface::new));
public static final ResourceLocation ID = CTerrainGeneration.id("basic");

Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/dev/tocraft/ctgen/zone/Zones.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.HashMap;
import java.util.List;

public class Zones {
public final class Zones {
// Northern Continent
public static final ResourceKey<Zone> STONY_FLATS = getKey("stony_flats");
public static final ResourceKey<Zone> SNOWY_FLATS = getKey("snowy_flats");
Expand Down
6 changes: 3 additions & 3 deletions fabric/src/main/java/dev/tocraft/ctgen/fabric/CTGDataGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public void onInitializeDataGenerator(@NotNull FabricDataGenerator generator) {
FabricDataGenerator.Pack pack = generator.createPack();
// generate zones
pack.addProvider((FabricDataGenerator.Pack.RegistryDependentFactory<DataProvider>) (output, registriesFuture) ->
new RegistriesDatapackGenerator(output, CompletableFuture.supplyAsync(() -> {
new RegistriesDatapackGenerator(output, registriesFuture.thenComposeAsync(registries -> CompletableFuture.supplyAsync(() -> {
RegistryAccess.Frozen frozen = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY);
return BUILDER.buildPatch(frozen, registriesFuture.join());
})));
return BUILDER.buildPatch(frozen, registries);
}))));
}
}

0 comments on commit b2df808

Please sign in to comment.