Changed Biome handling
This commit is contained in:
parent
be21b40cff
commit
abaef11682
8 changed files with 121 additions and 96 deletions
|
@ -9,7 +9,7 @@ loom_version=1.0-SNAPSHOT
|
|||
# check these on https://fabricmc.net/versions.html
|
||||
minecraft_version=22w43a
|
||||
loader_version=0.14.10
|
||||
fabric_version=0.65.1+1.19.3
|
||||
fabric_version=0.65.2+1.19.3
|
||||
# Mod Properties
|
||||
mod_version=2.1.3
|
||||
maven_group=org.betterx.bclib
|
||||
|
|
|
@ -6,7 +6,10 @@ import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
|||
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
|
||||
import org.betterx.bclib.api.v2.generator.GeneratorOptions;
|
||||
import org.betterx.bclib.api.v2.levelgen.LevelGenEvents;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||
import org.betterx.bclib.api.v2.levelgen.structures.TemplatePiece;
|
||||
import org.betterx.bclib.api.v2.levelgen.surface.rules.Conditions;
|
||||
import org.betterx.bclib.api.v2.poi.PoiManager;
|
||||
|
@ -24,6 +27,8 @@ import org.betterx.worlds.together.util.Logger;
|
|||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
@ -39,6 +44,84 @@ public class BCLib implements ModInitializer {
|
|||
.getModContainer("nullscape")
|
||||
.isPresent();
|
||||
|
||||
private static void registerTestBiomes() {
|
||||
if (true && isDevEnvironment()) {
|
||||
BCLBiome theYellow = BCLBiomeBuilder
|
||||
.start(makeID("the_yellow"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFF00)
|
||||
.waterColor(0x777700)
|
||||
.waterFogColor(0xFFFF00)
|
||||
.skyColor(0xAAAA00)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.YELLOW_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerEndLandBiome(theYellow);
|
||||
|
||||
BCLBiome theBlue = BCLBiomeBuilder
|
||||
.start(makeID("the_blue"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0x0000FF)
|
||||
.waterColor(0x000077)
|
||||
.waterFogColor(0x0000FF)
|
||||
.skyColor(0x0000AA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.LIGHT_BLUE_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerEndLandBiome(theBlue);
|
||||
|
||||
BCLBiome theGray = BCLBiomeBuilder
|
||||
.start(makeID("the_gray"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFFFF)
|
||||
.waterColor(0x777777)
|
||||
.waterFogColor(0xFFFFFF)
|
||||
.skyColor(0xAAAAAA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.GRAY_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerEndVoidBiome(theGray);
|
||||
|
||||
BCLBiome theOrange = BCLBiomeBuilder
|
||||
.start(makeID("the_orange"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFF7700)
|
||||
.waterColor(0x773300)
|
||||
.waterFogColor(0xFF7700)
|
||||
.skyColor(0xAA7700)
|
||||
.addNetherClimateParamater(-1, 1.1f)
|
||||
.surface(Blocks.ORANGE_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerNetherBiome(theOrange);
|
||||
|
||||
BCLBiome thePurple = BCLBiomeBuilder
|
||||
.start(makeID("the_purple"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFF00FF)
|
||||
.waterColor(0x770077)
|
||||
.waterFogColor(0xFF00FF)
|
||||
.skyColor(0xAA00AA)
|
||||
.addNetherClimateParamater(-1.1f, 1)
|
||||
.surface(Blocks.PURPLE_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerNetherBiome(thePurple);
|
||||
}
|
||||
}
|
||||
|
||||
private void onDatagen() {
|
||||
registerTestBiomes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
WorldsTogether.onInitialize();
|
||||
|
@ -74,12 +157,20 @@ public class BCLib implements ModInitializer {
|
|||
|
||||
WorldsTogether.FORCE_SERVER_TO_BETTERX_PRESET = Configs.SERVER_CONFIG.forceBetterXPreset();
|
||||
VersionChecker.registerMod(MOD_ID);
|
||||
|
||||
if (isDatagen()) {
|
||||
onDatagen();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDevEnvironment() {
|
||||
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||
}
|
||||
|
||||
public static boolean isDatagen() {
|
||||
return System.getProperty("fabric-api.datagen") != null;
|
||||
}
|
||||
|
||||
public static boolean isClient() {
|
||||
return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.betterx.bclib;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.*;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeData;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.surfaceRules.AssignedSurfaceRule;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
|
@ -17,8 +18,6 @@ import net.minecraft.data.PackOutput;
|
|||
import net.minecraft.resources.RegistryDataLoader;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
|
@ -38,87 +37,9 @@ public class BCLibDatagen implements DataGeneratorEntrypoint {
|
|||
|
||||
@Override
|
||||
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
|
||||
registerTestBiomes();
|
||||
|
||||
final FabricDataGenerator.Pack pack = dataGenerator.create();
|
||||
pack.addProvider(CustomRegistriesDataProvider::new);
|
||||
final FabricDataGenerator.Pack pack = dataGenerator.createPack();
|
||||
pack.addProvider(FabricBuiltinRegistriesProvider.forCurrentMod());
|
||||
|
||||
}
|
||||
|
||||
private void registerTestBiomes() {
|
||||
|
||||
if (true && BCLib.isDevEnvironment()) {
|
||||
BCLBiome theYellow = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_yellow"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFF00)
|
||||
.waterColor(0x777700)
|
||||
.waterFogColor(0xFFFF00)
|
||||
.skyColor(0xAAAA00)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.YELLOW_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerEndLandBiome(theYellow);
|
||||
|
||||
BCLBiome theBlue = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_blue"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0x0000FF)
|
||||
.waterColor(0x000077)
|
||||
.waterFogColor(0x0000FF)
|
||||
.skyColor(0x0000AA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.LIGHT_BLUE_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerEndLandBiome(theBlue);
|
||||
|
||||
BCLBiome theGray = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_gray"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFFFF)
|
||||
.waterColor(0x777777)
|
||||
.waterFogColor(0xFFFFFF)
|
||||
.skyColor(0xAAAAAA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.GRAY_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerEndVoidBiome(theGray);
|
||||
|
||||
BCLBiome theOrange = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_orange"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFF7700)
|
||||
.waterColor(0x773300)
|
||||
.waterFogColor(0xFF7700)
|
||||
.skyColor(0xAA7700)
|
||||
.addNetherClimateParamater(-1, 1.1f)
|
||||
.surface(Blocks.ORANGE_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerNetherBiome(theOrange);
|
||||
|
||||
BCLBiome thePurple = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_purple"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFF00FF)
|
||||
.waterColor(0x770077)
|
||||
.waterFogColor(0xFF00FF)
|
||||
.skyColor(0xAA00AA)
|
||||
.addNetherClimateParamater(-1.1f, 1)
|
||||
.surface(Blocks.PURPLE_CONCRETE)
|
||||
.build();
|
||||
BiomeAPI.registerNetherBiome(thePurple);
|
||||
}
|
||||
pack.addProvider(CustomRegistriesDataProvider::new);
|
||||
}
|
||||
|
||||
public static class CustomRegistriesDataProvider implements DataProvider {
|
||||
|
|
|
@ -206,7 +206,14 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
if (parameterPoints.isPresent()) this.parameterPoints.addAll(parameterPoints.get());
|
||||
this.setIntendedType(intendedType.map(t -> BiomeAPI.BiomeType.create(t)).orElse(BiomeAPI.BiomeType.NONE));
|
||||
|
||||
//make sure we are registered properly
|
||||
if (this.biomeParent != null)
|
||||
this.biomeParent.addSubBiome(this);
|
||||
|
||||
//make sure edges are set up correct
|
||||
if (this.edge != null) {
|
||||
this.setEdge(this.edge);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -135,7 +135,7 @@ public class BCLBiomeRegistry {
|
|||
}
|
||||
|
||||
public static BCLBiome getOrElseEmpty(@Nullable RegistryAccess access, ResourceLocation loc) {
|
||||
BCLBiome res = get(access, loc);
|
||||
BCLBiome res = access == null ? null : get(access, loc);
|
||||
if (res == null) return EMPTY_BIOME;
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -276,18 +276,23 @@ public class InternalBiomeAPI {
|
|||
static {
|
||||
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
|
||||
Optional<? extends Registry<Biome>> oBiomeRegistry = registryManager.registry(Registry.BIOME_REGISTRY);
|
||||
RegistryEntryAddedCallback
|
||||
.event(oBiomeRegistry.get())
|
||||
.register((rawId, id, biome) -> {
|
||||
BCLBiome b = BiomeAPI.getBiome(id);
|
||||
if (!"minecraft".equals(id.getNamespace()) && (b == null || b == BCLBiomeRegistry.EMPTY_BIOME)) {
|
||||
//BCLib.LOGGER.info(" #### " + rawId + ", " + biome + ", " + id);
|
||||
//BIOMES_TO_SORT.add(id);
|
||||
if (oBiomeRegistry.isPresent()) {
|
||||
RegistryEntryAddedCallback
|
||||
.event(oBiomeRegistry.get())
|
||||
.register((rawId, id, biome) -> {
|
||||
BCLBiome b = BiomeAPI.getBiome(id);
|
||||
if (!"minecraft".equals(id.getNamespace()) && (b == null || b == BCLBiomeRegistry.EMPTY_BIOME)) {
|
||||
//BCLib.LOGGER.info(" #### " + rawId + ", " + biome + ", " + id);
|
||||
//BIOMES_TO_SORT.add(id);
|
||||
// BIOME_ADDITIONS.computeIfAbsent(oBiomeRegistry.get(), reg -> new AtomicInteger(0))
|
||||
// .incrementAndGet();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
BCLib.LOGGER.warning("No valid Biome Registry available!");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,5 +84,7 @@ public class Conditions {
|
|||
register(BCLib.makeID("threshold_condition"), ThresholdCondition.CODEC);
|
||||
register(BCLib.makeID("volume_threshold_condition"), VolumeThresholdCondition.CODEC);
|
||||
register(BCLib.makeID("rough_noise_condition"), RoughNoiseCondition.CODEC);
|
||||
|
||||
Registry.register(Registry.RULE, "bclib_switch_rule", SwitchRuleSource.CODEC);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.betterx.bclib.mixin.common.SurfaceRulesContextAccessor;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules.Context;
|
||||
|
@ -49,6 +48,6 @@ public record SwitchRuleSource(NumericProvider selector, List<RuleSource> collec
|
|||
}
|
||||
|
||||
static {
|
||||
Registry.register(Registry.RULE, "bclib_switch_rule", SwitchRuleSource.CODEC);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue