Use new biome api

This commit is contained in:
SD 2020-11-30 11:51:26 +05:30
parent f0858f69cd
commit 7577ae98b8
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5
10 changed files with 133 additions and 56 deletions

View file

@ -32,13 +32,19 @@ dependencies {
modImplementation("io.github.boogiemonster1o1:libcbe:${libcbe_version}")
include("io.github.boogiemonster1o1:libcbe:${libcbe_version}") // Includes LibCBE as a Jar-in-Jar embedded dependency
modImplementation("curse.maven:worldedit:3039223") // For saving schematics
modImplementation("curse.maven:wecui:2995033") // Cos why not
// modImplementation("curse.maven:wecui:2995033") // Cos why not
modCompileOnly("io.github.prospector:modmenu:1.14.6+build.31") {
exclude module: "fabric-api"
}
modRuntime("io.github.prospector:modmenu:1.14.6+build.31") {
exclude module: "fabric-api"
}
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
}
test {
useJUnitPlatform()
}
version "4.0.0+alpha.4"

View file

@ -9,7 +9,7 @@ public class LimboSkyProperties extends SkyProperties {
}
@Override
public Vec3d adjustSkyColor(Vec3d color, float sunHeight) {
public Vec3d adjustFogColor(Vec3d color, float sunHeight) {
return color;
}

View file

@ -14,6 +14,6 @@ import net.minecraft.world.gen.feature.DefaultBiomeFeatures;
public class DefaultBiomeFeaturesMixin {
@Inject(method = "addDesertLakes", at = @At("RETURN"))
private static void addGateway(GenerationSettings.Builder builder, CallbackInfo ci) {
builder.feature(GenerationStep.Feature.TOP_LAYER_MODIFICATION, ModFeatures.SANDSTONE_PILLARS_FEATURE);
// builder.feature(GenerationStep.Feature.TOP_LAYER_MODIFICATION, ModFeatures.SANDSTONE_PILLARS_FEATURE);
}
}

View file

@ -79,8 +79,6 @@ public final class ModBiomes {
.grassColor(0)
.build())
.generationSettings(new GenerationSettings.Builder()
.feature(GenerationStep.Feature.SURFACE_STRUCTURES, ModFeatures.LIMBO_GATEWAY_CONFIGURED_FEATURE)
.feature(GenerationStep.Feature.LAKES, ModFeatures.ETERNAL_FLUID_LAKE)
.surfaceBuilder(SurfaceBuilder.NETHER.withConfig(new TernarySurfaceConfig(ModBlocks.UNRAVELLED_FABRIC.getDefaultState(), ModBlocks.UNRAVELLED_FABRIC.getDefaultState(), ModBlocks.ETERNAL_FLUID.getDefaultState())))
.build())
.precipitation(Biome.Precipitation.NONE)

View file

@ -1,12 +1,6 @@
package org.dimdev.dimdoors.world.feature;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.mixin.GenerationSettingsAccessor;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.feature.gateway.LimboGatewayFeature;
import org.dimdev.dimdoors.world.feature.gateway.schematic.SandstonePillarsV2Gateway;
import org.dimdev.dimdoors.world.feature.gateway.schematic.SchematicV2Gateway;
@ -15,60 +9,38 @@ import org.dimdev.dimdoors.world.feature.gateway.schematic.SchematicV2GatewayFea
import org.dimdev.dimdoors.world.feature.gateway.schematic.TwoPillarsV2Gateway;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.Decorator;
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.ConfiguredFeatures;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.SingleStateFeatureConfig;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
@SuppressWarnings("deprecation")
public final class ModFeatures {
public static final Feature<SchematicV2GatewayFeatureConfig> SCHEMATIC_GATEWAY_FEATURE = Registry.register(Registry.FEATURE, new Identifier("dimdoors", "schematic_gateway"), new SchematicV2GatewayFeature(SchematicV2GatewayFeatureConfig.CODEC));
public static final Feature<DefaultFeatureConfig> LIMBO_GATEWAY_FEATURE = Registry.register(Registry.FEATURE, new Identifier("dimdoors", "limbo_gateway"), new LimboGatewayFeature());
public static final SchematicV2Gateway SANDSTONE_PILLARS_GATEWAY = new SandstonePillarsV2Gateway();
public static final SchematicV2Gateway TWO_PILLARS_GATEWAY = new TwoPillarsV2Gateway();
public static final ConfiguredFeature<?, ?> SANDSTONE_PILLARS_FEATURE;
public static final ConfiguredFeature<?, ?> TWO_PILLARS_FEATURE;
public static final ConfiguredFeature<?, ?> LIMBO_GATEWAY_CONFIGURED_FEATURE;
public static ConfiguredFeature<?, ?> ETERNAL_FLUID_LAKE;
public static final RegistryKey<ConfiguredFeature<?, ?>> SANDSTONE_PILLARS = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("dimdoors", "sandstone_pillars"));
public static final RegistryKey<ConfiguredFeature<?, ?>> TWO_PILLARS = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("dimdoors", "two_pillars"));
public static final RegistryKey<ConfiguredFeature<?, ?>> LIMBO_GATEWAY = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("dimdoors", "limbo_gateway"));
public static void init() {
SANDSTONE_PILLARS_GATEWAY.init();
TWO_PILLARS_GATEWAY.init();
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("dimdoors", "sandstone_pillars"), SANDSTONE_PILLARS_FEATURE);
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("dimdoors", "limbo_gateway"), LIMBO_GATEWAY_CONFIGURED_FEATURE);
ETERNAL_FLUID_LAKE = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("dimdoors", "eternal_fluid_lake"), Feature.LAKE.configure(new SingleStateFeatureConfig(ModBlocks.ETERNAL_FLUID.getDefaultState())).decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(5, 70, 128)).applyChance(20)));
synchronized (BuiltinRegistries.BIOME) {
BuiltinRegistries.BIOME.stream()
.filter(biome ->
biome.getCategory() != Biome.Category.NONE &&
biome.getCategory() != Biome.Category.THEEND &&
biome.getCategory() != Biome.Category.NETHER &&
biome.getCategory() != Biome.Category.OCEAN &&
biome.getCategory() != Biome.Category.MUSHROOM
)
.forEach(biome -> {
int index = GenerationStep.Feature.SURFACE_STRUCTURES.ordinal();
List<List<Supplier<ConfiguredFeature<?, ?>>>> features = new ArrayList<>(biome.getGenerationSettings().getFeatures());
List<Supplier<ConfiguredFeature<?, ?>>> surfaceStructures = new ArrayList<>(features.get(index));
surfaceStructures.add(() -> TWO_PILLARS_FEATURE);
features.set(index, surfaceStructures);
((GenerationSettingsAccessor) biome.getGenerationSettings()).setFeatures(features);
});
}
}
static {
int gatewayChance = FabricLoader.getInstance().isDevelopmentEnvironment() ? 20 : ModConfig.INSTANCE.getWorldConfig().gatewayGenChance;
SANDSTONE_PILLARS_FEATURE = SCHEMATIC_GATEWAY_FEATURE.configure(new SchematicV2GatewayFeatureConfig(SchematicV2Gateway.ID_SCHEMATIC_MAP.inverse().get(SANDSTONE_PILLARS_GATEWAY))).decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP.applyChance(gatewayChance));
TWO_PILLARS_FEATURE = SCHEMATIC_GATEWAY_FEATURE.configure(new SchematicV2GatewayFeatureConfig(SchematicV2Gateway.ID_SCHEMATIC_MAP.inverse().get(TWO_PILLARS_GATEWAY))).decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP.applyChance(gatewayChance));
LIMBO_GATEWAY_CONFIGURED_FEATURE = LIMBO_GATEWAY_FEATURE.configure(DefaultFeatureConfig.INSTANCE).decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP.applyChance(gatewayChance));
BiomeModifications.addFeature(ctx -> {
Biome biome = ctx.getBiome();
return biome.getCategory() != Biome.Category.NONE &&
biome.getCategory() != Biome.Category.THEEND &&
biome.getCategory() != Biome.Category.NETHER &&
biome.getCategory() != Biome.Category.OCEAN &&
biome.getCategory() != Biome.Category.MUSHROOM;
}, GenerationStep.Feature.SURFACE_STRUCTURES, TWO_PILLARS);
BiomeModifications.addFeature(ctx -> ctx.getBiome().getCategory() == Biome.Category.DESERT, GenerationStep.Feature.SURFACE_STRUCTURES, SANDSTONE_PILLARS);
BiomeModifications.addFeature(ctx -> ctx.getBiomeKey().getValue().equals(ModBiomes.LIMBO_KEY.getValue()), GenerationStep.Feature.SURFACE_STRUCTURES, LIMBO_GATEWAY);
}
}

