Skip to content

Commit

Permalink
v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugman76 authored Jan 23, 2025
2 parents 9602246 + 8bfb34e commit 7efcaae
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 33 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ loader_name=Fabric
loader_icon=https://fabricmc.net/assets/logo.png

# check these on https://fabricmc.net/develop/
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
loader_version=0.16.10
fabric_version=0.115.0+1.21.1
fabric_version=0.115.0+1.21.4
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
var blockTags = pack.addProvider(UniversalOresBlockTagProvider::new);
pack.addProvider((fabricDataOutput, completableFuture) -> new UniversalOresItemTagProvider(fabricDataOutput, completableFuture, blockTags));
pack.addProvider(UniversalOresBlockLootTableProvider::new);
pack.addProvider(UniversalOresRecipeGenerator::new);
pack.addProvider(UniversalOresRecipeGenerator::create);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public UniversalOresBlockLootTableProvider(FabricDataOutput dataOutput, Completa

@Override
public void generate() {
var enchantments = this.registryLookup.getWrapperOrThrow(RegistryKeys.ENCHANTMENT);
var enchantments = this.registries.getOrThrow(RegistryKeys.ENCHANTMENT);

for (var block : UniversalOresBlocks.COAL_ORES) {
this.addDrop(block, b -> this.oreDrops(b, Items.COAL));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@


import fr.hugman.universal_ores.block.UniversalOresBlocks;
import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.ItemModelGenerator;
import net.minecraft.data.client.TexturedModel;
import net.minecraft.client.data.BlockStateModelGenerator;
import net.minecraft.client.data.ItemModelGenerator;
import net.minecraft.client.data.TexturedModel;

public class UniversalOresModelProvider extends FabricModelProvider {
public UniversalOresModelProvider(FabricDataOutput output) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,49 @@
import fr.hugman.universal_ores.block.UniversalOresBlocks;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.data.server.recipe.CookingRecipeJsonBuilder;
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.recipe.CookingRecipeJsonBuilder;
import net.minecraft.data.recipe.RecipeExporter;
import net.minecraft.data.recipe.RecipeGenerator;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.Items;
import net.minecraft.recipe.*;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;

public class UniversalOresRecipeGenerator extends FabricRecipeProvider {
public UniversalOresRecipeGenerator(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
public class UniversalOresRecipeGenerator extends RecipeGenerator {
public UniversalOresRecipeGenerator(RegistryWrapper.WrapperLookup registries, RecipeExporter exporter) {
super(registries, exporter);
}

@Override
public void generate(RecipeExporter exporter) {
offerOres(exporter, ImmutableList.copyOf(UniversalOresBlocks.COAL_ORES), RecipeCategory.MISC, Items.COAL, 0.1F, 200, "coal");
offerOres(exporter, ImmutableList.copyOf(UniversalOresBlocks.IRON_ORES), RecipeCategory.MISC, Items.IRON_INGOT, 0.7F, 200, "iron_ingot");
offerOres(exporter, ImmutableList.copyOf(
public void generate() {
offerOres(ImmutableList.copyOf(UniversalOresBlocks.COAL_ORES), RecipeCategory.MISC, Items.COAL, 0.1F, 200, "coal");
offerOres(ImmutableList.copyOf(UniversalOresBlocks.IRON_ORES), RecipeCategory.MISC, Items.IRON_INGOT, 0.7F, 200, "iron_ingot");
offerOres(ImmutableList.copyOf(
Stream.concat(Arrays.stream(UniversalOresBlocks.GOLD_ORES), Arrays.stream(UniversalOresBlocks.NETHER_GOLD_ORES))
.toArray(ItemConvertible[]::new)
), RecipeCategory.MISC, Items.GOLD_INGOT, 1.0F, 200, "gold_ingot");
offerOres(exporter, ImmutableList.copyOf(UniversalOresBlocks.COPPER_ORES), RecipeCategory.MISC, Items.COPPER_INGOT, 0.7F, 200, "copper_ingot");
offerOres(exporter, ImmutableList.copyOf(UniversalOresBlocks.LAPIS_ORES), RecipeCategory.MISC, Items.LAPIS_LAZULI, 0.2F, 200, "lapis_lazuli");
offerOres(exporter, ImmutableList.copyOf(UniversalOresBlocks.REDSTONE_ORES), RecipeCategory.REDSTONE, Items.REDSTONE, 0.7F, 200, "redstone");
offerOres(exporter, ImmutableList.copyOf(UniversalOresBlocks.EMERALD_ORES), RecipeCategory.MISC, Items.EMERALD, 1.0F, 200, "emerald");
offerOres(exporter, ImmutableList.copyOf(UniversalOresBlocks.DIAMOND_ORES), RecipeCategory.MISC, Items.DIAMOND, 1.0F, 200, "diamond");
offerOres(exporter, ImmutableList.copyOf(UniversalOresBlocks.QUARTZ_ORES), RecipeCategory.MISC, Items.QUARTZ, 0.2F, 200, "quartz");
offerOres(ImmutableList.copyOf(UniversalOresBlocks.COPPER_ORES), RecipeCategory.MISC, Items.COPPER_INGOT, 0.7F, 200, "copper_ingot");
offerOres(ImmutableList.copyOf(UniversalOresBlocks.LAPIS_ORES), RecipeCategory.MISC, Items.LAPIS_LAZULI, 0.2F, 200, "lapis_lazuli");
offerOres(ImmutableList.copyOf(UniversalOresBlocks.REDSTONE_ORES), RecipeCategory.REDSTONE, Items.REDSTONE, 0.7F, 200, "redstone");
offerOres(ImmutableList.copyOf(UniversalOresBlocks.EMERALD_ORES), RecipeCategory.MISC, Items.EMERALD, 1.0F, 200, "emerald");
offerOres(ImmutableList.copyOf(UniversalOresBlocks.DIAMOND_ORES), RecipeCategory.MISC, Items.DIAMOND, 1.0F, 200, "diamond");
offerOres(ImmutableList.copyOf(UniversalOresBlocks.QUARTZ_ORES), RecipeCategory.MISC, Items.QUARTZ, 0.2F, 200, "quartz");
}

public void offerOres(RecipeExporter exporter, List<ItemConvertible> ores, RecipeCategory category, ItemConvertible result, float experience, int cookingTime, String name) {
offerMultipleOptions(exporter, RecipeSerializer.SMELTING, SmeltingRecipe::new, ores, category, result, experience, cookingTime, name, "_from_smelting");
offerMultipleOptions(exporter, RecipeSerializer.BLASTING, BlastingRecipe::new, ores, category, result, experience, cookingTime / 2, name, "_from_blasting");
public void offerOres(List<ItemConvertible> ores, RecipeCategory category, ItemConvertible result, float experience, int cookingTime, String name) {
offerMultipleOptionsFixed(RecipeSerializer.SMELTING, SmeltingRecipe::new, ores, category, result, experience, cookingTime, name, "_from_smelting");
offerMultipleOptionsFixed(RecipeSerializer.BLASTING, BlastingRecipe::new, ores, category, result, experience, cookingTime / 2, name, "_from_blasting");
}

public static <T extends AbstractCookingRecipe> void offerMultipleOptions(
RecipeExporter exporter,
public <T extends AbstractCookingRecipe> void offerMultipleOptionsFixed(
RecipeSerializer<T> serializer,
AbstractCookingRecipe.RecipeFactory<T> recipeFactory,
List<ItemConvertible> inputs,
Expand All @@ -60,7 +62,21 @@ public static <T extends AbstractCookingRecipe> void offerMultipleOptions(
CookingRecipeJsonBuilder.create(Ingredient.ofItems(itemConvertible), category, output, experience, cookingTime, serializer, recipeFactory)
.group(group)
.criterion(hasItem(itemConvertible), conditionsFromItem(itemConvertible))
.offerTo(exporter, UniversalOres.id(getItemPath(output) + suffix + "_" + getItemPath(itemConvertible)));
.offerTo(this.exporter, RegistryKey.of(RegistryKeys.RECIPE, UniversalOres.id(getItemPath(output) + suffix + "_" + getItemPath(itemConvertible))));
}
}

public static FabricRecipeProvider create(FabricDataOutput fabricDataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) {
return new FabricRecipeProvider(fabricDataOutput, completableFuture) {
@Override
protected RecipeGenerator getRecipeGenerator(RegistryWrapper.WrapperLookup wrapperLookup, RecipeExporter recipeExporter) {
return new UniversalOresRecipeGenerator(wrapperLookup, recipeExporter);
}

@Override
public String getName() {
return "Recipes";
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ private static Block register(String key, Function<AbstractBlock.Settings, Block
}

private static Block register(RegistryKey<Block> key, Function<AbstractBlock.Settings, Block> factory, AbstractBlock.Settings blockSettings) {
var block = factory.apply(blockSettings);
var block = factory.apply(blockSettings.registryKey(key));
Registry.register(Registries.BLOCK, key, block);

var itemRegistryKey = RegistryKey.of(RegistryKeys.ITEM, key.getValue());
Registry.register(Registries.ITEM, itemRegistryKey, new BlockItem(block, new Item.Settings()));
Registry.register(Registries.ITEM, itemRegistryKey, new BlockItem(block, new Item.Settings().registryKey(itemRegistryKey).useBlockPrefixedTranslationKey()));

return block;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
],
"accessWidener": "universal_ores.accesswidener",
"depends": {
"minecraft": "^1.21.1",
"minecraft": "^1.21.4",
"fabric": "*"
},
"custom": {
Expand Down

0 comments on commit 7efcaae

Please sign in to comment.