Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Commit

Permalink
Fix for campsite generation
Browse files Browse the repository at this point in the history
  • Loading branch information
florensie committed Feb 21, 2022
1 parent 1c5ca4f commit fb305ec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/main/java/artifacts/common/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ private WorldGen() {
public static final class Campsite {
@ConfigEntry.Gui.RequiresRestart
@ConfigEntry.Gui.Tooltip(count = 2)
@ConfigEntry.BoundedDiscrete(max = 100)
public int genChance = 8;
@ConfigEntry.BoundedDiscrete(max = 10_000, min = 1)
public int campsiteRarity = 5;

@ConfigEntry.Gui.Tooltip(count = 2)
@ConfigEntry.BoundedDiscrete(max = 100)
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/artifacts/common/init/ModFeatures.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import java.util.function.Predicate;

import static artifacts.Artifacts.CONFIG;

public class ModFeatures {

public static final Feature<NoneFeatureConfiguration> CAMPSITE = Registry.register(
Expand All @@ -37,9 +39,13 @@ public class ModFeatures {

public static void register() {
Predicate<BiomeSelectionContext> biomeSelector = BiomeSelectors.foundInOverworld();
BiomeModifications.addFeature(biomeSelector, GenerationStep.Decoration.UNDERGROUND_STRUCTURES,
BuiltinRegistries.PLACED_FEATURE.getResourceKey(PLACED_CAMPSITE)
.orElseThrow(() -> new RuntimeException("Failed to get feature from registry")));


if (CONFIG.worldgen.campsite.campsiteRarity < 10_000) {
BiomeModifications.addFeature(biomeSelector, GenerationStep.Decoration.UNDERGROUND_STRUCTURES,
BuiltinRegistries.PLACED_FEATURE.getResourceKey(PLACED_CAMPSITE)
.orElseThrow(() -> new RuntimeException("Failed to get feature from registry")));
}
}

private ModFeatures() {
Expand All @@ -56,8 +62,7 @@ private ModFeatures() {
BuiltinRegistries.PLACED_FEATURE,
Artifacts.id("underground_campsite"),
configuredFeature.placed(
// TODO: genchance is different, we probably got it all wrong
RarityFilter.onAverageOnceEvery(Artifacts.CONFIG.worldgen.campsite.genChance),
RarityFilter.onAverageOnceEvery(CONFIG.worldgen.campsite.campsiteRarity),
InSquarePlacement.spread(),
HeightRangePlacement.uniform(
VerticalAnchor.aboveBottom(32),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/artifacts.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "artifacts.mixin.mixins",
"compatibilityLevel": "JAVA_16",
"compatibilityLevel": "JAVA_17",
"plugin": "artifacts.mixin.ArtifactsMixinPlugin",
"mixins": [
"accessors.DamageSourceAccessor",
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/assets/artifacts/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@
"text.autoconfig.artifacts.option.worldgen.artifactRarity.@Tooltip[4]": "Setting this to 10000 will completely prevent artifacts from spawning",
"text.autoconfig.artifacts.option.worldgen.artifactRarity.@Tooltip[5]": "When set to 0, every container that can contain artifacts will contain an artifact",
"text.autoconfig.artifacts.option.worldgen.campsite": "Underground Campsites",
"text.autoconfig.artifacts.option.worldgen.campsite.genChance": "Generation frequency (per chunk)",
"text.autoconfig.artifacts.option.worldgen.campsite.genChance.@Tooltip[0]": "An attempt to generate a campsite might still fail",
"text.autoconfig.artifacts.option.worldgen.campsite.genChance.@Tooltip[1]": "depending on the density and shape of caves",
"text.autoconfig.artifacts.option.worldgen.campsite.campsiteRarity": "Campsite rarity",
"text.autoconfig.artifacts.option.worldgen.campsite.campsiteRarity.@Tooltip[0]": "A higher number means less frequent generation",
"text.autoconfig.artifacts.option.worldgen.campsite.campsiteRarity.@Tooltip[1]": "Also depends on the density and shape of caves",
"text.autoconfig.artifacts.option.worldgen.campsite.mimicChance": "Mimic chance",
"text.autoconfig.artifacts.option.worldgen.campsite.mimicChance.@Tooltip[0]": "Probability for a mimic to spawn",
"text.autoconfig.artifacts.option.worldgen.campsite.mimicChance.@Tooltip[1]": "instead of a loot container",
Expand Down

0 comments on commit fb305ec

Please sign in to comment.