Skip to content

Commit

Permalink
still tryna fix ore gen
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasPlacentino committed Dec 30, 2022
1 parent bce4410 commit 555ecb7
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/obsilab/mcsc/MCSC.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
/*
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<ConfiguredFeature<?, ?>> BORAX_ORE =
CONFIGURED_FEATURES.register("borax_ore",
() -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(OVERWORLD_BORAX_ORES.get(),
10 // vein size
)));
*/


public static final ResourceKey<ConfiguredFeature<?, ?>> ORE_BORAX = FeatureUtils.createKey("ore_borax");

public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
RuleTest ruletest1 = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES);
List<OreConfiguration.TargetBlockState> 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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PlacedFeature> PLACED_FEATURES =
DeferredRegister.create(Registries.PLACED_FEATURE, MCSC.MOD_ID);

public static final RegistryObject<PlacedFeature> 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<PlacementModifier> orePlacement(PlacementModifier placementModifier, PlacementModifier placementModifier1) {
return List.of(placementModifier, InSquarePlacement.spread(), placementModifier1, BiomeFilter.biome());
}

public static List<PlacementModifier> commonOrePlacement(int i, PlacementModifier placementModifier) {
return orePlacement(CountPlacement.of(i), placementModifier);
}

public static List<PlacementModifier> rareOrePlacement(int i, PlacementModifier placementModifier) {
return orePlacement(RarityFilter.onAverageOnceEvery(i), placementModifier);
}

public static void register(IEventBus eventBus) {
PLACED_FEATURES.register(eventBus);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "forge:add_features",
"biomes": "#minecraft:is_overworld",
"features": "mcsc:borax_ore_placed",
"step": "underground_ores"
}

0 comments on commit 555ecb7

Please # to comment.