diff --git a/src/main/java/com/obsilab/mcsc/MCSC.java b/src/main/java/com/obsilab/mcsc/MCSC.java index 6e66013..fee0895 100644 --- a/src/main/java/com/obsilab/mcsc/MCSC.java +++ b/src/main/java/com/obsilab/mcsc/MCSC.java @@ -5,6 +5,7 @@ import com.obsilab.mcsc.block.custom.CrystalIngotBlock; import com.obsilab.mcsc.item.ModItems; import com.obsilab.mcsc.world.feature.ModConfiguredFeatures; +import com.obsilab.mcsc.world.feature.ModPlacedFeatures; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; @@ -44,6 +45,7 @@ public class MCSC { // Define mod id in a common place for everything to reference public static final String MOD_ID = "mcsc"; + public static final String MCSC = MOD_ID; // 🤷‍♂️ // Directly reference a slf4j logger private static final Logger LOGGER = LogUtils.getLogger(); /* @@ -85,6 +87,7 @@ public MCSC() ModBlocks.register(modEventBus); ModConfiguredFeatures.register(modEventBus); + ModPlacedFeatures.register(modEventBus); // Register the commonSetup method for modloading modEventBus.addListener(this::commonSetup); diff --git a/src/main/java/com/obsilab/mcsc/world/feature/ModConfiguredFeatures.java b/src/main/java/com/obsilab/mcsc/world/feature/ModConfiguredFeatures.java index 10ee42f..e1d1471 100644 --- a/src/main/java/com/obsilab/mcsc/world/feature/ModConfiguredFeatures.java +++ b/src/main/java/com/obsilab/mcsc/world/feature/ModConfiguredFeatures.java @@ -5,12 +5,20 @@ import com.obsilab.mcsc.MCSC; import com.obsilab.mcsc.block.ModBlocks; import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.features.FeatureUtils; import net.minecraft.data.worldgen.features.OreFeatures; +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 net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.RegistryObject; +import net.minecraft.data.worldgen.BootstapContext; import java.util.List; @@ -31,8 +39,24 @@ public class ModConfiguredFeatures { OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, ModBlocks.PHOSPHATE_ORE.get().defaultBlockState())//, //OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.DEEPSLATE_PHOSPHATE_ORE.get().defaultBlockState()) )); + + + public static final RegistryObject> BORAX_ORE = + CONFIGURED_FEATURES.register("borax_ore", + () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(OVERWORLD_BORAX_ORES.get(), + 10 // vein size + ))); */ + + public static final ResourceKey> ORE_BORAX = FeatureUtils.createKey("ore_borax"); + + public static void bootstrap(BootstapContext> context) { + RuleTest ruletest1 = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES); + List list6 = List.of(OreConfiguration.target(ruletest1, ModBlocks.BORAX_ORE.get().defaultBlockState())); + FeatureUtils.register(context, ORE_BORAX, Feature.ORE, new OreConfiguration(list6, 10)); + } + public static void register(IEventBus eventBus) { CONFIGURED_FEATURES.register(eventBus); } diff --git a/src/main/java/com/obsilab/mcsc/world/feature/ModPlacedFeatures.java b/src/main/java/com/obsilab/mcsc/world/feature/ModPlacedFeatures.java new file mode 100644 index 0000000..031280b --- /dev/null +++ b/src/main/java/com/obsilab/mcsc/world/feature/ModPlacedFeatures.java @@ -0,0 +1,42 @@ +package com.obsilab.mcsc.world.feature; + +import com.obsilab.mcsc.MCSC; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.level.levelgen.VerticalAnchor; +import net.minecraft.world.level.levelgen.placement.*; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.RegistryObject; + +import java.util.List; + +public class ModPlacedFeatures { + public static final DeferredRegister PLACED_FEATURES = + DeferredRegister.create(Registries.PLACED_FEATURE, MCSC.MOD_ID); + + public static final RegistryObject BORAX_ORE_PLACED = PLACED_FEATURES.register("borax_ore_placed", + () -> new PlacedFeature(ModConfiguredFeatures.BORAX_ORE.getHolder().get(), + commonOrePlacement(6, // VeinsPerChunk + HeightRangePlacement.triangle( + VerticalAnchor.absolute(0), + VerticalAnchor.absolute(160) + )))); + + + public static List orePlacement(PlacementModifier placementModifier, PlacementModifier placementModifier1) { + return List.of(placementModifier, InSquarePlacement.spread(), placementModifier1, BiomeFilter.biome()); + } + + public static List commonOrePlacement(int i, PlacementModifier placementModifier) { + return orePlacement(CountPlacement.of(i), placementModifier); + } + + public static List rareOrePlacement(int i, PlacementModifier placementModifier) { + return orePlacement(RarityFilter.onAverageOnceEvery(i), placementModifier); + } + + public static void register(IEventBus eventBus) { + PLACED_FEATURES.register(eventBus); + } + +} diff --git a/src/main/resources/data/mcsc/forge/biome_modifier/add_borax_ore.json b/src/main/resources/data/mcsc/forge/biome_modifier/add_borax_ore.json new file mode 100644 index 0000000..c2dbb60 --- /dev/null +++ b/src/main/resources/data/mcsc/forge/biome_modifier/add_borax_ore.json @@ -0,0 +1,6 @@ +{ + "type": "forge:add_features", + "biomes": "#minecraft:is_overworld", + "features": "mcsc:borax_ore_placed", + "step": "underground_ores" +} \ No newline at end of file