Skip to content

Commit

Permalink
tryna fix ore gen once again
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasPlacentino committed Jan 1, 2023
1 parent 8d1bb62 commit 3c57003
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ public class ModConfiguredFeatures {
public static final DeferredRegister<ConfiguredFeature<?, ?>> CONFIGURED_FEATURES =
DeferredRegister.create(Registries.CONFIGURED_FEATURE, MCSC.MOD_ID);

/*

public static final Supplier<List<OreConfiguration.TargetBlockState>> OVERWORLD_BORAX_ORES =
Suppliers.memoize(() -> List.of(
OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, ModBlocks.BORAX_ORE.get().defaultBlockState())//,
OreConfiguration.target(new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES), ModBlocks.BORAX_ORE.get().defaultBlockState())//,
//OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.DEEPSLATE_BORAX_ORE.get().defaultBlockState())
));

public static final Supplier<List<OreConfiguration.TargetBlockState>> OVERWORLD_PHOSPHATE_ORES =
Suppliers.memoize(() -> List.of(
OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, ModBlocks.PHOSPHATE_ORE.get().defaultBlockState())//,
OreConfiguration.target(new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES), ModBlocks.PHOSPHATE_ORE.get().defaultBlockState())//,
//OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.DEEPSLATE_PHOSPHATE_ORE.get().defaultBlockState())
));

Expand All @@ -46,7 +46,7 @@ public class ModConfiguredFeatures {
() -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(OVERWORLD_BORAX_ORES.get(),
10 // vein size
)));
*/

// public static final RegistryObject<OreFeatures> BORAX_ORE =
// CONFIGURED_FEATURES.register("borax_ore",
// () -> new OreFeatures(new OreConfiguration(
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/com/obsilab/mcsc/world/feature/ModFeatures.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.obsilab.mcsc.world.feature;

import com.obsilab.mcsc.MCSC;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.levelgen.VerticalAnchor;
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.placement.CountPlacement;
import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

import java.util.List;

import static com.obsilab.mcsc.world.feature.ModPlacedFeatures.orePlacement;

public class ModFeatures {
private static final DeferredRegister<ConfiguredFeature<?, ?>> CONFIGURED_FEATURES = DeferredRegister.create(Registries.CONFIGURED_FEATURE, MCSC.MOD_ID);
private static final DeferredRegister<PlacedFeature> PLACED_FEATURES = DeferredRegister.create(Registries.PLACED_FEATURE, MCSC.MOD_ID);

public static final RegistryObject<ConfiguredFeature<?, ?>> BORAX_ORE_CONFIGURED = CONFIGURED_FEATURES.register("borax_ore",
() -> {
var block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("mcsc:borax_ore"));
var target = List.of(OreConfiguration.target(new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES), block.defaultBlockState()));
return new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(target, 64));
});

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

public static final RegistryObject<PlacedFeature> BORAX_ORE_PLACED = PLACED_FEATURES.register("borax_ore",
() -> new PlacedFeature(BORAX_ORE_CONFIGURED.getHolder().get(),
commonOrePlacement(10, HeightRangePlacement.triangle(VerticalAnchor.absolute(-24), VerticalAnchor.absolute(56)))));

public static void register(IEventBus bus) {
CONFIGURED_FEATURES.register(bus);
PLACED_FEATURES.register(bus);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ 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 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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"feature": "minecraft:borax_ore",
"placement": [
{
"type": "minecraft:count",
"count": 30
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:uniform",
"max_inclusive": {
"absolute": 160
},
"min_inclusive": {
"absolute": 0
}
}
},
{
"type": "minecraft:biome"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"feature": "mcsc:ore_borax",
"feature": "minecraft:ore_borax",
"placement": [
{
"type": "minecraft:count",
Expand All @@ -11,7 +11,7 @@
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:triangle",
"type": "minecraft:uniform",
"max_inclusive": {
"absolute": 160
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"feature": "mcsc:ore_phosphate",
"feature": "minecraft:ore_phosphate",
"placement": [
{
"type": "minecraft:count",
Expand All @@ -16,7 +16,7 @@
"below_top": 0
},
"min_inclusive": {
"absolute": 136
"absolute": 160
}
}
},
Expand Down

0 comments on commit 3c57003

Please # to comment.