Skip to content

Commit

Permalink
修改 patchouli 模组的支持
Browse files Browse the repository at this point in the history
- 进度和合成添加 modid 判断,但是部分 datagen 无法生成此参数,故删掉部分 datagen,改为手动添加
  • Loading branch information
TartaricAcid committed Sep 8, 2024
1 parent cabc169 commit 05a2a11
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ dependencies {
runtimeOnly "maven.modrinth:libipn:neoforge-1.21-6.0.2"
implementation "maven.modrinth:inventory-profiles-next:neoforge-1.21-2.0.4"
// Patchouli
implementation "libs:Patchouli:1.21-87-NEOFORGE-SNAPSHOT"
implementation "maven.modrinth:patchouli:1.21-87-neoforge"
}

// 用于 neoforge.mods 里替换那一堆 ${xxxx}
Expand Down
Binary file removed libs/Patchouli-1.21-87-NEOFORGE-SNAPSHOT.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"neoforge:conditions": [
{
"type": "neoforge:mod_loaded",
"modid": "patchouli"
}
],
"parent": "minecraft:recipes/root",
"criteria": {
"has_book": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"neoforge:conditions": [
{
"type": "neoforge:mod_loaded",
"modid": "patchouli"
}
],
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.tartaricacid.touhoulittlemaid.datagen;

import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid;
import com.github.tartaricacid.touhoulittlemaid.advancements.GivePatchouliBookConfigTrigger;
import com.github.tartaricacid.touhoulittlemaid.advancements.GiveSmartSlabConfigTrigger;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementHolder;
Expand All @@ -19,8 +18,7 @@
public class AdvancementDataGen extends AdvancementProvider {
public AdvancementDataGen(PackOutput packOutput, CompletableFuture<HolderLookup.Provider> provider, ExistingFileHelper helper) {
super(packOutput, provider, helper, List.of(
new GiveSmartSlab(),
new GrantPatchouliBook()
new GiveSmartSlab()
));
}

Expand All @@ -33,14 +31,4 @@ public void generate(HolderLookup.Provider provider, Consumer<AdvancementHolder>
.save(saver, ResourceLocation.fromNamespaceAndPath(TouhouLittleMaid.MOD_ID, "give_smart_slab"), helper);
}
}

private static final class GrantPatchouliBook implements AdvancementGenerator {
@Override
public void generate(HolderLookup.Provider provider, Consumer<AdvancementHolder> saver, ExistingFileHelper helper) {
Advancement.Builder.advancement()
.addCriterion("tick", GivePatchouliBookConfigTrigger.Instance.instance())
.rewards(AdvancementRewards.Builder.loot(LootTableGenerator.GRANT_PATCHOULI_BOOK))
.save(saver, ResourceLocation.fromNamespaceAndPath(TouhouLittleMaid.MOD_ID, "grant_patchouli_book"), helper);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public static void gatherData(GatherDataEvent event) {
generator.addProvider(event.includeServer(), new LootTableProvider(pack,
Set.of(
LootTableGenerator.ADDITIONAL_LOOT_TABLE,
LootTableGenerator.GIVE_SMART_SLAB,
LootTableGenerator.GRANT_PATCHOULI_BOOK
LootTableGenerator.GIVE_SMART_SLAB
),
List.of(
new LootTableProvider.SubProviderEntry(LootTableGenerator.ChestLootTables::new, LootContextParamSets.CHEST),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.functions.SetComponentsFunction;
import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import vazkii.patchouli.common.item.PatchouliDataComponents;
import vazkii.patchouli.common.item.PatchouliItems;

import java.util.HashSet;
import java.util.Set;
Expand All @@ -31,7 +28,6 @@
public class LootTableGenerator {
public static final ResourceKey<LootTable> ADDITIONAL_LOOT_TABLE = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.fromNamespaceAndPath(TouhouLittleMaid.MOD_ID, "chests/additional_loot_table"));
public static final ResourceKey<LootTable> GIVE_SMART_SLAB = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.fromNamespaceAndPath(TouhouLittleMaid.MOD_ID, "give_smart_slab"));
public static final ResourceKey<LootTable> GRANT_PATCHOULI_BOOK = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.fromNamespaceAndPath(TouhouLittleMaid.MOD_ID, "grant_patchouli_book"));

public record ChestLootTables(HolderLookup.Provider provider) implements LootTableSubProvider {
@Override
Expand All @@ -57,12 +53,6 @@ public void generate(BiConsumer<ResourceKey<LootTable>, LootTable.Builder> consu
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(InitItems.SMART_SLAB_INIT))));

consumer.accept(GRANT_PATCHOULI_BOOK, LootTable.lootTable()
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(PatchouliItems.BOOK)
.apply(SetComponentsFunction.setComponent(PatchouliDataComponents.BOOK, InitItems.MEMORIZABLE_GENSOKYO_LOCATION)))));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.tartaricacid.touhoulittlemaid.init.InitDataComponent;
import com.github.tartaricacid.touhoulittlemaid.init.InitEntities;
import com.github.tartaricacid.touhoulittlemaid.init.InitItems;
import com.github.tartaricacid.touhoulittlemaid.init.registry.CompatRegistry;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.*;
Expand All @@ -12,6 +13,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.common.conditions.ModLoadedCondition;
import vazkii.patchouli.common.item.PatchouliDataComponents;
import vazkii.patchouli.common.item.PatchouliItems;

Expand Down Expand Up @@ -335,14 +337,15 @@ protected void buildRecipes(RecipeOutput recipeOutput) {
.unlockedBy(getHasName(Items.DIAMOND), has(Tags.Items.GEMS_DIAMOND))
.save(recipeOutput);

ModLoadedCondition modLoadedCondition = new ModLoadedCondition(CompatRegistry.PATCHOULI);
ItemStack patchouliBook = new ItemStack(PatchouliItems.BOOK);
patchouliBook.set(PatchouliDataComponents.BOOK, InitItems.MEMORIZABLE_GENSOKYO_LOCATION);
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, patchouliBook)
.requires(Tags.Items.DYES_WHITE)
.requires(Tags.Items.DYES_RED)
.requires(Items.BOOK)
.unlockedBy(getHasName(Items.BOOK), has(Items.BOOK))
.save(recipeOutput, InitItems.MEMORIZABLE_GENSOKYO_LOCATION);
.save(recipeOutput.withConditions(modLoadedCondition), InitItems.MEMORIZABLE_GENSOKYO_LOCATION);

ShapedRecipeBuilder.shaped(RecipeCategory.MISC, InitItems.CHAIR)
.pattern(" ")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"neoforge:conditions": [
{
"type": "neoforge:mod_loaded",
"modid": "patchouli"
}
],
"criteria": {
"tick": {
"trigger": "touhou_little_maid:give_patchouli_book_config"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"neoforge:conditions": [
{
"type": "neoforge:mod_loaded",
"modid": "patchouli"
}
],
"type": "minecraft:advancement_reward",
"pools": [
{
Expand Down

0 comments on commit 05a2a11

Please sign in to comment.