mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-20 07:10:24 +00:00
BiomeGrid no longer needs World object.
This commit is contained in:
@@ -16,6 +16,7 @@ import com.dfsek.terra.fabric.inventory.FabricItemHandle;
|
||||
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
|
||||
import com.dfsek.terra.fabric.world.FabricBiome;
|
||||
import com.dfsek.terra.fabric.world.FabricWorldHandle;
|
||||
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.world.generator.TerraChunkGeneratorCodec;
|
||||
import com.dfsek.terra.registry.ConfigRegistry;
|
||||
@@ -24,7 +25,6 @@ import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.world.GeneratorType;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.VanillaLayeredBiomeSource;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
||||
import net.minecraft.world.gen.chunk.FlatChunkGeneratorConfig;
|
||||
@@ -45,7 +45,8 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
new StructuresConfig(Optional.empty(), Collections.emptyMap()), biomeRegistry);
|
||||
config.updateLayerBlocks();
|
||||
|
||||
return new FabricChunkGeneratorWrapper(new VanillaLayeredBiomeSource(seed, false, false, biomeRegistry), seed);
|
||||
|
||||
return new FabricChunkGeneratorWrapper(new TerraBiomeSource(biomeRegistry, seed), seed);
|
||||
}
|
||||
};
|
||||
private final TerraChunkGeneratorCodec chunkGeneratorCodec = new TerraChunkGeneratorCodec(this);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.dfsek.terra.fabric.codec;
|
||||
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
|
||||
public class ConfigPackCodec implements Codec<ConfigPack> {
|
||||
@Override
|
||||
public <T> DataResult<Pair<ConfigPack, T>> decode(DynamicOps<T> ops, T input) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> DataResult<T> encode(ConfigPack input, DynamicOps<T> ops, T prefix) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.dfsek.terra.fabric.world;
|
||||
|
||||
import com.dfsek.terra.registry.TerraRegistry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class FabricBiomeRegistry extends TerraRegistry<Biome> {
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.dfsek.terra.fabric.world;
|
||||
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryLookupCodec;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TerraBiomeSource extends BiomeSource {
|
||||
public static final Codec<TerraBiomeSource> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
RegistryLookupCodec.of(Registry.BIOME_KEY).forGetter(source -> source.biomeRegistry),
|
||||
Codec.LONG.fieldOf("seed").stable().forGetter(source -> source.seed))
|
||||
.apply(instance, instance.stable(TerraBiomeSource::new)));
|
||||
|
||||
private final Registry<Biome> biomeRegistry;
|
||||
private final long seed;
|
||||
private final TerraPlugin main;
|
||||
|
||||
public TerraBiomeSource(Registry<Biome> biomes, long seed) {
|
||||
super(biomes.stream().collect(Collectors.toList()));
|
||||
this.biomeRegistry = biomes;
|
||||
this.seed = seed;
|
||||
this.main = TerraFabricPlugin.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Codec<? extends BiomeSource> getCodec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeSource withSeed(long seed) {
|
||||
return new TerraBiomeSource(this.biomeRegistry, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiomeForNoiseGen(int biomeX, int biomeY, int biomeZ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user