Skip to content

Commit

Permalink
Make Ore Generate in the World
Browse files Browse the repository at this point in the history
  • Loading branch information
EmpressAutumn committed Feb 5, 2024
1 parent 0a71564 commit 8491814
Show file tree
Hide file tree
Showing 18 changed files with 258 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// 1.20.4 2024-02-05T16:01:54.5161812 Titanium/Model Definitions
// 1.20.4 2024-02-05T17:06:17.0790645 Titanium/Model Definitions
e0c60320e94e5d876caf5db971017c564d2b52e3 assets\titanium\blockstates\deepslate_titanium_ore.json
b9ab004f7892f3b08e2dfb1181cd001579110f57 assets\titanium\models\item\titanium_chestplate.json
2d1a0a57ba4b82755a917b6bac14f13f839767f3 assets\titanium\models\item\raw_titanium.json
7786475ccc60c57b0f8753a66d1c1aa91ebdf1ad assets\titanium\models\item\titanium_pickaxe.json
e6cb7cbe6e9ad09e1c77b221aa81fb6c6c281ee0 assets\titanium\models\item\titanium_shovel.json
f542e849d8f61855942377bddbcd72574245a98d assets\titanium\models\item\titanium_ore.json
e6cb7cbe6e9ad09e1c77b221aa81fb6c6c281ee0 assets\titanium\models\item\titanium_shovel.json
b111702b740c70103c3e193d53b398f65cf31641 assets\titanium\blockstates\raw_titanium_block.json
13b448d892e18db065991245bedf98f1495faee6 assets\titanium\models\item\titanium_sword.json
a0555e40980d02acc693771d2853772f9d55f840 assets\titanium\models\item\titanium_helmet.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.4 2024-02-05T16:01:54.5201905 Titanium/Block Loot Tables
// 1.20.4 2024-02-05T17:06:17.0838726 Titanium/Block Loot Tables
fd73ce0826e836b7e0abe4af39b85db2aca5988b data\titanium\loot_tables\blocks\deepslate_titanium_ore.json
9ddfc49204e35d9ec5442f9f55a2da667b84215c data\titanium\loot_tables\blocks\titanium_block.json
ecf65e601c9264c2de80be1a0a9d67f85c2744c2 data\titanium\loot_tables\blocks\raw_titanium_block.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// 1.20.4 2024-02-05T16:01:54.5231981 Titanium/Tags for minecraft:block
// 1.20.4 2024-02-05T17:06:17.0866939 Titanium/Tags for minecraft:block
40a22829dc45910fc144676bb4bd94f2ed21c46b data\minecraft\tags\blocks\mineable\pickaxe.json
40a22829dc45910fc144676bb4bd94f2ed21c46b data\minecraft\tags\blocks\needs_iron_tool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// 1.20.4 2024-02-05T17:06:17.0896883 Titanium/World Gen
31a3c735f941c808dd8915d27e9f8340a70c606b data\titanium\worldgen\configured_feature\titanium_ore.json
8d75cadfd54d93e9504231ada137c960200b7ac0 data\titanium\worldgen\configured_feature\end_titanium_ore.json
3d92d749954790a861e3fc4d734a5617fa7d030a data\titanium\worldgen\placed_feature\titanium_ore_placed.json
f25520097b6003fd5b7be640fa98068bfeae03c2 data\titanium\worldgen\placed_feature\end_titanium_ore_placed.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// 1.20.4 2024-02-05T16:01:54.5091617 Titanium/Recipes
// 1.20.4 2024-02-05T17:06:17.0751973 Titanium/Recipes
f8a16a50c8ef3d1b70a0befe2781046dea651c41 data\titanium\recipes\titanium_ingot.json
8db0f204262bd86cd7905c7d52705381a8dfa78c data\titanium\recipes\titanium_ingot_from_blasting_end_titanium_ore.json
200e84c3f8001cbf640d369f4b12a1f53c465655 data\titanium\recipes\titanium_ingot_from_smelting_titanium_ore.json
9fdb0af08e25924ac9180580edfb8cabf0a1330c data\titanium\recipes\titanium_helmet.json
faf3e30aa11a39183dff4f36f99fc1e2d381cedc data\titanium\advancements\recipes\misc\titanium_ingot_from_blasting_raw_titanium.json
200a808611f844f6a2613e2b07cb8cade0c465e4 data\titanium\recipes\titanium_ingot_from_blasting_titanium_ore.json
faf3e30aa11a39183dff4f36f99fc1e2d381cedc data\titanium\advancements\recipes\misc\titanium_ingot_from_blasting_raw_titanium.json
5d138c95cbba1740d8c06173e79d91508758fd3e data\titanium\advancements\recipes\misc\titanium_ingot_from_smelting_titanium_ore.json
e6dc57e0aca2c4af3ae6e1d6689994b79483c09c data\titanium\recipes\titanium_chestplate.json
2cdd3763e3eebdd064c6fda6cb626e437292dd17 data\titanium\advancements\recipes\misc\titanium_ingot_from_blasting_titanium_ore.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 1.20.4 2024-02-05T16:01:54.5041484 Titanium/Tags for minecraft:item
// 1.20.4 2024-02-05T17:06:17.0700409 Titanium/Tags for minecraft:item
2a186cdc91b83a46ade5894dc10cd043cef0c7cc data\fabric\tags\items\swords.json
89b0efee69794169293c204cbbf104952bcc8544 data\fabric\tags\items\shovels.json
758fc896a1c5fb6a5ca958cef5066c539ebc193f data\fabric\tags\items\axes.json
89b0efee69794169293c204cbbf104952bcc8544 data\fabric\tags\items\shovels.json
49490c758ba9aaee94e1f6192fc4a2eb56bde4d8 data\fabric\tags\items\hoes.json
ab93c62885c7a9aaf84f8aa8c17a2530ea0dd93e data\fabric\tags\items\pickaxes.json
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": 12,
"targets": [
{
"state": {
"Name": "titanium:end_titanium_ore"
},
"target": {
"block": "minecraft:end_stone",
"predicate_type": "minecraft:block_match"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "minecraft:ore",
"config": {
"discard_chance_on_air_exposure": 0.0,
"size": 12,
"targets": [
{
"state": {
"Name": "titanium:titanium_ore"
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:stone_ore_replaceables"
}
},
{
"state": {
"Name": "titanium:deepslate_titanium_ore"
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:deepslate_ore_replaceables"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"feature": "titanium:end_titanium_ore",
"placement": [
{
"type": "minecraft:count",
"count": 8
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:uniform",
"max_inclusive": {
"below_top": 0
},
"min_inclusive": {
"above_bottom": 0
}
}
},
{
"type": "minecraft:biome"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"feature": "titanium:titanium_ore",
"placement": [
{
"type": "minecraft:count",
"count": 4
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:uniform",
"max_inclusive": {
"absolute": 20
},
"min_inclusive": {
"above_bottom": 0
}
}
},
{
"type": "minecraft:biome"
}
]
}
3 changes: 3 additions & 0 deletions src/main/java/com/atom596/titanium/Titanium.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.atom596.titanium.block.TitaniumBlocks;
import com.atom596.titanium.item.TitaniumItemGroup;
import com.atom596.titanium.item.TitaniumItems;
import com.atom596.titanium.world.gen.TitaniumWorldGeneration;
import net.fabricmc.api.ModInitializer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -16,5 +17,7 @@ public void onInitialize() {
TitaniumItems.register();
TitaniumBlocks.register();
TitaniumItemGroup.register();

TitaniumWorldGeneration.generateModWorldGen();
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/atom596/titanium/TitaniumDataGenerator.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.atom596.titanium;

import com.atom596.titanium.datagen.*;
import com.atom596.titanium.world.TitaniumConfiguredFeatures;
import com.atom596.titanium.world.TitaniumPlacedFeatures;
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.minecraft.registry.RegistryBuilder;
import net.minecraft.registry.RegistryKeys;

public class TitaniumDataGenerator implements DataGeneratorEntrypoint {
@Override
Expand All @@ -14,5 +18,12 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
pack.addProvider(TitaniumLootTableProvider::new);
pack.addProvider(TitaniumModelProvider::new);
pack.addProvider(TitaniumRecipeProvider::new);
pack.addProvider(TitaniumWorldGenerator::new);
}

@Override
public void buildRegistry(RegistryBuilder registryBuilder) {
registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, TitaniumConfiguredFeatures::bootstrap);
registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, TitaniumPlacedFeatures::bootstrap);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.atom596.titanium.datagen;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;

import java.util.concurrent.CompletableFuture;

public class TitaniumWorldGenerator extends FabricDynamicRegistryProvider {
public TitaniumWorldGenerator(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
}

@Override
protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) {
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE));
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE));
}

@Override
public String getName() {
return "World Gen";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,39 @@
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.feature.OreFeatureConfig;

import java.util.List;

public class TitaniumConfiguredFeatures {
public static final RegistryKey<ConfiguredFeature<?, ?>> TITANIUM_ORE_KEY = registerKey("titanium_ore");
public static final RegistryKey<ConfiguredFeature<?, ?>> END_TITANIUM_ORE_KEY = registerKey("end_titanium_ore");

public static void bootstrap(Registerable<ConfiguredFeature<?, ?>> context) {
RuleTest stoneReplaceables = new TagMatchRuleTest(BlockTags.STONE_ORE_REPLACEABLES);
RuleTest deepslateReplaceables = new TagMatchRuleTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES);
RuleTest endReplaceables = new BlockMatchRuleTest(Blocks.END_STONE);

List<OreFeatureConfig.Target> overworldTitaniumOres =
List.of(OreFeatureConfig.createTarget(stoneReplaceables, TitaniumBlocks.TITANIUM_ORE.getDefaultState()),
OreFeatureConfig.createTarget(deepslateReplaceables, TitaniumBlocks.DEEPSLATE_TITANIUM_ORE.getDefaultState()));
List<OreFeatureConfig.Target> endTitaniumOre =
List.of(OreFeatureConfig.createTarget(endReplaceables, TitaniumBlocks.END_TITANIUM_ORE.getDefaultState()));

register(context, TITANIUM_ORE_KEY, Feature.ORE, new OreFeatureConfig(overworldTitaniumOres, 12));
register(context, END_TITANIUM_ORE_KEY, Feature.ORE, new OreFeatureConfig(endTitaniumOre, 12));
}

public static RegistryKey<ConfiguredFeature<?, ?>> registerKey(String name) {
return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, new Identifier(Titanium.MOD_ID, name));
}

private static <FC extends FeatureConfig, F extends Feature<FC>> void register(Registerable<ConfiguredFeature<?, ?>> context,
RegistryKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration) {
context.register(key, new ConfiguredFeature<>(feature, configuration));
}

/*public static final RegistryKey<ConfiguredFeature<?, ?>> TITANIUM_ORE_KEY = registerKey("titanium_ore");
public static void bootstrap(Registerable<ConfiguredFeature<?, ?>> context) {
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/atom596/titanium/world/TitaniumOrePlacement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.atom596.titanium.world;

import net.minecraft.world.gen.placementmodifier.*;

import java.util.List;

public class TitaniumOrePlacement {
public static List<PlacementModifier> modifiers(PlacementModifier countModifier, PlacementModifier heightModifier) {
return List.of(countModifier, SquarePlacementModifier.of(), heightModifier, BiomePlacementModifier.of());
}

public static List<PlacementModifier> modifiersWithCount(int count, PlacementModifier heightModifier) {
return modifiers(CountPlacementModifier.of(count), heightModifier);
}

public static List<PlacementModifier> modifiersWithRarity(int chance, PlacementModifier heightModifier) {
return modifiers(RarityFilterPlacementModifier.of(chance), heightModifier);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.atom596.titanium.world;

import com.atom596.titanium.Titanium;
import net.minecraft.registry.Registerable;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.YOffset;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.world.gen.placementmodifier.HeightRangePlacementModifier;
import net.minecraft.world.gen.placementmodifier.PlacementModifier;

import java.util.List;

public class TitaniumPlacedFeatures {
public static final RegistryKey<PlacedFeature> TITANIUM_ORE_PLACED_KEY = registerKey("titanium_ore_placed");
public static final RegistryKey<PlacedFeature> END_TITANIUM_ORE_PLACED_KEY = registerKey("end_titanium_ore_placed");

public static void bootstrap(Registerable<PlacedFeature> context) {
var configuredFeatureRegistryEntryLookup = context.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE);

register(context, TITANIUM_ORE_PLACED_KEY, configuredFeatureRegistryEntryLookup.getOrThrow(TitaniumConfiguredFeatures.TITANIUM_ORE_KEY),
TitaniumOrePlacement.modifiersWithCount(4, HeightRangePlacementModifier.uniform(YOffset.BOTTOM, YOffset.fixed(20))));
register(context, END_TITANIUM_ORE_PLACED_KEY, configuredFeatureRegistryEntryLookup.getOrThrow(TitaniumConfiguredFeatures.END_TITANIUM_ORE_KEY),
TitaniumOrePlacement.modifiersWithCount(16, HeightRangePlacementModifier.uniform(YOffset.BOTTOM, YOffset.TOP)));
}

public static RegistryKey<PlacedFeature> registerKey(String name) {
return RegistryKey.of(RegistryKeys.PLACED_FEATURE, new Identifier(Titanium.MOD_ID, name));
}

private static void register(Registerable<PlacedFeature> context, RegistryKey<PlacedFeature> key, RegistryEntry<ConfiguredFeature<?, ?>> configuration,
List<PlacementModifier> modifiers) {
context.register(key, new PlacedFeature(configuration, List.copyOf(modifiers)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.atom596.titanium.world.gen;

import com.atom596.titanium.world.TitaniumPlacedFeatures;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.minecraft.world.gen.GenerationStep;

public class TitaniumOreGeneration {
public static void generateOres() {
BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(),
GenerationStep.Feature.UNDERGROUND_ORES, TitaniumPlacedFeatures.TITANIUM_ORE_PLACED_KEY);
BiomeModifications.addFeature(BiomeSelectors.foundInTheEnd(),
GenerationStep.Feature.UNDERGROUND_ORES, TitaniumPlacedFeatures.END_TITANIUM_ORE_PLACED_KEY);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.atom596.titanium.world.gen;

public class TitaniumWorldGeneration {
public static void generateModWorldGen() {
TitaniumOreGeneration.generateOres();
}
}

0 comments on commit 8491814

Please sign in to comment.