View file

@ -32,7 +32,7 @@ public abstract class SchematicV2Gateway implements Gateway {
try (InputStream stream = DimensionalDoorsInitializer.class.getResourceAsStream(schematicJarDirectory + this.id + ".schem")) {
if (stream == null) {
throw new RuntimeException("Schematic '" + this.id + "' was not found in the jar or config directory, neither with the .schem extension, nor with the .schematic extension.");
throw new RuntimeException("Schematic '" + this.id + "' was not found in the jar");
}
try {
this.schematic = Schematic.fromTag(NbtIo.readCompressed(stream));

View file

@ -6,11 +6,9 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.world.gen.feature.FeatureConfig;
public class SchematicV2GatewayFeatureConfig implements FeatureConfig {
public static final Codec<SchematicV2GatewayFeatureConfig> CODEC = RecordCodecBuilder.create((instance) -> {
return instance.group(
Codec.STRING.fieldOf("gatewayId").forGetter(SchematicV2GatewayFeatureConfig::getGatewayId)
).apply(instance, SchematicV2GatewayFeatureConfig::new);
});
public static final Codec<SchematicV2GatewayFeatureConfig> CODEC = RecordCodecBuilder.create((instance) -> instance.group(
Codec.STRING.fieldOf("gatewayId").forGetter(SchematicV2GatewayFeatureConfig::getGatewayId)
).apply(instance, SchematicV2GatewayFeatureConfig::new));
private final SchematicV2Gateway gateway;
private final String gatewayId;

View file

@ -0,0 +1,33 @@
{
"config": {
"feature": {
"config": {},
"type": "dimdoors:limbo_gateway"
},
"decorator": {
"config": {
"outer": {
"config": {
"chance": 20
},
"type": "minecraft:chance"
},
"inner": {
"config": {
"outer": {
"config": {},
"type": "minecraft:square"
},
"inner": {
"config": {},
"type": "minecraft:top_solid_heightmap"
}
},
"type": "minecraft:decorated"
}
},
"type": "minecraft:decorated"
}
},
"type": "minecraft:decorated"
}

View file

@ -0,0 +1,35 @@
{
"config": {
"feature": {
"config": {
"gatewayId": "sandstone_pillars"
},
"type": "dimdoors:schematic_gateway"
},
"decorator": {
"config": {
"outer": {
"config": {
"chance": 20
},
"type": "minecraft:chance"
},
"inner": {
"config": {
"outer": {
"config": {},
"type": "minecraft:square"
},
"inner": {
"config": {},
"type": "minecraft:top_solid_heightmap"
}
},
"type": "minecraft:decorated"
}
},
"type": "minecraft:decorated"
}
},
"type": "minecraft:decorated"
}

View file

@ -0,0 +1,35 @@
{
"config": {
"feature": {
"config": {
"gatewayId": "two_pillars"
},
"type": "dimdoors:schematic_gateway"
},
"decorator": {
"config": {
"outer": {
"config": {
"chance": 20
},
"type": "minecraft:chance"
},
"inner": {
"config": {
"outer": {
"config": {},
"type": "minecraft:square"
},
"inner": {
"config": {},
"type": "minecraft:top_solid_heightmap"
}
},
"type": "minecraft:decorated"
}
},
"type": "minecraft:decorated"
}
},
"type": "minecraft:decorated"
}