Skip to content

Commit

Permalink
修复一个地物相关的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
Glyceryl6 committed Oct 9, 2024
1 parent e84d8b4 commit c6973d7
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,25 @@
import java.util.concurrent.CompletableFuture;

public class WGDataPackProvider extends DatapackBuiltinEntriesProvider {
public WGDataPackProvider(PackOutput output,CompletableFuture<HolderLookup.Provider> 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<Biome> biomes = bootstrap.lookup(Registries.BIOME);
HolderGetter<PlacedFeature> 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<HolderLookup.Provider> 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<Biome> biomes = bootstrap.lookup(Registries.BIOME);
HolderGetter<PlacedFeature> 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));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import org.hiedacamellia.whispergrove.WhisperGrove;

public class WGBiomeModifier {

public static final ResourceKey<BiomeModifier> 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<BiomeModifier> 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"));

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,52 +37,37 @@ public class WGFeature {
new TwoLayersFeatureSize(1, 0, 2)
).forceDirt().build());

public static final ResourceKey<PlacedFeature> CASSIA_TREE_PLACED_KEY = ResourceKey.create(
Registries.PLACED_FEATURE,
WhisperGrove.prefix("cassia_tree")
);
public static final ResourceKey<PlacedFeature> 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<ConfiguredFeature<?,?>> WG_MED_KEY = ResourceKey.create(
Registries.CONFIGURED_FEATURE,
WhisperGrove.prefix("wg_med")
);
public static final ResourceKey<ConfiguredFeature<?, ?>> WG_MED_KEY = ResourceKey.create(Registries.CONFIGURED_FEATURE, WhisperGrove.prefix("wg_med"));

public static final ConfiguredFeature<RandomPatchConfiguration, Feature<RandomPatchConfiguration>> 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<PlacedFeature> WG_MED_PLACED_KEY = ResourceKey.create(
Registries.PLACED_FEATURE,
WhisperGrove.prefix("wg_med")
);
public static final ConfiguredFeature<RandomPatchConfiguration, Feature<RandomPatchConfiguration>> 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<PlacedFeature> 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)));

}

0 comments on commit c6973d7

Please sign in to comment.