From 35631f0ff3e7bf5052f5f092ed3ce0e1d3ea52f0 Mon Sep 17 00:00:00 2001 From: glyceryl <494192175@qq.com> Date: Wed, 9 Oct 2024 17:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E5=9C=B0?= =?UTF-8?q?=E7=89=A9=E7=9B=B8=E5=85=B3=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/provider/WGDataPackProvider.java | 61 ++++++------------- .../data/provider/WGItemModelProvider.java | 7 ++- .../registers/WGBiomeModifier.java | 15 ++--- .../whispergrove/registers/WGFeature.java | 61 +++++++------------ 4 files changed, 55 insertions(+), 89 deletions(-) diff --git a/src/main/java/org/hiedacamellia/whispergrove/core/data/provider/WGDataPackProvider.java b/src/main/java/org/hiedacamellia/whispergrove/core/data/provider/WGDataPackProvider.java index a4aa0b7..7ef7f38 100644 --- a/src/main/java/org/hiedacamellia/whispergrove/core/data/provider/WGDataPackProvider.java +++ b/src/main/java/org/hiedacamellia/whispergrove/core/data/provider/WGDataPackProvider.java @@ -22,48 +22,25 @@ import java.util.concurrent.CompletableFuture; public class WGDataPackProvider extends DatapackBuiltinEntriesProvider { - public WGDataPackProvider(PackOutput output,CompletableFuture lookupProvider) { - super(output, - lookupProvider, - new RegistrySetBuilder() - .add(Registries.CONFIGURED_FEATURE, bootstrap -> { - bootstrap.register( - WGFeature.CASSIA_TREE_KEY, - WGFeature.CASSIA_TREE - ); - bootstrap.register( - WGFeature.WG_MED_KEY, - WGFeature.WG_MED - ); - }).add(Registries.PLACED_FEATURE, bootstrap -> { - bootstrap.register( - WGFeature.CASSIA_TREE_PLACED_KEY, - WGFeature.CASSIA_TREE_PLACED - ); - bootstrap.register( - WGFeature.WG_MED_PLACED_KEY, - WGFeature.WG_MED_PLACED - ); - }).add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { - HolderGetter biomes = bootstrap.lookup(Registries.BIOME); - HolderGetter placedFeatures = bootstrap.lookup(Registries.PLACED_FEATURE); - bootstrap.register(WGBiomeModifier.CASSIA_TREE, - new BiomeModifiers.AddFeaturesBiomeModifier( - HolderSet.direct(List.of(biomes.getOrThrow(Biomes.DARK_FOREST),biomes.getOrThrow(Biomes.FOREST),biomes.getOrThrow(Biomes.BIRCH_FOREST))), - HolderSet.direct(placedFeatures.getOrThrow(WGFeature.CASSIA_TREE_PLACED_KEY)), - GenerationStep.Decoration.SURFACE_STRUCTURES - ) - ); -// bootstrap.register(WGBiomeModifier.WG_MED, -// new BiomeModifiers.AddFeaturesBiomeModifier( -// HolderSet.direct(List.of(biomes.getOrThrow(Biomes.DARK_FOREST),biomes.getOrThrow(Biomes.FOREST),biomes.getOrThrow(Biomes.BIRCH_FOREST))), -// HolderSet.direct(placedFeatures.getOrThrow(WGFeature.WG_MED_PLACED_KEY)), -// GenerationStep.Decoration.VEGETAL_DECORATION -// ) -// ); - }), - Set.of(WhisperGrove.MODID)); + public WGDataPackProvider(PackOutput output,CompletableFuture lookupProvider) { + super(output, lookupProvider, new RegistrySetBuilder() + .add(Registries.CONFIGURED_FEATURE, bootstrap -> { + bootstrap.register(WGFeature.CASSIA_TREE_KEY, WGFeature.CASSIA_TREE); + bootstrap.register(WGFeature.WG_MED_KEY, WGFeature.WG_MED); + }).add(Registries.PLACED_FEATURE, bootstrap -> { + bootstrap.register(WGFeature.CASSIA_TREE_PLACED_KEY, WGFeature.CASSIA_TREE_PLACED); + bootstrap.register(WGFeature.WG_MED_PLACED_KEY, WGFeature.WG_MED_PLACED); + }).add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { + HolderGetter biomes = bootstrap.lookup(Registries.BIOME); + HolderGetter placedFeatures = bootstrap.lookup(Registries.PLACED_FEATURE); + bootstrap.register(WGBiomeModifier.CASSIA_TREE, new BiomeModifiers.AddFeaturesBiomeModifier( + HolderSet.direct(List.of(biomes.getOrThrow(Biomes.DARK_FOREST), biomes.getOrThrow(Biomes.FOREST), biomes.getOrThrow(Biomes.BIRCH_FOREST))), + HolderSet.direct(placedFeatures.getOrThrow(WGFeature.CASSIA_TREE_PLACED_KEY)), GenerationStep.Decoration.SURFACE_STRUCTURES)); + bootstrap.register(WGBiomeModifier.WG_MED, new BiomeModifiers.AddFeaturesBiomeModifier( + HolderSet.direct(List.of(biomes.getOrThrow(Biomes.DARK_FOREST), biomes.getOrThrow(Biomes.FOREST), biomes.getOrThrow(Biomes.BIRCH_FOREST))), + HolderSet.direct(placedFeatures.getOrThrow(WGFeature.WG_MED_PLACED_KEY)), GenerationStep.Decoration.VEGETAL_DECORATION)); + }), Set.of(WhisperGrove.MODID)); } -} +} \ No newline at end of file diff --git a/src/main/java/org/hiedacamellia/whispergrove/core/data/provider/WGItemModelProvider.java b/src/main/java/org/hiedacamellia/whispergrove/core/data/provider/WGItemModelProvider.java index 6271b5e..768f72e 100644 --- a/src/main/java/org/hiedacamellia/whispergrove/core/data/provider/WGItemModelProvider.java +++ b/src/main/java/org/hiedacamellia/whispergrove/core/data/provider/WGItemModelProvider.java @@ -2,6 +2,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; +import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.neoforged.neoforge.client.model.generators.ItemModelProvider; import net.neoforged.neoforge.common.data.ExistingFileHelper; @@ -20,8 +21,10 @@ public WGItemModelProvider(PackOutput output, ExistingFileHelper helper) { @Override protected void registerModels() { getKnownItems().forEach(item -> { - String path = BuiltInRegistries.ITEM.getKey(item).getPath(); - this.singleTexture(path, this.mcLoc("item/generated"), "layer0", this.modLoc("item/" + path)); + if (!(item instanceof BlockItem)) { + String path = BuiltInRegistries.ITEM.getKey(item).getPath(); + this.singleTexture(path, this.mcLoc("item/generated"), "layer0", this.modLoc("item/" + path)); + } }); } diff --git a/src/main/java/org/hiedacamellia/whispergrove/registers/WGBiomeModifier.java b/src/main/java/org/hiedacamellia/whispergrove/registers/WGBiomeModifier.java index 621f60e..5e9fb4b 100644 --- a/src/main/java/org/hiedacamellia/whispergrove/registers/WGBiomeModifier.java +++ b/src/main/java/org/hiedacamellia/whispergrove/registers/WGBiomeModifier.java @@ -6,12 +6,13 @@ import org.hiedacamellia.whispergrove.WhisperGrove; public class WGBiomeModifier { + public static final ResourceKey CASSIA_TREE = ResourceKey.create( - NeoForgeRegistries.Keys.BIOME_MODIFIERS, // The registry this key is for - WhisperGrove.prefix("cassia_tree") // The registry name - ); + NeoForgeRegistries.Keys.BIOME_MODIFIERS, + WhisperGrove.prefix("cassia_tree")); + public static final ResourceKey WG_MED = ResourceKey.create( - NeoForgeRegistries.Keys.BIOME_MODIFIERS, // The registry this key is for - WhisperGrove.prefix("wg_med") // The registry name - ); -} + NeoForgeRegistries.Keys.BIOME_MODIFIERS, + WhisperGrove.prefix("wg_med")); + +} \ No newline at end of file diff --git a/src/main/java/org/hiedacamellia/whispergrove/registers/WGFeature.java b/src/main/java/org/hiedacamellia/whispergrove/registers/WGFeature.java index a70a5e6..8f4a2e7 100644 --- a/src/main/java/org/hiedacamellia/whispergrove/registers/WGFeature.java +++ b/src/main/java/org/hiedacamellia/whispergrove/registers/WGFeature.java @@ -37,52 +37,37 @@ public class WGFeature { new TwoLayersFeatureSize(1, 0, 2) ).forceDirt().build()); - public static final ResourceKey CASSIA_TREE_PLACED_KEY = ResourceKey.create( - Registries.PLACED_FEATURE, - WhisperGrove.prefix("cassia_tree") - ); + public static final ResourceKey CASSIA_TREE_PLACED_KEY = ResourceKey.create(Registries.PLACED_FEATURE, WhisperGrove.prefix("cassia_tree")); public static final PlacedFeature CASSIA_TREE_PLACED = new PlacedFeature(Holder.direct(CASSIA_TREE), List.of(HeightmapPlacement.onHeightmap(Heightmap.Types.OCEAN_FLOOR), - InSquarePlacement.spread(), - CountPlacement.of(1), - BiomeFilter.biome(), + InSquarePlacement.spread(), CountPlacement.of(1), BiomeFilter.biome(), SurfaceWaterDepthFilter.forMaxDepth(0), - PlacementUtils.filteredByBlockSurvival(Blocks.BIRCH_SAPLING) - )); + PlacementUtils.filteredByBlockSurvival(Blocks.BIRCH_SAPLING))); - public static final ResourceKey> WG_MED_KEY = ResourceKey.create( - Registries.CONFIGURED_FEATURE, - WhisperGrove.prefix("wg_med") - ); + public static final ResourceKey> WG_MED_KEY = ResourceKey.create(Registries.CONFIGURED_FEATURE, WhisperGrove.prefix("wg_med")); - public static final ConfiguredFeature> WG_MED = new ConfiguredFeature<>(Feature.FLOWER,new RandomPatchConfiguration( - 64, 6, 2, - PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK, - new SimpleBlockConfiguration( - new NoiseThresholdProvider(2345L, - new NormalNoise.NoiseParameters(0, 1.0), 0.005F, -0.8F, 0.33333334F, - Blocks.DANDELION.defaultBlockState(), - List.of( - WGBlock.CROP_BLOCKS.get("rehmannia").get().defaultBlockState(), - WGBlock.CROP_BLOCKS.get("licorice").get().defaultBlockState(), - WGBlock.CROP_BLOCKS.get("milkvetch").get().defaultBlockState(), - WGBlock.CROP_BLOCKS.get("gentian").get().defaultBlockState(), - WGBlock.CROP_BLOCKS.get("ginseng").get().defaultBlockState() - ), List.of()))) - )); - public static final ResourceKey WG_MED_PLACED_KEY = ResourceKey.create( - Registries.PLACED_FEATURE, - WhisperGrove.prefix("wg_med") - ); + public static final ConfiguredFeature> WG_MED = new ConfiguredFeature<>(Feature.FLOWER, new RandomPatchConfiguration( + 64, 6, 2, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(new NoiseThresholdProvider(496156461L, + new NormalNoise.NoiseParameters(0, 1.0), 0.005F, -0.8F, 0.33333334F, Blocks.DANDELION.defaultBlockState(), + List.of(WGBlock.CROP_BLOCKS.get("rehmannia").get().defaultBlockState(), + WGBlock.CROP_BLOCKS.get("licorice").get().defaultBlockState(), + WGBlock.CROP_BLOCKS.get("milkvetch").get().defaultBlockState(), + WGBlock.CROP_BLOCKS.get("gentian").get().defaultBlockState(), + WGBlock.CROP_BLOCKS.get("ginseng").get().defaultBlockState()), + List.of(WGBlock.CROP_BLOCKS.get("rehmannia").get().defaultBlockState(), + WGBlock.CROP_BLOCKS.get("licorice").get().defaultBlockState(), + WGBlock.CROP_BLOCKS.get("milkvetch").get().defaultBlockState(), + WGBlock.CROP_BLOCKS.get("gentian").get().defaultBlockState(), + WGBlock.CROP_BLOCKS.get("ginseng").get().defaultBlockState())))))); + + public static final ResourceKey WG_MED_PLACED_KEY = ResourceKey.create(Registries.PLACED_FEATURE, WhisperGrove.prefix("wg_med")); public static final PlacedFeature WG_MED_PLACED = new PlacedFeature(Holder.direct(WG_MED), List.of(HeightmapPlacement.onHeightmap(Heightmap.Types.WORLD_SURFACE), - InSquarePlacement.spread(), - CountPlacement.of(1), - BiomeFilter.biome(), + InSquarePlacement.spread(), CountPlacement.of(1), BiomeFilter.biome(), SurfaceWaterDepthFilter.forMaxDepth(0), PlacementUtils.filteredByBlockSurvival(Blocks.BIRCH_SAPLING), - RarityFilter.onAverageOnceEvery(10) - )); -} + RarityFilter.onAverageOnceEvery(10))); + +} \ No newline at end of file