🇺🇦 Українська (Ukrainian - Ukraine)
🇺🇦 Українська (Ukrainian - Ukraine)
Зовнішній вигляд
🇺🇦 Українська (Ukrainian - Ukraine)
🇺🇦 Українська (Ukrainian - Ukraine)
Зовнішній вигляд
Ця сторінка написана для версії:
1.21.4
Ця сторінка написана для версії:
1.21.4
ПЕРЕДУМОВА
Спершу переконайтеся, що ви виконали процес налаштування datagen.
По-перше, нам знадобиться наш постачальник. Створіть клас extends FabricRecipeProvider
. Уся наша генерація рецептів відбуватиметься всередині методу generate
нашого постачальника.
import java.util.List;
import java.util.concurrent.CompletableFuture;
import net.minecraft.data.recipe.RecipeExporter;
import net.minecraft.data.recipe.RecipeGenerator;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.ItemTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
public class FabricDocsReferenceRecipeProvider extends FabricRecipeProvider {
public FabricDocsReferenceRecipeProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
}
@Override
protected RecipeGenerator getRecipeGenerator(RegistryWrapper.WrapperLookup registryLookup, RecipeExporter exporter) {
return new RecipeGenerator(registryLookup, exporter) {
@Override
public void generate() {
RegistryWrapper.Impl<Item> itemLookup = registries.getOrThrow(RegistryKeys.ITEM);
}
};
}
@Override
public String getName() {
return "FabricDocsReferenceRecipeProvider";
}
}
Щоб завершити налаштування, додайте цього постачальника до своєї DataGeneratorEntrypoint
у методі onInitializeDataGenerator
.
pack.addProvider(FabricDocsReferenceRecipeProvider::new);
Безформні рецепти досить прості. Просто додайте їх до методу generate
у вашому постачальнику:
createShapeless(RecipeCategory.BUILDING_BLOCKS, Items.DIRT) // You can also specify an int to produce more than one
.input(Items.COARSE_DIRT) // You can also specify an int to require more than one, or a tag to accept multiple things
// Create an advancement that gives you the recipe
.criterion(hasItem(Items.COARSE_DIRT), conditionsFromItem(Items.COARSE_DIRT))
.offerTo(exporter);
Для формного рецепта ви визначаєте форму за допомогою String
, а потім визначаєте, що означає кожен char
у String
.
createShaped(RecipeCategory.MISC, Items.CRAFTING_TABLE, 4)
.pattern("ll")
.pattern("ll")
.input('l', ItemTags.LOGS) // 'l' means "any log"
.group("multi_bench") // Put it in a group called "multi_bench" - groups are shown in one slot in the recipe book
.criterion(hasItem(Items.CRAFTING_TABLE), conditionsFromItem(Items.CRAFTING_TABLE))
.offerTo(exporter);
createShaped(RecipeCategory.MISC, Items.LOOM, 4)
.pattern("ww")
.pattern("ll")
.input('w', ItemTags.WOOL) // 'w' means "any wool"
.input('l', ItemTags.LOGS)
.group("multi_bench")
.criterion(hasItem(Items.LOOM), conditionsFromItem(Items.LOOM))
.offerTo(exporter);
createDoorRecipe(Items.OAK_DOOR, Ingredient.ofItems(Items.OAK_BUTTON)) // Using a helper method!
.criterion(hasItem(Items.OAK_BUTTON), conditionsFromItem(Items.OAK_BUTTON))
.offerTo(exporter);
TIP
Існує багато допоміжних методів для створення звичайних рецептів. Перевірте, що може запропонувати RecipeProvider
! Використовуйте Alt + 7
в IntelliJ, щоб відкрити структуру класу, включаючи список методів.
Інші рецепти працюють так само, але вимагають кількох додаткових параметрів. Наприклад, рецепти плавки повинні знати, скільки досвіду присудити.
offerSmelting(
List.of(Items.BREAD, Items.COOKIE, Items.HAY_BLOCK), // Inputs
RecipeCategory.FOOD, // Category
Items.WHEAT, // Output
0.1f, // Experience
300, // Cooking time
"food_to_wheat" // group
);