Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[salt]: 修复部分错误的命名,添加盐矿的生成和配方 #112

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ public class ModBlocks {
@I18n(en_us = "Baobab Wall Sign", zh_cn = "墙上的猴面包木告示牌", zh_tw = "牆上的猴麵包木告示牌", descriptionId = "block.wild_wind.baobab_wall_sign")
public static final DeferredBlock<WallSignBlock> BAOBAB_WALL_SIGN =
register("baobab_wall_sign", props -> new WallSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_WALL_SIGN).lootFrom(BAOBAB_SIGN));
@I18n(en_us = "Baobab Hanging Sign", zh_cn = "猴面包木悬挂式告示牌", zh_tw = "猴麵包木懸挂式告示牌")
@I18n(en_us = "Baobab Hanging Sign", zh_cn = "悬挂式猴面包木告示牌", zh_tw = "懸挂式猴麵包木告示牌")
public static final DeferredBlock<CeilingHangingSignBlock> BAOBAB_HANGING_SIGN =
register("baobab_hanging_sign", props -> new CeilingHangingSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_HANGING_SIGN));
@I18n(en_us = "Baobab Wall Hanging Sign", zh_cn = "墙上的猴面包木悬挂式告示牌", zh_tw = "牆上的猴麵包木懸挂式告示牌", descriptionId = "block.wild_wind.baobab_wall_hanging_sign")
@I18n(en_us = "Baobab Wall Hanging Sign", zh_cn = "墙上的悬挂式猴面包木告示牌", zh_tw = "牆上的懸挂式猴麵包木告示牌", descriptionId = "block.wild_wind.baobab_wall_hanging_sign")
public static final DeferredBlock<WallHangingSignBlock> BAOBAB_WALL_HANGING_SIGN =
register("baobab_wall_hanging_sign", props -> new WallHangingSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_WALL_HANGING_SIGN).lootFrom(BAOBAB_HANGING_SIGN));
public static final DeferredItem<BlockItem> BAOBAB_LOG_ITEM =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void addSmeltingRecipes() {
SimpleCookingRecipeBuilder smelting = smelting(Items.TERRACOTTA, RecipeCategory.BUILDING_BLOCKS, ModBlocks.GLAZED_TERRACOTTA.get(),0.35F);
add(smelting);


smeltingAndBlasting(Ingredient.of(ModBlocks.SALT_ORE_ITEM.get(), ModBlocks.DEEPSLATE_SALT_ORE_ITEM.get()), RecipeCategory.MISC, ModBaseItems.SALT.get(), 0.7F);
}

