Skip to content

Commit

Permalink
写到一半的战利品表DataGen
Browse files Browse the repository at this point in the history
  • Loading branch information
HaooooZhang committed Aug 20, 2024
1 parent f52c5b4 commit ae3cc49
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
import org.hiedacamellia.whispergrove.core.data.lang.EnglishLanguageProvider;
import org.hiedacamellia.whispergrove.core.data.provider.ModelProvider;
import org.hiedacamellia.whispergrove.core.data.provider.StateProvider;
import org.hiedacamellia.whispergrove.core.data.provider.WGLootTableProvider;
import org.hiedacamellia.whispergrove.core.data.provider.WGRecipeProvider;

public class Data {
public static void onGatherData(GatherDataEvent event) {
var gen = event.getGenerator();
var packOutput = gen.getPackOutput();
var helper = event.getExistingFileHelper();
var lookupProvider = event.getLookupProvider();
gen.addProvider(event.includeClient(), new EnglishLanguageProvider(packOutput));
gen.addProvider(event.includeClient(), new ChineseLanguageProvider(packOutput));
gen.addProvider(event.includeClient(), new ClassicalChineseLanguageProvider(packOutput));
gen.addProvider(event.includeClient(), new ModelProvider(packOutput, helper));
gen.addProvider(event.includeClient(), new StateProvider(packOutput, helper));
gen.addProvider(event.includeServer(), new WGRecipeProvider(packOutput, event.getLookupProvider()));
gen.addProvider(event.includeServer(), new WGRecipeProvider(packOutput, lookupProvider));
gen.addProvider(event.includeClient(),new WGLootTableProvider(packOutput, lookupProvider));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected void registerModels() {
"sliced_ren_shen",
"sliced_long_dan_cao"
,"mo_yu_gu",
//"shu_fu_pian",
"shu_fu_pian",
"bone_fragment"
).forEach(s -> this.singleTexture(s,
ResourceLocation.withDefaultNamespace("item/generated"), "layer0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.hiedacamellia.whispergrove.core.data.provider;

import net.minecraft.core.HolderLookup;
import net.minecraft.core.WritableRegistry;
import net.minecraft.data.PackOutput;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.util.ProblemReporter;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.ValidationContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;

import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

public class WGLootTableProvider extends LootTableProvider {
public WGLootTableProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
super(output, Set.of(), List.of(new SubProviderEntry(WGBlockLoot::new, LootContextParamSets.BLOCK)), registries);
}

@Override
protected void validate(WritableRegistry<LootTable> registry, ValidationContext context, ProblemReporter.Collector collector) {
// FIXME 需要核实正确写法
// map.forEach((key, value) -> LootTables.validate(context, key, value));
}

public static class WGBlockLoot extends BlockLootSubProvider {
protected WGBlockLoot(HolderLookup.Provider lookupProvider) {
super(Set.of(), FeatureFlags.REGISTRY.allFlags(), lookupProvider);
}

@Override
protected void generate() {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ protected void buildRecipes(RecipeOutput output) {
.unlockedBy("has_iron_ingot", has(Items.IRON_INGOT))
.save(output);

//熔炉配方
SimpleCookingRecipeBuilder.smelting(
Ingredient.of(MO_YU_GU),//输入
RecipeCategory.MISC,//配方类型
Expand All @@ -65,5 +66,6 @@ protected void buildRecipes(RecipeOutput output) {
)
.unlockedBy("has_lilac", has(Items.BONE))
.save(output, "duan_long_gu_smelting");

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ae3cc49

Please sign in to comment.