Skip to content

Commit

Permalink
补全进度生成
Browse files Browse the repository at this point in the history
  • Loading branch information
baka4n committed Dec 15, 2023
1 parent 4594eeb commit c03868c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/advancement/datagen.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## Mojang
这个是mojang的原生Advancement DataGen代码

```java

package net.minecraft.data.advancements;
Expand Down Expand Up @@ -105,7 +106,8 @@ public class TutorialProvider extends AdvancementProvider {

private static void register(Consumer<Advancement> advancementConsumer) {
Advancement.Builder.advancement()
.addCriterion(new CraftingRecipeTrigger.TriggerInstance(EntityPredicate.Composite.ANY, ItemPredicate.Builder.item().of(Items.STICK)));
.addCriterion("a", new CraftingRecipeTrigger.TriggerInstance(EntityPredicate.Composite.ANY, ItemPredicate.Builder.item().of(Items.STICK)))
.save(consumer, new ResourceLocation("tutorial", "main/root"));
}

@Override
Expand All @@ -124,7 +126,30 @@ public class TutorialProvider extends AdvancementProvider {
## Fabric

```java
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.critereon.EntityPredicate;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;

import java.util.function.Consumer;

public class TutorialProvider extends FabricAdvancementProvider {
public TutorialProvider(FabricDataGenerator generator) {
super(generator);
}

@Override
public void generateAdvancement(Consumer<Advancement> consumer) {
Advancement.Builder.advancement()
.addCriterion("a", new CraftingRecipeTrigger.TriggerInstance(EntityPredicate.Composite.ANY, ItemPredicate.Builder.item().of(Items.STICK)))
.save(consumer, new ResourceLocation("tutorial", "main/root"));
}
}
```

## Architectury
## Architectury
1. 写一个forge的dataGen
2. 分别在fabric forge模块下设定特有的dataen操作

0 comments on commit c03868c

Please sign in to comment.