public static Criterion<InventoryChangeTrigger.TriggerInstance> has(ItemLike... likes) {
Expand Down Expand Up @@ -162,10 +162,7 @@ protected static <T extends RecipeBuilder> void unlockedBy(T t, TagKey<Item> tag
t.unlockedBy(("has" + "_" + tag.location()).toLowerCase(Locale.ROOT), has(tag));
}



protected void addShapelessRecipe() {

add(shapeless(RecipeCategory.FOOD, ModBaseFoods.FISH_CHOWDER.get(), 1, fish_chowder -> {
unlockedBy(fish_chowder, ModBaseFoods.RAW_TROUT.get(), Items.COD, Items.SALMON);
unlockedBy(fish_chowder, Items.BROWN_MUSHROOM, Items.RED_MUSHROOM);
Expand Down Expand Up @@ -302,6 +299,15 @@ public static SimpleCookingRecipeBuilder smelting(
.unlockedBy(BuiltInRegistries.ITEM.getKey(item).toString(), has(item));
}

public static SimpleCookingRecipeBuilder blasting(
Ingredient input, RecipeCategory category, ItemLike result, float exp, int cookingTime
) {
ItemStack[] items = input.getItems();
Item item = items[0].getItem();
return SimpleCookingRecipeBuilder.blasting(input, category, result, exp, cookingTime)
.unlockedBy(BuiltInRegistries.ITEM.getKey(item).toString(), has(item));
}

public static SimpleCookingRecipeBuilder smoking(
Ingredient input, RecipeCategory category, ItemLike result, float exp, int cookingTime
) {
Expand Down Expand Up @@ -346,12 +352,23 @@ public static SimpleCookingRecipeBuilder smelting(
.unlockedBy(BuiltInRegistries.ITEM.getKey(input.asItem()).toString(), has(input));
}

public static SimpleCookingRecipeBuilder blasting(
ItemLike input, RecipeCategory category, ItemLike result, float exp, int cookingTime) {
return SimpleCookingRecipeBuilder.blasting(Ingredient.of(input), category, result, exp, cookingTime)
.unlockedBy(BuiltInRegistries.ITEM.getKey(input.asItem()).toString(), has(input));
}

public static SimpleCookingRecipeBuilder smoking(
ItemLike input, RecipeCategory category, ItemLike result, float exp, int cookingTime) {
return SimpleCookingRecipeBuilder.smoking(Ingredient.of(input), category, result, exp, cookingTime)
.unlockedBy(BuiltInRegistries.ITEM.getKey(input.asItem()).toString(), has(input));
}

public void smeltingAndBlasting(Ingredient input, RecipeCategory category, ItemLike result, float exp) {
add(smelting(input, category, result, exp));
add(blasting(input, category, result, exp), "blasting/");
}

public void smeltingAndSmoking(Ingredient input, RecipeCategory category, ItemLike result, float exp) {
add(smelting(input, category, result, exp));
add(smoking(input, category, result, exp), "smoking/");
Expand All @@ -377,13 +394,26 @@ public static SimpleCookingRecipeBuilder smoking(
return smoking(input, category, result, exp, 200);
}

public static SimpleCookingRecipeBuilder blasting(
Ingredient input, RecipeCategory category, ItemLike result, float exp
) {
return blasting(input, category, result, exp, 200);
}

public void smeltingAndSmoking(
ItemLike input, RecipeCategory category, ItemLike result, float exp
) {
add(smelting(input, category, result, exp));
add(smoking(input, category, result, exp), "smoking/");
}

public void smeltingAndBlasting(
ItemLike input, RecipeCategory category, ItemLike result, float exp
) {
add(smelting(input, category, result, exp));
add(blasting(input, category, result, exp), "blasting/");
}

public void smeltingSmokingAndCampfire(ItemLike input, RecipeCategory category, ItemLike result, float exp) {
add(smelting(input, category, result, exp));
add(smoking(input, category, result, exp), "smoking/");
Expand All @@ -402,6 +432,12 @@ public static SimpleCookingRecipeBuilder smoking(
return smoking(input, category, result, exp, 200);
}

public static SimpleCookingRecipeBuilder blasting(
ItemLike input, RecipeCategory category, ItemLike result, float exp
) {
return blasting(input, category, result, exp, 200);
}

public void add(RecipeBuilder builder) {
list.put(BuiltInRegistries.ITEM.getKey(builder.getResult()), builder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

import com.google.common.collect.ImmutableSet;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.block.Block;
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.ApplyBonusCount;
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
import org.polaris2023.wild_wind.common.init.ModBlocks;
import org.polaris2023.wild_wind.common.init.ModInitializer;
import org.polaris2023.wild_wind.common.init.items.ModBaseItems;
Expand Down Expand Up @@ -40,8 +48,8 @@ public void generate() {
this.dropSelf(ModBlocks.CONCRETE.get());
this.dropSelf(ModBlocks.GLAZED_TERRACOTTA.get());
this.dropSelf(ModBlocks.SALT_BLOCK.get());
this.dropOther(ModBlocks.SALT_ORE.get(), ModBaseItems.SALT.get());
this.dropOther(ModBlocks.DEEPSLATE_SALT_ORE.get(), ModBaseItems.SALT.get());
this.add(ModBlocks.SALT_ORE.get(), this.createSaltOreDrops(ModBlocks.SALT_ORE.get()));
this.add(ModBlocks.DEEPSLATE_SALT_ORE.get(), this.createSaltOreDrops(ModBlocks.DEEPSLATE_SALT_ORE.get()));
this.dropSelf(ModBlocks.AZALEA_LOG.get());
this.dropSelf(ModBlocks.STRIPPED_AZALEA_LOG.get());
this.dropSelf(ModBlocks.AZALEA_WOOD.get());
Expand Down Expand Up @@ -70,4 +78,17 @@ public void generate() {
this.dropSelf(ModBlocks.PALM_SAPLING.get());
this.dropSelf(ModBlocks.BAOBAB_SAPLING.get());
}

protected LootTable.Builder createSaltOreDrops(Block block) {
HolderLookup.RegistryLookup<Enchantment> registrylookup = this.registries.lookupOrThrow(Registries.ENCHANTMENT);
return this.createSilkTouchDispatchTable(
block,
this.applyExplosionDecay(
block,
LootItem.lootTableItem(ModBaseItems.SALT)
.apply(SetItemCountFunction.setCount(UniformGenerator.between(4.0F, 9.0F)))
.apply(ApplyBonusCount.addOreBonusCount(registrylookup.getOrThrow(Enchantments.FORTUNE)))
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void addTags(HolderLookup.Provider provider) {
tag(BlockTags.SNOW_LAYER_CANNOT_SURVIVE_ON).add(ModBlocks.BRITTLE_ICE.get());

//Mineable
tag(BlockTags.MINEABLE_WITH_PICKAXE).add(ModBlocks.BRITTLE_ICE.get(), ModBlocks.SALT_ORE.get());
tag(BlockTags.MINEABLE_WITH_PICKAXE).add(ModBlocks.BRITTLE_ICE.get(), ModBlocks.SALT_ORE.get(), ModBlocks.DEEPSLATE_SALT_ORE.get());
tag(BlockTags.MINEABLE_WITH_AXE).add(ModBlocks.PALM_CROWN.get());

tag(ModBlockTags.AZALEA_LOGS).add(ModBlocks.AZALEA_LOG.get(), ModBlocks.AZALEA_WOOD.get(), ModBlocks.STRIPPED_AZALEA_LOG.get(), ModBlocks.STRIPPED_AZALEA_WOOD.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,34 @@
import net.minecraft.data.worldgen.BootstrapContext;
import net.minecraft.data.worldgen.features.FeatureUtils;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.DiskConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.feature.stateproviders.RuleBasedBlockStateProvider;
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest;
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest;
import org.polaris2023.wild_wind.common.init.ModBlocks;
import org.polaris2023.wild_wind.common.init.ModFeatures;
import org.polaris2023.wild_wind.util.Helpers;

import java.util.List;

public class ModConfiguredFeatureRegistry {
public static final ResourceKey<ConfiguredFeature<?, ?>> BRITTLE_ICE = ResourceKey.create(Registries.CONFIGURED_FEATURE, Helpers.location("brittle_ice"));
public static final ResourceKey<ConfiguredFeature<?, ?>> DISK_BRITTLE_ICE = ResourceKey.create(Registries.CONFIGURED_FEATURE, Helpers.location("disk_brittle_ice"));
private static final RuleTest STONE_ORE_REPLACEABLES = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES);
private static final RuleTest DEEPSLATE_ORE_REPLACEABLES = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES);

public static final ResourceKey<ConfiguredFeature<?, ?>> BRITTLE_ICE = create("brittle_ice");
public static final ResourceKey<ConfiguredFeature<?, ?>> DISK_BRITTLE_ICE = create("disk_brittle_ice");

//Ore
public static final ResourceKey<ConfiguredFeature<?, ?>> ORE_SALT = create("ore_salt");
public static final ResourceKey<ConfiguredFeature<?, ?>> ORE_SALT_BURIED = create("ore_salt_buried");

public static void bootstrap(BootstrapContext<ConfiguredFeature<?, ?>> context) {
FeatureUtils.register(context, BRITTLE_ICE, ModFeatures.BRITTLE_ICE, NoneFeatureConfiguration.NONE);
Expand All @@ -29,5 +40,17 @@ public static void bootstrap(BootstrapContext<ConfiguredFeature<?, ?>> context)
BlockPredicate.matchesBlocks(List.of(Blocks.ICE, ModBlocks.BRITTLE_ICE.get())),
UniformInt.of(4, 6), 1
));
FeatureUtils.register(context, ORE_SALT, Feature.ORE, new OreConfiguration(List.of(
OreConfiguration.target(STONE_ORE_REPLACEABLES, ModBlocks.SALT_ORE.get().defaultBlockState()),
OreConfiguration.target(DEEPSLATE_ORE_REPLACEABLES, ModBlocks.DEEPSLATE_SALT_ORE.get().defaultBlockState())
), 7));
FeatureUtils.register(context, ORE_SALT_BURIED, Feature.ORE, new OreConfiguration(List.of(
OreConfiguration.target(STONE_ORE_REPLACEABLES, ModBlocks.SALT_ORE.get().defaultBlockState()),
OreConfiguration.target(DEEPSLATE_ORE_REPLACEABLES, ModBlocks.DEEPSLATE_SALT_ORE.get().defaultBlockState())
), 7, 1.0F));
}

private static ResourceKey<ConfiguredFeature<?, ?>> create(String name) {
return ResourceKey.create(Registries.CONFIGURED_FEATURE, Helpers.location(name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
import java.util.List;

public class ModPlacedFeatureRegistry {
public static final ResourceKey<PlacedFeature> BRITTLE_ICE = ResourceKey.create(Registries.PLACED_FEATURE, Helpers.location("brittle_ice"));
public static final ResourceKey<PlacedFeature> DISK_BRITTLE_ICE = ResourceKey.create(Registries.PLACED_FEATURE, Helpers.location("disk_brittle_ice"));
public static final ResourceKey<PlacedFeature> BRITTLE_ICE = create("brittle_ice");
public static final ResourceKey<PlacedFeature> DISK_BRITTLE_ICE = create("disk_brittle_ice");

//Ore
public static final ResourceKey<PlacedFeature> ORE_SALT = create("ore_salt");
public static final ResourceKey<PlacedFeature> ORE_SALT_BURIED = create("ore_salt_buried");

public static void bootstrap(BootstrapContext<PlacedFeature> context) {
HolderGetter<ConfiguredFeature<?, ?>> configuredFeaturesLookup = context.lookup(Registries.CONFIGURED_FEATURE);
Expand All @@ -27,9 +31,21 @@ public static void bootstrap(BootstrapContext<PlacedFeature> context) {
context, DISK_BRITTLE_ICE, configuredFeaturesLookup.getOrThrow(ModConfiguredFeatureRegistry.DISK_BRITTLE_ICE),
orePlacement(CountPlacement.of(6), HeightmapPlacement.onHeightmap(Heightmap.Types.OCEAN_FLOOR_WG))
);
PlacementUtils.register(
context, ORE_SALT, configuredFeaturesLookup.getOrThrow(ModConfiguredFeatureRegistry.ORE_SALT),
orePlacement(CountPlacement.of(2), HeightRangePlacement.triangle(VerticalAnchor.absolute(-32), VerticalAnchor.absolute(32)))
);
PlacementUtils.register(
context, ORE_SALT_BURIED, configuredFeaturesLookup.getOrThrow(ModConfiguredFeatureRegistry.ORE_SALT_BURIED),
orePlacement(CountPlacement.of(2), HeightRangePlacement.uniform(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(64)))
);
}

private static List<PlacementModifier> orePlacement(PlacementModifier countPlacement, PlacementModifier heightRange) {
return List.of(countPlacement, InSquarePlacement.spread(), heightRange, BiomeFilter.biome());
}

private static ResourceKey<PlacedFeature> create(String name) {
return ResourceKey.create(Registries.PLACED_FEATURE, Helpers.location(name));
}
}
Loading