Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/org/hiedacamellia/whispergrove/core/data/Data.java
#	src/main/java/org/hiedacamellia/whispergrove/core/data/provider/ModelProvider.java
#	src/main/java/org/hiedacamellia/whispergrove/core/data/provider/WGRecipeProvider.java
#	src/main/java/org/hiedacamellia/whispergrove/registers/WGItem.java
  • Loading branch information
Glyceryl6 committed Aug 21, 2024
2 parents b4d9e78 + 1c08789 commit d448b02
Show file tree
Hide file tree
Showing 19 changed files with 290 additions and 73 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/hiedacamellia/whispergrove/core/data/Data.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package org.hiedacamellia.whispergrove.core.data;

import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.data.event.GatherDataEvent;
import org.hiedacamellia.whispergrove.WhisperGrove;
import org.hiedacamellia.whispergrove.core.data.lang.ChineseLanguageProvider;
import org.hiedacamellia.whispergrove.core.data.lang.ClassicalChineseLanguageProvider;
import org.hiedacamellia.whispergrove.core.data.lang.EnglishLanguageProvider;
import org.hiedacamellia.whispergrove.core.data.provider.WGItemModelProvider;
import org.hiedacamellia.whispergrove.core.data.provider.WGBlockStateProvider;
import org.hiedacamellia.whispergrove.core.data.provider.WGLootTableProvider;
import org.hiedacamellia.whispergrove.core.data.provider.WGRecipeProvider;

@EventBusSubscriber(modid = WhisperGrove.MODID, bus = EventBusSubscriber.Bus.MOD)
Expand All @@ -19,12 +17,14 @@ 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 WGItemModelProvider(packOutput, helper));
gen.addProvider(event.includeClient(), new WGBlockStateProvider(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 @@ -108,6 +108,14 @@ protected void addTranslations() {
add("tooltip.whispergrove.sliced_long_dan_cao","");
add("item.whispergrove.mo_yu_gu","墨鱼骨");
add("tooltip.whispergrove.mo_yu_gu","");
add("item.whispergrove.shu_fu_pian","熟附片");
add("tooltip.whispergrove.shu_fu_pian","");
add("item.whispergrove.bone_fragment","骨头碎片");
add("tooltip.whispergrove.bone_fragment","");

add("item.whispergrove.roller","药碾");
add("tooltip.whispergrove.roller","");


add("block.whispergrove.rou_gui_log","肉桂原木");
add("tooltip.whispergrove.rou_gui_log","");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,25 @@ protected void addTranslations() {
add("tooltip.whispergrove.sliced_long_dan_cao","");
add("item.whispergrove.mo_yu_gu","Cuttleflsh Bone");
add("tooltip.whispergrove.mo_yu_gu","");
add("item.whispergrove.shu_fu_pian","Roasted Prepared Common Monkshood Daughter Root");
add("tooltip.whispergrove.shu_fu_pian","");
add("item.whispergrove.bone_fragment","Bone Fragment");
add("tooltip.whispergrove.bone_fragment","");

add("item.whispergrove.roller","roller");
add("tooltip.whispergrove.roller","");

add("block.whispergrove.rou_gui_log","肉桂 Log");
add("block.whispergrove.rou_gui_log","Cinnamon Log");
add("tooltip.whispergrove.rou_gui_log","");
add("block.whispergrove.rou_gui_stripped_log","Stripped 肉桂 Log");
add("block.whispergrove.rou_gui_stripped_log","Stripped Cinnamon Log");
add("tooltip.whispergrove.rou_gui_stripped_log","");
add("block.whispergrove.rou_gui_leaves","肉桂 Leaves");
add("block.whispergrove.rou_gui_leaves","Cinnamon Leaves");
add("tooltip.whispergrove.rou_gui_leaves","");
add("block.whispergrove.rou_gui_planks","肉桂 Blank");
add("block.whispergrove.rou_gui_planks","Cinnamon Blank");
add("tooltip.whispergrove.rou_gui_planks","");
add("block.whispergrove.rou_gui_slab","肉桂 Slab");
add("block.whispergrove.rou_gui_slab","Cinnamon Slab");
add("tooltip.whispergrove.rou_gui_slab","");
add("block.whispergrove.rou_gui_stair","肉桂 Stair");
add("block.whispergrove.rou_gui_stair","Cinnamon Stair");
add("tooltip.whispergrove.rou_gui_stair","");

add("block.whispergrove.springing","Springing");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.hiedacamellia.whispergrove.core.data.provider;

import com.google.common.collect.Iterables;
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.EntityLootSubProvider;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.util.ProblemReporter;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
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 net.neoforged.neoforge.registries.DeferredHolder;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

import static org.hiedacamellia.whispergrove.registers.WGBlock.*;

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() {
this.dropSelf(RouGuiLog.get());
this.dropSelf(RouGuiStrippedLog.get());
this.dropSelf(RouGuiPlanks.get());
this.dropSelf(RouGuiSlab.get());
this.dropSelf(RouGuiLeaves.get());
this.dropSelf(RouGuiStair.get());
this.dropSelf(Roller.get());
}

@Nonnull
@Override
protected Iterable<Block> getKnownBlocks() {
// 模组自定义的方块战利品表必须覆盖此方法,以绕过对原版方块战利品表的检查(此处返回该模组的所有方块)
return Iterables.transform(BLOCKS.getEntries(), DeferredHolder::get);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void buildRecipes(RecipeOutput output) {
SimpleCookingRecipeBuilder.smelting(
Ingredient.of(Items.LILAC),//输入
RecipeCategory.MISC,//配方类型
new ItemStack((Holder<Item>) CLOVE),//产物,也可以是ItemStack
new ItemStack((Holder<Item>) CHAO_DING_XIANG),//产物,也可以是ItemStack
0.1f,//经验值
100//烹饪时间
)
Expand Down
Loading

0 comments on commit d448b02

Please sign in to comment.