Nether biome source (WIP)
This commit is contained in:
parent
34ecbb3f14
commit
683427c312
9 changed files with 215 additions and 12 deletions
|
@ -17,6 +17,7 @@ import ru.bclib.registry.BaseBlockEntities;
|
||||||
import ru.bclib.registry.BaseRegistry;
|
import ru.bclib.registry.BaseRegistry;
|
||||||
import ru.bclib.util.Logger;
|
import ru.bclib.util.Logger;
|
||||||
import ru.bclib.world.generator.BCLibEndBiomeSource;
|
import ru.bclib.world.generator.BCLibEndBiomeSource;
|
||||||
|
import ru.bclib.world.generator.BCLibNetherBiomeSource;
|
||||||
import ru.bclib.world.surface.BCLSurfaceBuilders;
|
import ru.bclib.world.surface.BCLSurfaceBuilders;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -31,6 +32,7 @@ public class BCLib implements ModInitializer {
|
||||||
BaseBlockEntities.register();
|
BaseBlockEntities.register();
|
||||||
BCLSurfaceBuilders.register();
|
BCLSurfaceBuilders.register();
|
||||||
BCLibEndBiomeSource.register();
|
BCLibEndBiomeSource.register();
|
||||||
|
BCLibNetherBiomeSource.register();
|
||||||
TagAPI.init();
|
TagAPI.init();
|
||||||
CraftingRecipes.init();
|
CraftingRecipes.init();
|
||||||
WorldDataAPI.registerModCache(MOD_ID);
|
WorldDataAPI.registerModCache(MOD_ID);
|
||||||
|
|
|
@ -32,6 +32,19 @@ public class BiomeAPI {
|
||||||
*/
|
*/
|
||||||
public static final BCLBiome EMPTY_BIOME = new BCLBiome(Biomes.THE_VOID.location(), BuiltinRegistries.BIOME.get(Biomes.THE_VOID), 1, 0);
|
public static final BCLBiome EMPTY_BIOME = new BCLBiome(Biomes.THE_VOID.location(), BuiltinRegistries.BIOME.get(Biomes.THE_VOID), 1, 0);
|
||||||
|
|
||||||
|
public static final BCLBiome NETHER_WASTES_BIOME = registerNetherBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("nether_wastes")));
|
||||||
|
public static final BCLBiome CRIMSON_FOREST_BIOME = registerNetherBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("crimson_forest")));
|
||||||
|
public static final BCLBiome WARPED_FOREST_BIOME = registerNetherBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("warped_forest")));
|
||||||
|
public static final BCLBiome SOUL_SAND_VALLEY_BIOME = registerNetherBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("soul_sand_valley")));
|
||||||
|
public static final BCLBiome BASALT_DELTAS_BIOME = registerNetherBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("basalt_deltas")));
|
||||||
|
|
||||||
|
public static final BCLBiome THE_END = registerEndLandBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("the_end")));
|
||||||
|
public static final BCLBiome END_MIDLANDS = registerSubBiome(THE_END, BuiltinRegistries.BIOME.get(new ResourceLocation("end_midlands")), 0.5F);
|
||||||
|
public static final BCLBiome END_HIGHLANDS = registerSubBiome(THE_END, BuiltinRegistries.BIOME.get(new ResourceLocation("end_highlands")), 0.5F);
|
||||||
|
|
||||||
|
public static final BCLBiome END_BARRENS = registerEndVoidBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("end_barrens")));
|
||||||
|
public static final BCLBiome SMALL_END_ISLANDS = registerEndVoidBiome(BuiltinRegistries.BIOME.get(new ResourceLocation("small_end_islands")));
|
||||||
|
|
||||||
private static final Map<ResourceLocation, BCLBiome> NETHER_BIOMES = Maps.newHashMap();
|
private static final Map<ResourceLocation, BCLBiome> NETHER_BIOMES = Maps.newHashMap();
|
||||||
private static final Map<ResourceLocation, BCLBiome> END_LAND_BIOMES = Maps.newHashMap();
|
private static final Map<ResourceLocation, BCLBiome> END_LAND_BIOMES = Maps.newHashMap();
|
||||||
private static final Map<ResourceLocation, BCLBiome> END_VOID_BIOMES = Maps.newHashMap();
|
private static final Map<ResourceLocation, BCLBiome> END_VOID_BIOMES = Maps.newHashMap();
|
||||||
|
@ -57,18 +70,33 @@ public class BiomeAPI {
|
||||||
/**
|
/**
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||||
* @param biome {@link BCLBiome}
|
* @param biome {@link BCLBiome}
|
||||||
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static void registerBiome(BCLBiome biome) {
|
public static BCLBiome registerBiome(BCLBiome biome) {
|
||||||
if (BuiltinRegistries.BIOME.get(biome.getID()) == null) {
|
if (BuiltinRegistries.BIOME.get(biome.getID()) == null) {
|
||||||
Registry.register(BuiltinRegistries.BIOME, biome.getID(), biome.getBiome());
|
Registry.register(BuiltinRegistries.BIOME, biome.getID(), biome.getBiome());
|
||||||
}
|
}
|
||||||
ID_MAP.put(biome.getID(), biome);
|
ID_MAP.put(biome.getID(), biome);
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BCLBiome registerSubBiome(BCLBiome parent, BCLBiome subBiome) {
|
||||||
|
registerBiome(subBiome);
|
||||||
|
parent.addSubBiome(subBiome);
|
||||||
|
return subBiome;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BCLBiome registerSubBiome(BCLBiome parent, Biome biome, float chance) {
|
||||||
|
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome).get();
|
||||||
|
BCLBiome subBiome = new BCLBiome(key.location(), biome, 1, chance);
|
||||||
|
return registerSubBiome(parent, subBiome);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||||
* After that biome will be added to BCLib Nether Biome Generator and into Fabric Biome API.
|
* After that biome will be added to BCLib Nether Biome Generator and into Fabric Biome API.
|
||||||
* @param biome {@link BCLBiome}
|
* @param biome {@link BCLBiome}
|
||||||
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static void registerNetherBiome(BCLBiome biome) {
|
public static void registerNetherBiome(BCLBiome biome) {
|
||||||
registerBiome(biome);
|
registerBiome(biome);
|
||||||
|
@ -89,63 +117,73 @@ public class BiomeAPI {
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||||
* After that biome will be added to BCLib Nether Biome Generator and into Fabric Biome API.
|
* After that biome will be added to BCLib Nether Biome Generator and into Fabric Biome API.
|
||||||
* @param biome {@link BCLBiome}
|
* @param biome {@link BCLBiome}
|
||||||
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static void registerNetherBiome(Biome biome) {
|
public static BCLBiome registerNetherBiome(Biome biome) {
|
||||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome).get();
|
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome).get();
|
||||||
BCLBiome bclBiome = new BCLBiome(key.location(), biome, 1, 1);
|
BCLBiome bclBiome = new BCLBiome(key.location(), biome, 1, 1);
|
||||||
NETHER_BIOME_PICKER.addBiome(bclBiome);
|
NETHER_BIOME_PICKER.addBiome(bclBiome);
|
||||||
registerBiome(bclBiome);
|
registerBiome(bclBiome);
|
||||||
|
return bclBiome;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||||
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a land biome (will generate only on islands).
|
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a land biome (will generate only on islands).
|
||||||
* @param biome {@link BCLBiome}
|
* @param biome {@link BCLBiome}
|
||||||
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static void registerEndLandBiome(BCLBiome biome) {
|
public static BCLBiome registerEndLandBiome(BCLBiome biome) {
|
||||||
registerBiome(biome);
|
registerBiome(biome);
|
||||||
END_LAND_BIOME_PICKER.addBiome(biome);
|
END_LAND_BIOME_PICKER.addBiome(biome);
|
||||||
float weight = biome.getGenChance();
|
float weight = biome.getGenChance();
|
||||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
||||||
InternalBiomeData.addEndBiomeReplacement(Biomes.END_HIGHLANDS, key, weight);
|
InternalBiomeData.addEndBiomeReplacement(Biomes.END_HIGHLANDS, key, weight);
|
||||||
InternalBiomeData.addEndBiomeReplacement(Biomes.END_MIDLANDS, key, weight);
|
InternalBiomeData.addEndBiomeReplacement(Biomes.END_MIDLANDS, key, weight);
|
||||||
|
return biome;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register {@link BCLBiome} wrapper for {@link Biome}.
|
* Register {@link BCLBiome} wrapper for {@link Biome}.
|
||||||
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a land biome (will generate only on islands).
|
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a land biome (will generate only on islands).
|
||||||
* @param biome {@link BCLBiome}
|
* @param biome {@link BCLBiome}
|
||||||
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static void registerEndLandBiome(Biome biome) {
|
public static BCLBiome registerEndLandBiome(Biome biome) {
|
||||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome).get();
|
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome).get();
|
||||||
BCLBiome bclBiome = new BCLBiome(key.location(), biome, 1, 1);
|
BCLBiome bclBiome = new BCLBiome(key.location(), biome, 1, 1);
|
||||||
END_LAND_BIOME_PICKER.addBiome(bclBiome);
|
END_LAND_BIOME_PICKER.addBiome(bclBiome);
|
||||||
registerBiome(bclBiome);
|
registerBiome(bclBiome);
|
||||||
|
return bclBiome;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||||
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a void biome (will generate only in the End void - between islands).
|
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a void biome (will generate only in the End void - between islands).
|
||||||
* @param biome {@link BCLBiome}
|
* @param biome {@link BCLBiome}
|
||||||
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static void registerEndVoidBiome(BCLBiome biome) {
|
public static BCLBiome registerEndVoidBiome(BCLBiome biome) {
|
||||||
registerBiome(biome);
|
registerBiome(biome);
|
||||||
END_VOID_BIOME_PICKER.addBiome(biome);
|
END_VOID_BIOME_PICKER.addBiome(biome);
|
||||||
float weight = biome.getGenChance();
|
float weight = biome.getGenChance();
|
||||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
||||||
InternalBiomeData.addEndBiomeReplacement(Biomes.SMALL_END_ISLANDS, key, weight);
|
InternalBiomeData.addEndBiomeReplacement(Biomes.SMALL_END_ISLANDS, key, weight);
|
||||||
|
return biome;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||||
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a void biome (will generate only in the End void - between islands).
|
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a void biome (will generate only in the End void - between islands).
|
||||||
* @param biome {@link BCLBiome}
|
* @param biome {@link BCLBiome}
|
||||||
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static void registerEndVoidBiome(Biome biome) {
|
public static BCLBiome registerEndVoidBiome(Biome biome) {
|
||||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome).get();
|
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome).get();
|
||||||
BCLBiome bclBiome = new BCLBiome(key.location(), biome, 1, 1);
|
BCLBiome bclBiome = new BCLBiome(key.location(), biome, 1, 1);
|
||||||
END_VOID_BIOME_PICKER.addBiome(bclBiome);
|
END_VOID_BIOME_PICKER.addBiome(bclBiome);
|
||||||
registerBiome(bclBiome);
|
registerBiome(bclBiome);
|
||||||
|
return bclBiome;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
35
src/main/java/ru/bclib/mixin/common/DimensionTypeMixin.java
Normal file
35
src/main/java/ru/bclib/mixin/common/DimensionTypeMixin.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package ru.bclib.mixin.common;
|
||||||
|
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
|
import net.minecraft.world.level.dimension.DimensionType;
|
||||||
|
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||||
|
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import ru.bclib.world.generator.BCLibEndBiomeSource;
|
||||||
|
import ru.bclib.world.generator.BCLibNetherBiomeSource;
|
||||||
|
|
||||||
|
@Mixin(value = DimensionType.class, priority = 100)
|
||||||
|
public class DimensionTypeMixin {
|
||||||
|
@Inject(method = "defaultNetherGenerator", at = @At("HEAD"), cancellable = true)
|
||||||
|
private static void be_replaceNetherBiomeSource(Registry<Biome> biomeRegistry, Registry<NoiseGeneratorSettings> chunkGeneratorSettingsRegistry, long seed, CallbackInfoReturnable<ChunkGenerator> info) {
|
||||||
|
info.setReturnValue(new NoiseBasedChunkGenerator(
|
||||||
|
new BCLibNetherBiomeSource(biomeRegistry, seed),
|
||||||
|
seed,
|
||||||
|
() -> chunkGeneratorSettingsRegistry.getOrThrow(NoiseGeneratorSettings.END)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "defaultEndGenerator", at = @At("HEAD"), cancellable = true)
|
||||||
|
private static void be_replaceEndBiomeSource(Registry<Biome> biomeRegistry, Registry<NoiseGeneratorSettings> chunkGeneratorSettingsRegistry, long seed, CallbackInfoReturnable<ChunkGenerator> info) {
|
||||||
|
info.setReturnValue(new NoiseBasedChunkGenerator(
|
||||||
|
new BCLibEndBiomeSource(biomeRegistry, seed),
|
||||||
|
seed,
|
||||||
|
() -> chunkGeneratorSettingsRegistry.getOrThrow(NoiseGeneratorSettings.END)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ import ru.bclib.interfaces.BiomeListProvider;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mixin(value = WeightedBiomePicker.class, remap = false)
|
@Mixin(value = WeightedBiomePicker.class, remap = false)
|
||||||
public class WeightedBiomePickerAccessor implements BiomeListProvider {
|
public class WeightedBiomePickerMixin implements BiomeListProvider {
|
||||||
private final List<ResourceKey<Biome>> biomes = Lists.newArrayList();
|
private final List<ResourceKey<Biome>> biomes = Lists.newArrayList();
|
||||||
|
|
||||||
@Inject(method = "addBiome", at = @At("TAIL"))
|
@Inject(method = "addBiome", at = @At("TAIL"))
|
26
src/main/java/ru/bclib/mixin/common/WorldGenRegionMixin.java
Normal file
26
src/main/java/ru/bclib/mixin/common/WorldGenRegionMixin.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package ru.bclib.mixin.common;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.server.level.WorldGenRegion;
|
||||||
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(WorldGenRegion.class)
|
||||||
|
public class WorldGenRegionMixin {
|
||||||
|
@Final
|
||||||
|
@Shadow
|
||||||
|
private ChunkPos center;
|
||||||
|
|
||||||
|
@Inject(method = "ensureCanWrite", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void be_alterBlockCheck(BlockPos blockPos, CallbackInfoReturnable<Boolean> info) {
|
||||||
|
int x = blockPos.getX() >> 4;
|
||||||
|
int z = blockPos.getZ() >> 4;
|
||||||
|
WorldGenRegion region = (WorldGenRegion) (Object) this;
|
||||||
|
info.setReturnValue(Math.abs(x - center.x) < 2 && Math.abs(z - center.z) < 2);
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,6 +42,8 @@ public class BCLibEndBiomeSource extends BiomeSource {
|
||||||
public BCLibEndBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
public BCLibEndBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
||||||
super(getBiomes(biomeRegistry));
|
super(getBiomes(biomeRegistry));
|
||||||
|
|
||||||
|
BiomeAPI.END_LAND_BIOME_PICKER.clearMutables();
|
||||||
|
BiomeAPI.END_VOID_BIOME_PICKER.clearMutables();
|
||||||
biomeRegistry.forEach(biome -> {
|
biomeRegistry.forEach(biome -> {
|
||||||
ResourceLocation key = biomeRegistry.getKey(biome);
|
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||||
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||||
|
@ -50,6 +52,8 @@ public class BCLibEndBiomeSource extends BiomeSource {
|
||||||
BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome);
|
BiomeAPI.END_LAND_BIOME_PICKER.addBiomeMutable(bclBiome);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
BiomeAPI.END_LAND_BIOME_PICKER.rebuild();
|
||||||
|
BiomeAPI.END_VOID_BIOME_PICKER.rebuild();
|
||||||
|
|
||||||
this.mapLand = new BiomeMap(seed, GeneratorOptions.getBiomeSizeEndLand(), BiomeAPI.END_LAND_BIOME_PICKER);
|
this.mapLand = new BiomeMap(seed, GeneratorOptions.getBiomeSizeEndLand(), BiomeAPI.END_LAND_BIOME_PICKER);
|
||||||
this.mapVoid = new BiomeMap(seed, GeneratorOptions.getBiomeSizeEndVoid(), BiomeAPI.END_VOID_BIOME_PICKER);
|
this.mapVoid = new BiomeMap(seed, GeneratorOptions.getBiomeSizeEndVoid(), BiomeAPI.END_VOID_BIOME_PICKER);
|
||||||
|
@ -74,6 +78,7 @@ public class BCLibEndBiomeSource extends BiomeSource {
|
||||||
public Biome getNoiseBiome(int biomeX, int biomeY, int biomeZ) {
|
public Biome getNoiseBiome(int biomeX, int biomeY, int biomeZ) {
|
||||||
long i = (long) biomeX * (long) biomeX;
|
long i = (long) biomeX * (long) biomeX;
|
||||||
long j = (long) biomeZ * (long) biomeZ;
|
long j = (long) biomeZ * (long) biomeZ;
|
||||||
|
long check = GeneratorOptions.isFarEndBiomes() ? 65536L : 625L;
|
||||||
long dist = i + j;
|
long dist = i + j;
|
||||||
|
|
||||||
if ((biomeX & 31) == 0 && (biomeZ & 31) == 0) {
|
if ((biomeX & 31) == 0 && (biomeZ & 31) == 0) {
|
||||||
|
@ -81,9 +86,8 @@ public class BCLibEndBiomeSource extends BiomeSource {
|
||||||
mapVoid.clearCache();
|
mapVoid.clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
BCLBiome endBiome = null;
|
|
||||||
if (endLandFunction == null) {
|
if (endLandFunction == null) {
|
||||||
if (dist <= 65536L) return centerBiome;
|
if (dist <= check) return centerBiome;
|
||||||
float height = TheEndBiomeSource.getHeightValue(
|
float height = TheEndBiomeSource.getHeightValue(
|
||||||
noise,
|
noise,
|
||||||
(biomeX >> 1) + 1,
|
(biomeX >> 1) + 1,
|
||||||
|
@ -104,10 +108,10 @@ public class BCLibEndBiomeSource extends BiomeSource {
|
||||||
else {
|
else {
|
||||||
pos.setLocation(biomeX, biomeZ);
|
pos.setLocation(biomeX, biomeZ);
|
||||||
if (endLandFunction.apply(pos)) {
|
if (endLandFunction.apply(pos)) {
|
||||||
return dist <= 65536L ? centerBiome : mapLand.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
|
return dist <= check ? centerBiome : mapLand.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return dist <= 65536L ? barrens : mapVoid.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
|
return dist <= check ? barrens : mapVoid.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,6 +127,6 @@ public class BCLibEndBiomeSource extends BiomeSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
Registry.register(Registry.BIOME_SOURCE, BCLib.makeID("better_end_biome_source"), CODEC);
|
Registry.register(Registry.BIOME_SOURCE, BCLib.makeID("end_biome_source"), CODEC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
package ru.bclib.world.generator;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.resources.RegistryLookupCodec;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
|
import net.minecraft.world.level.biome.Biomes;
|
||||||
|
import net.minecraft.world.level.biome.TheEndBiomeSource;
|
||||||
|
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||||
|
import net.minecraft.world.level.levelgen.synth.SimplexNoise;
|
||||||
|
import ru.bclib.BCLib;
|
||||||
|
import ru.bclib.api.BiomeAPI;
|
||||||
|
import ru.bclib.noise.OpenSimplexNoise;
|
||||||
|
import ru.bclib.world.biomes.BCLBiome;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class BCLibNetherBiomeSource extends BiomeSource {
|
||||||
|
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||||
|
return instance.group(RegistryLookupCodec.create(Registry.BIOME_REGISTRY).forGetter((theEndBiomeSource) -> {
|
||||||
|
return theEndBiomeSource.biomeRegistry;
|
||||||
|
}), Codec.LONG.fieldOf("seed").stable().forGetter((theEndBiomeSource) -> {
|
||||||
|
return theEndBiomeSource.seed;
|
||||||
|
})).apply(instance, instance.stable(BCLibNetherBiomeSource::new));
|
||||||
|
});
|
||||||
|
private final Registry<Biome> biomeRegistry;
|
||||||
|
private BiomeMap biomeMap;
|
||||||
|
private final long seed;
|
||||||
|
|
||||||
|
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed) {
|
||||||
|
super(getBiomes(biomeRegistry));
|
||||||
|
|
||||||
|
BiomeAPI.NETHER_BIOME_PICKER.clearMutables();
|
||||||
|
biomeRegistry.forEach(biome -> {
|
||||||
|
ResourceLocation key = biomeRegistry.getKey(biome);
|
||||||
|
BCLBiome bclBiome = BiomeAPI.getBiome(key);
|
||||||
|
bclBiome.updateActualBiomes(biomeRegistry);
|
||||||
|
if (!BiomeAPI.NETHER_BIOME_PICKER.containsImmutable(key)) {
|
||||||
|
BiomeAPI.NETHER_BIOME_PICKER.addBiomeMutable(bclBiome);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
BiomeAPI.NETHER_BIOME_PICKER.rebuild();
|
||||||
|
|
||||||
|
this.biomeMap = new BiomeMap(seed, GeneratorOptions.getBiomeSizeEndLand(), BiomeAPI.NETHER_BIOME_PICKER);
|
||||||
|
this.biomeRegistry = biomeRegistry;
|
||||||
|
this.seed = seed;
|
||||||
|
|
||||||
|
WorldgenRandom chunkRandom = new WorldgenRandom(seed);
|
||||||
|
chunkRandom.consumeCount(17292);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
|
||||||
|
return biomeRegistry.stream().filter(biome -> BiomeAPI.isEndBiome(biomeRegistry.getKey(biome))).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome getNoiseBiome(int biomeX, int biomeY, int biomeZ) {
|
||||||
|
long i = (long) biomeX * (long) biomeX;
|
||||||
|
long j = (long) biomeZ * (long) biomeZ;
|
||||||
|
|
||||||
|
if ((biomeX & 31) == 0 && (biomeZ & 31) == 0) {
|
||||||
|
biomeMap.clearCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
return biomeMap.getBiome(biomeX << 2, biomeZ << 2).getActualBiome();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeSource withSeed(long seed) {
|
||||||
|
return new BCLibNetherBiomeSource(biomeRegistry, seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Codec<? extends BiomeSource> codec() {
|
||||||
|
return CODEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void register() {
|
||||||
|
Registry.register(Registry.BIOME_SOURCE, BCLib.makeID("nether_biome_source"), CODEC);
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ public class GeneratorOptions {
|
||||||
private static int biomeSizeEndLand;
|
private static int biomeSizeEndLand;
|
||||||
private static int biomeSizeEndVoid;
|
private static int biomeSizeEndVoid;
|
||||||
private static Function<Point, Boolean> endLandFunction;
|
private static Function<Point, Boolean> endLandFunction;
|
||||||
|
private static boolean farEndBiomes;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
biomeSizeNether = Configs.GENERATOR_CONFIG.getInt("nether.biomeMap", "biomeSize", 256);
|
biomeSizeNether = Configs.GENERATOR_CONFIG.getInt("nether.biomeMap", "biomeSize", 256);
|
||||||
|
@ -37,4 +38,12 @@ public class GeneratorOptions {
|
||||||
public static Function<Point, Boolean> getEndLandFunction() {
|
public static Function<Point, Boolean> getEndLandFunction() {
|
||||||
return endLandFunction;
|
return endLandFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isFarEndBiomes() {
|
||||||
|
return farEndBiomes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFarEndBiomes(boolean farEndBiomes) {
|
||||||
|
GeneratorOptions.farEndBiomes = farEndBiomes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,14 @@
|
||||||
"package": "ru.bclib.mixin.common",
|
"package": "ru.bclib.mixin.common",
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"WeightedBiomePickerMixin",
|
||||||
"ComposterBlockAccessor",
|
"ComposterBlockAccessor",
|
||||||
"PotionBrewingAccessor",
|
"PotionBrewingAccessor",
|
||||||
"RecipeManagerAccessor",
|
"RecipeManagerAccessor",
|
||||||
"EnchantmentMenuMixin",
|
"EnchantmentMenuMixin",
|
||||||
"MinecraftServerMixin",
|
"MinecraftServerMixin",
|
||||||
|
"WorldGenRegionMixin",
|
||||||
|
"DimensionTypeMixin",
|
||||||
"RecipeManagerMixin",
|
"RecipeManagerMixin",
|
||||||
"BoneMealItemMixin",
|
"BoneMealItemMixin",
|
||||||
"ServerLevelMixin",
|
"ServerLevelMixin",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue