Skip to content

Commit

Permalink
fix salt ore generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hojosa committed Aug 20, 2024
1 parent e391608 commit 5293095
Show file tree
Hide file tree
Showing 22 changed files with 327 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "forge:add_features",
"biomes": "#minecraft:is_overworld",
"features": "growthcraft:deepslate_salt_ore_placed",
"step": "underground_ores"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "forge:add_features",
"biomes": "#minecraft:is_end",
"features": "growthcraft:end_salt_ore_placed",
"step": "underground_ores"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "forge:add_features",
"biomes": "#minecraft:is_nether",
"features": "growthcraft:nether_salt_ore_placed",
"step": "underground_ores"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "forge:add_features",
"biomes": "#minecraft:is_overworld",
"features": "growthcraft:salt_ore_placed",
"step": "underground_ores"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:ore",
"config": {
"discard_chance_on_air_exposure": 0.0,
"size": 5,
"targets": [
{
"state": {
"Name": "growthcraft:salt_ore_deepslate"
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:deepslate_ore_replaceables"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:ore",
"config": {
"discard_chance_on_air_exposure": 0.0,
"size": 5,
"targets": [
{
"state": {
"Name": "growthcraft:salt_ore_end"
},
"target": {
"block": "minecraft:end_stone",
"predicate_type": "minecraft:block_match"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:ore",
"config": {
"discard_chance_on_air_exposure": 0.0,
"size": 5,
"targets": [
{
"state": {
"Name": "growthcraft:salt_ore_nether"
},
"target": {
"block": "minecraft:netherrack",
"predicate_type": "minecraft:block_match"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:ore",
"config": {
"discard_chance_on_air_exposure": 0.0,
"size": 5,
"targets": [
{
"state": {
"Name": "growthcraft:salt_ore"
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:stone_ore_replaceables"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"feature": "growthcraft:deepslate_salt_ore",
"placement": [
{
"type": "minecraft:count",
"count": 50
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:uniform",
"max_inclusive": {
"absolute": 64
},
"min_inclusive": {
"absolute": -32
}
}
},
{
"type": "minecraft:biome"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"feature": "growthcraft:end_salt_ore",
"placement": [
{
"type": "minecraft:count",
"count": 50
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:uniform",
"max_inclusive": {
"absolute": 64
},
"min_inclusive": {
"absolute": -32
}
}
},
{
"type": "minecraft:biome"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"feature": "growthcraft:nether_salt_ore",
"placement": [
{
"type": "minecraft:count",
"count": 50
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:uniform",
"max_inclusive": {
"absolute": 64
},
"min_inclusive": {
"absolute": -32
}
}
},
{
"type": "minecraft:biome"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"feature": "growthcraft:salt_ore",
"placement": [
{
"type": "minecraft:count",
"count": 10
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:uniform",
"max_inclusive": {
"absolute": 64
},
"min_inclusive": {
"absolute": -32
}
}
},
{
"type": "minecraft:biome"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import growthcraft.core.datagen.providers.GrowthcraftCoreItemTags;
import growthcraft.core.datagen.providers.GrowthcraftCoreLootTableProvider;
import growthcraft.core.datagen.providers.GrowthcraftCoreRecipes;
import growthcraft.core.datagen.providers.GrowthcraftCoreWorldGenProvider;
import growthcraft.core.shared.Reference;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
Expand Down Expand Up @@ -35,9 +36,8 @@ public static void gatherData(GatherDataEvent event) {
generator.addProvider(event.includeServer(), new GrowthcraftCoreRecipes(packOutput));
generator.addProvider(event.includeServer(), new GrowthcraftCoreLootTableProvider(packOutput));
generator.addProvider(event.includeServer(), new GrowthcraftCoreGlobalLootModifiersProvider(packOutput));
generator.addProvider(event.includeServer(), new GrowthcraftCoreWorldGenProvider(packOutput, lookupProvider));
// generator.addProvider(event.includeServer(), new LootTableProvider(packOutput, Collections.emptySet(),
// List.of(new LootTableProvider.SubProviderEntry(GrowthcraftCoreLootTables::new, LootContextParamSets.BLOCK))));
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package growthcraft.core.datagen.providers;

import java.util.Set;
import java.util.concurrent.CompletableFuture;

import growthcraft.core.shared.Reference;
import growthcraft.core.world.GrowthcraftBiomeModifiers;
import growthcraft.core.world.GrowthcraftConfiguredFeatures;
import growthcraft.core.world.GrowthcraftPlacedFeatures;
import net.minecraft.core.HolderLookup.Provider;
import net.minecraft.core.RegistrySetBuilder;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider;
import net.minecraftforge.registries.ForgeRegistries;

public class GrowthcraftCoreWorldGenProvider extends DatapackBuiltinEntriesProvider{
public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
.add(Registries.CONFIGURED_FEATURE, GrowthcraftConfiguredFeatures::bootstrap)
.add(Registries.PLACED_FEATURE, GrowthcraftPlacedFeatures::bootstrap)
.add(ForgeRegistries.Keys.BIOME_MODIFIERS, GrowthcraftBiomeModifiers::bootstrap);

public GrowthcraftCoreWorldGenProvider(PackOutput output, CompletableFuture<Provider> registries) {
super(output, registries, BUILDER, Set.of(Reference.MODID));
}

@Override
public String getName() {
return "Growthcraft WorldGen";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package growthcraft.core.world;

import growthcraft.core.shared.Reference;
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.levelgen.GenerationStep;
import net.minecraftforge.common.world.BiomeModifier;
import net.minecraftforge.common.world.ForgeBiomeModifiers;
import net.minecraftforge.registries.ForgeRegistries;

public class GrowthcraftBiomeModifiers {
public static final ResourceKey<BiomeModifier> ADD_SALT_ORE = registerKey("add_salt_ore");
public static final ResourceKey<BiomeModifier> ADD_DEEPSLATE_SALT_ORE = registerKey("add_deepslate_salt_ore");
public static final ResourceKey<BiomeModifier> ADD_NETHER_SALT_ORE = registerKey("add_nether_salt_ore");
public static final ResourceKey<BiomeModifier> ADD_END_SALT_ORE = registerKey("add_end_salt_ore");


public static void bootstrap(BootstapContext<BiomeModifier> context) {
var placedFeatures = context.lookup(Registries.PLACED_FEATURE);
var biomes = context.lookup(Registries.BIOME);

context.register(ADD_SALT_ORE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier(
biomes.getOrThrow(BiomeTags.IS_OVERWORLD),
HolderSet.direct(placedFeatures.getOrThrow(GrowthcraftPlacedFeatures.SALT_ORE_PLACED_KEY)),
GenerationStep.Decoration.UNDERGROUND_ORES));

context.register(ADD_DEEPSLATE_SALT_ORE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier(
biomes.getOrThrow(BiomeTags.IS_OVERWORLD),
HolderSet.direct(placedFeatures.getOrThrow(GrowthcraftPlacedFeatures.DEEPSLATE_SALT_ORE_PLACED_KEY)),
GenerationStep.Decoration.UNDERGROUND_ORES));

context.register(ADD_NETHER_SALT_ORE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier(
biomes.getOrThrow(BiomeTags.IS_NETHER),
HolderSet.direct(placedFeatures.getOrThrow(GrowthcraftPlacedFeatures.NETHER_SALT_ORE_PLACED_KEY)),
GenerationStep.Decoration.UNDERGROUND_ORES));

context.register(ADD_END_SALT_ORE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier(
biomes.getOrThrow(BiomeTags.IS_END),
HolderSet.direct(placedFeatures.getOrThrow(GrowthcraftPlacedFeatures.END_SALT_ORE_PLACED_KEY)),
GenerationStep.Decoration.UNDERGROUND_ORES));
}

private static ResourceKey<BiomeModifier> registerKey(String name) {
return ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(Reference.MODID, name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest;

public class GrowthcraftConfiguredFeatures {
public static final ResourceKey<ConfiguredFeature<?, ?>> OVERWORLD_SALT_ORE_KEY
public static final ResourceKey<ConfiguredFeature<?, ?>> SALT_ORE_KEY
= registerKey(Reference.UnlocalizedName.SALT_ORE);

public static final ResourceKey<ConfiguredFeature<?, ?>> NETHER_SALT_ORE_KEY
= registerKey(Reference.UnlocalizedName.SALT_ORE + "_nether");
= registerKey("nether_" + Reference.UnlocalizedName.SALT_ORE);

public static final ResourceKey<ConfiguredFeature<?, ?>> END_SALT_ORE_KEY
= registerKey(Reference.UnlocalizedName.SALT_ORE + "_end");
= registerKey("end_" + Reference.UnlocalizedName.SALT_ORE);

public static final ResourceKey<ConfiguredFeature<?, ?>> DEEPSLATE_SALT_ORE_KEY
= registerKey(Reference.UnlocalizedName.SALT_ORE + "_deepslate");
= registerKey("deepslate_" + Reference.UnlocalizedName.SALT_ORE);

private static final int SALT_ORE_GEN_VEIN_SIZE
= GrowthcraftConfig.getSaltOreGenVeinSize(); // Iron is 9, Diamond is 0.7
Expand All @@ -43,9 +43,9 @@ public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
RuleTest deepslateReplaceable = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES);
RuleTest netherrackReplaceable = new BlockMatchTest(Blocks.NETHERRACK);
RuleTest endstoneReplaceable = new BlockMatchTest(Blocks.END_STONE);

if(GrowthcraftConfig.isSaltOreGenEnabled()) {
register(context, OVERWORLD_SALT_ORE_KEY, Feature.ORE, new OreConfiguration(stoneReplaceable,
register(context, SALT_ORE_KEY, Feature.ORE, new OreConfiguration(stoneReplaceable,
GrowthcraftBlocks.SALT_ORE.get().defaultBlockState(), SALT_ORE_GEN_VEIN_SIZE));

if (GrowthcraftConfig.isSaltOreGenEnabledForDimension("deepslate")) {
Expand All @@ -55,12 +55,12 @@ public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {

if (GrowthcraftConfig.isSaltOreGenEnabledForDimension("theend")) {
register(context, END_SALT_ORE_KEY, Feature.ORE, new OreConfiguration(endstoneReplaceable,
GrowthcraftBlocks.SALT_ORE_END.get().defaultBlockState(), 9));
GrowthcraftBlocks.SALT_ORE_END.get().defaultBlockState(), SALT_ORE_GEN_VEIN_SIZE));
}

if (GrowthcraftConfig.isSaltOreGenEnabledForDimension("nether")) {
register(context, NETHER_SALT_ORE_KEY, Feature.ORE, new OreConfiguration(netherrackReplaceable,
GrowthcraftBlocks.SALT_ORE_NETHER.get().defaultBlockState(), 9));
GrowthcraftBlocks.SALT_ORE_NETHER.get().defaultBlockState(), SALT_ORE_GEN_VEIN_SIZE));
}
} else {
Growthcraft.LOGGER.info("Growthcraft Core config has salt generation disabled.");
Expand Down
Loading

0 comments on commit 5293095

Please sign in to comment.