mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Generate Black Quartz
This commit is contained in:
parent
899b2a982b
commit
02422d6547
11 changed files with 230 additions and 2 deletions
|
@ -1,2 +1,5 @@
|
|||
// 1.20.4 2024-03-04T22:51:31.6164303 Registries
|
||||
// 1.20.4 2024-03-05T16:53:18.8159163 Registries
|
||||
020d2b1f1c21d6c6663ef8126a52e2b9deb0e52e data/actuallyadditions/damage_type/atomicreconstructor.json
|
||||
4ba41428fdcf03f52855029153722e22e8702823 data/actuallyadditions/neoforge/biome_modifier/add_black_quartz.json
|
||||
3c9f4fbfed04f0e75ea7b370aa2f8acc531a63bb data/actuallyadditions/worldgen/configured_feature/ore_black_quartz.json
|
||||
4eace98485badda3da34f4fc2069e7d222c1abd4 data/actuallyadditions/worldgen/placed_feature/ore_black_quartz.json
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "actuallyadditions:bool_config_feature_modifier",
|
||||
"biomes": "#minecraft:is_overworld",
|
||||
"boolConfig": "generateQuartz",
|
||||
"features": "actuallyadditions:ore_black_quartz",
|
||||
"step": "underground_ores"
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"type": "minecraft:ore",
|
||||
"config": {
|
||||
"discard_chance_on_air_exposure": 0.0,
|
||||
"size": 6,
|
||||
"targets": [
|
||||
{
|
||||
"state": {
|
||||
"Name": "actuallyadditions:black_quartz_ore"
|
||||
},
|
||||
"target": {
|
||||
"predicate_type": "minecraft:tag_match",
|
||||
"tag": "minecraft:stone_ore_replaceables"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"feature": "actuallyadditions:ore_black_quartz",
|
||||
"placement": [
|
||||
{
|
||||
"type": "minecraft:count",
|
||||
"count": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:in_square"
|
||||
},
|
||||
{
|
||||
"type": "minecraft:height_range",
|
||||
"height": {
|
||||
"type": "minecraft:trapezoid",
|
||||
"max_inclusive": {
|
||||
"absolute": 45
|
||||
},
|
||||
"min_inclusive": {
|
||||
"absolute": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "minecraft:biome"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package de.ellpeck.actuallyadditions.data;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.ActuallyBiomeModifiers;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.ActuallyConfiguredFeatures;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.ActuallyPlacedFeatures;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.ActuallyDamageTypes;
|
||||
import net.minecraft.core.Cloner;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
|
@ -17,6 +20,7 @@ import net.neoforged.fml.common.Mod;
|
|||
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
|
||||
import net.neoforged.neoforge.common.data.ExistingFileHelper;
|
||||
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -65,6 +69,9 @@ public class ActuallyAdditionsData {
|
|||
registryBuilder.add(Registries.DAMAGE_TYPE, (context) -> {
|
||||
context.register(ActuallyDamageTypes.ATOMIC_RECONSTRUCTOR, new DamageType("actuallyadditions.atomic_reconstructor", 0.0F));
|
||||
});
|
||||
registryBuilder.add(Registries.CONFIGURED_FEATURE, ActuallyConfiguredFeatures::bootstrap);
|
||||
registryBuilder.add(Registries.PLACED_FEATURE, ActuallyPlacedFeatures::bootstrap);
|
||||
registryBuilder.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, ActuallyBiomeModifiers::bootstrap);
|
||||
// We need the BIOME registry to be present, so we can use a biome tag, doesn't matter that it's empty
|
||||
registryBuilder.add(Registries.BIOME, $ -> {
|
||||
});
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyTags;
|
||||
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
||||
|
@ -25,12 +26,12 @@ import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
|
|||
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
|
||||
import de.ellpeck.actuallyadditions.mod.event.CommonEvents;
|
||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.modifier.BoolConfigFeatureBiomeModifier;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
||||
import de.ellpeck.actuallyadditions.mod.items.Worm;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.BannerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.MethodHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
|
@ -43,6 +44,9 @@ import net.minecraft.world.entity.EntityType;
|
|||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
|
@ -54,6 +58,7 @@ import net.neoforged.fml.loading.FMLEnvironment;
|
|||
import net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.common.conditions.ICondition;
|
||||
import net.neoforged.neoforge.common.world.BiomeModifier;
|
||||
import net.neoforged.neoforge.event.AddReloadListenerEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppedEvent;
|
||||
|
@ -86,6 +91,15 @@ public class ActuallyAdditions {
|
|||
private static final DeferredRegister<Codec<? extends ICondition>> CONDITION_CODECS = DeferredRegister.create(NeoForgeRegistries.Keys.CONDITION_CODECS, MODID);
|
||||
public static final DeferredHolder<Codec<? extends ICondition>, Codec<BoolConfigCondition>> BOOL_CONFIG_CONDITION = CONDITION_CODECS.register("bool_config_condition", () -> BoolConfigCondition.CODEC);
|
||||
|
||||
public static final DeferredRegister<Codec<? extends BiomeModifier>> BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(NeoForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, MODID);
|
||||
public static final Supplier<Codec<BoolConfigFeatureBiomeModifier>> BOOL_CONFIG_MODIFIER = BIOME_MODIFIER_SERIALIZERS.register("bool_config_feature_modifier", () ->
|
||||
RecordCodecBuilder.create(builder -> builder.group(
|
||||
Biome.LIST_CODEC.fieldOf("biomes").forGetter(BoolConfigFeatureBiomeModifier::biomes),
|
||||
PlacedFeature.LIST_CODEC.fieldOf("features").forGetter(BoolConfigFeatureBiomeModifier::features),
|
||||
GenerationStep.Decoration.CODEC.fieldOf("step").forGetter(BoolConfigFeatureBiomeModifier::step),
|
||||
Codec.STRING.fieldOf("boolConfig").forGetter(BoolConfigFeatureBiomeModifier::boolConfig)
|
||||
).apply(builder, BoolConfigFeatureBiomeModifier::new))
|
||||
);
|
||||
|
||||
public static boolean commonCapsLoaded;
|
||||
|
||||
|
@ -101,6 +115,7 @@ public class ActuallyAdditions {
|
|||
ActuallyContainers.CONTAINERS.register(eventBus);
|
||||
ENTITIES.register(eventBus);
|
||||
CONDITION_CODECS.register(eventBus);
|
||||
BIOME_MODIFIER_SERIALIZERS.register(eventBus);
|
||||
eventBus.addListener(this::onConfigReload);
|
||||
ActuallyParticles.init(eventBus);
|
||||
ActuallyTags.init();
|
||||
|
|
|
@ -14,6 +14,7 @@ public class CommonConfig {
|
|||
static {
|
||||
Other.build();
|
||||
Machines.build();
|
||||
Worldgen.build();
|
||||
ItemSettings.build();
|
||||
COMMON_CONFIG = BUILDER.build();
|
||||
}
|
||||
|
@ -54,6 +55,18 @@ public class CommonConfig {
|
|||
}
|
||||
}
|
||||
|
||||
public static class Worldgen {
|
||||
public static ModConfigSpec.BooleanValue GENERATE_QUARTZ;
|
||||
|
||||
public static void build() {
|
||||
BUILDER.comment("Worldgen Settings").push("worldgenSettings");
|
||||
|
||||
GENERATE_QUARTZ = BUILDER.comment("Should Black Quartz generate in the world?").define("laserRelayLoss", true);
|
||||
|
||||
BUILDER.pop();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Other {
|
||||
public static ModConfigSpec.BooleanValue SOLID_XP_ALWAYS_ORBS;
|
||||
public static ModConfigSpec.BooleanValue DO_UPDATE_CHECK;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.modifier.BoolConfigFeatureBiomeModifier;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.neoforged.neoforge.common.world.BiomeModifier;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
|
||||
public class ActuallyBiomeModifiers {
|
||||
protected static final ResourceKey<BiomeModifier> ADD_BLACK_QUARTZ_ORE_MODIFIER = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS,
|
||||
new ResourceLocation(ActuallyAdditions.MODID, "add_black_quartz"));
|
||||
|
||||
public static void bootstrap(BootstapContext<BiomeModifier> context) {
|
||||
HolderGetter<Biome> biomeGetter = context.lookup(Registries.BIOME);
|
||||
HolderGetter<PlacedFeature> placedGetter = context.lookup(Registries.PLACED_FEATURE);
|
||||
|
||||
HolderSet.Named<Biome> overworldHolder = biomeGetter.getOrThrow(BiomeTags.IS_OVERWORLD);
|
||||
|
||||
context.register(ADD_BLACK_QUARTZ_ORE_MODIFIER, new BoolConfigFeatureBiomeModifier(
|
||||
overworldHolder,
|
||||
HolderSet.direct(placedGetter.getOrThrow(ActuallyPlacedFeatures.PLACED_ORE_BLACK_QUARTZ)),
|
||||
GenerationStep.Decoration.UNDERGROUND_ORES, "generateQuartz"
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.data.worldgen.features.FeatureUtils;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ActuallyConfiguredFeatures {
|
||||
public static final ResourceKey<ConfiguredFeature<?, ?>> ORE_BLACK_QUARTZ = FeatureUtils.createKey("actuallyadditions:ore_black_quartz");
|
||||
// public static final ResourceKey<ConfiguredFeature<?, ?>> ORE_BLACK_QUARTZ_BURIED = FeatureUtils.createKey("actuallyadditions:ore_black_quartz_buried");
|
||||
|
||||
public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
|
||||
RuleTest stoneRuleTest = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES);
|
||||
List<OreConfiguration.TargetBlockState> list = List.of(
|
||||
OreConfiguration.target(stoneRuleTest, ActuallyBlocks.BLACK_QUARTZ_ORE.get().defaultBlockState())
|
||||
);
|
||||
FeatureUtils.register(context, ORE_BLACK_QUARTZ, Feature.ORE, new OreConfiguration(list, 6));
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.levelgen.VerticalAnchor;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.placement.BiomeFilter;
|
||||
import net.minecraft.world.level.levelgen.placement.CountPlacement;
|
||||
import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
|
||||
import net.minecraft.world.level.levelgen.placement.InSquarePlacement;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ActuallyPlacedFeatures {
|
||||
public static final ResourceKey<PlacedFeature> PLACED_ORE_BLACK_QUARTZ = PlacementUtils.createKey("actuallyadditions:ore_black_quartz");
|
||||
// public static final ResourceKey<PlacedFeature> PLACED_ORE_BLACK_QUARTZ_BURIED = PlacementUtils.createKey("actuallyadditions:ore_black_quartz_buried");
|
||||
|
||||
public static void bootstrap(BootstapContext<PlacedFeature> context) {
|
||||
HolderGetter<ConfiguredFeature<?, ?>> holdergetter = context.lookup(Registries.CONFIGURED_FEATURE);
|
||||
|
||||
PlacementUtils.register(context, PLACED_ORE_BLACK_QUARTZ, holdergetter.getOrThrow(ActuallyConfiguredFeatures.ORE_BLACK_QUARTZ),
|
||||
commonOrePlacement(10, HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(45))));
|
||||
}
|
||||
|
||||
private static List<PlacementModifier> orePlacement(PlacementModifier modifier, PlacementModifier modifier1) {
|
||||
return List.of(modifier, InSquarePlacement.spread(), modifier1, BiomeFilter.biome());
|
||||
}
|
||||
|
||||
private static List<PlacementModifier> commonOrePlacement(int count, PlacementModifier modifier) {
|
||||
return orePlacement(CountPlacement.of(count), modifier);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package de.ellpeck.actuallyadditions.mod.gen.modifier;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.neoforged.neoforge.common.world.BiomeGenerationSettingsBuilder;
|
||||
import net.neoforged.neoforge.common.world.BiomeModifier;
|
||||
import net.neoforged.neoforge.common.world.ModifiableBiomeInfo;
|
||||
|
||||
public record BoolConfigFeatureBiomeModifier(HolderSet<Biome> biomes, HolderSet<PlacedFeature> features, GenerationStep.Decoration step,
|
||||
String boolConfig) implements BiomeModifier {
|
||||
|
||||
@Override
|
||||
public void modify(Holder<Biome> biome, Phase phase, ModifiableBiomeInfo.BiomeInfo.Builder builder) {
|
||||
if (phase == Phase.ADD && checkConfig() && this.biomes.contains(biome)) {
|
||||
BiomeGenerationSettingsBuilder generationSettings = builder.getGenerationSettings();
|
||||
this.features.forEach(holder -> generationSettings.addFeature(this.step, holder));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkConfig() {
|
||||
switch (boolConfig) {
|
||||
default:
|
||||
return true;
|
||||
case "generateQuartz":
|
||||
return CommonConfig.Worldgen.GENERATE_QUARTZ.get();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<? extends BiomeModifier> codec() {
|
||||
return ActuallyAdditions.BOOL_CONFIG_MODIFIER.get();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue