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

Overhaul Mineral Veins #5902

Merged
merged 26 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
58d29a6
Overhaul vein infrastructure to work with biome tags
BluSunrize Mar 29, 2024
579b7f6
Adjust datagen to match
BluSunrize Mar 29, 2024
e4aa1c9
Change text generation for the manual page on mineral veins
BluSunrize Mar 29, 2024
d3d11dd
Reorder data-creation for mineral veins
BluSunrize Mar 29, 2024
8cba02d
Add new mineral vein: Banded Iron
BluSunrize Mar 29, 2024
600cd13
Add new mineral vein: Lazulitic Intrusion
BluSunrize Mar 29, 2024
3909b8f
Add new mineral vein: Alluvial Sift
BluSunrize Mar 29, 2024
1229e35
Rebalance a variety of veins to make them more usable, including more…
BluSunrize Mar 29, 2024
7515036
Drop old todo note
BluSunrize Mar 29, 2024
2184f54
Update Pentandite to be rich in nickel and include platinum and osmiu…
BluSunrize Mar 29, 2024
76c9898
Update Wolframite to be more focused on tungsten and include tin if p…
BluSunrize Mar 29, 2024
f176b2c
Fix biome condition for Beryl
BluSunrize Mar 29, 2024
9ae8af9
Add biome tags for specific IE veins
BluSunrize Mar 29, 2024
49c8917
Limit Silt, Claypan and Seabed to specific biomes
BluSunrize Mar 29, 2024
be6373a
Add manual documentation for biome tags
BluSunrize Mar 29, 2024
176d092
Remove gravel from silt veins, instead increasing it in the spoils
BluSunrize Mar 29, 2024
cb0d334
Remove dimension keys, they are no longer needed
BluSunrize Mar 29, 2024
58244ee
Allow survey tools to be used more easily in the nether
BluSunrize Mar 29, 2024
1c14a24
Simplify codec for BiomeTagPredicates
BluSunrize Mar 31, 2024
b6ca341
Change ancient seabed to use is_beach tag
BluSunrize Mar 31, 2024
b883341
Change localization for biome tags
BluSunrize Mar 31, 2024
cdee55e
Change datagen for minerals to allow varargs
BluSunrize Mar 31, 2024
243bc09
Add a forge-namespace tag for swamps
BluSunrize Mar 31, 2024
834ed62
Put Silt in swamps and oceans as well
BluSunrize Mar 31, 2024
b3ea4b3
Add Rich Auricupride in mesa biomes, reduce gold content in normal Au…
BluSunrize Mar 31, 2024
2f44dae
Fix datagen after rebase
BluSunrize Apr 1, 2024
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
5 changes: 5 additions & 0 deletions src/api/java/blusunrize/immersiveengineering/api/IETags.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.material.Fluid;
import net.neoforged.neoforge.common.Tags.Blocks;
Expand Down Expand Up @@ -150,6 +151,10 @@ public class IETags
public static final TagKey<EntityType<?>> shaderbagWhitelist = createEntityWrapper(rl("shaderbag/whitelist"));
public static final TagKey<EntityType<?>> shaderbagBlacklist = createEntityWrapper(rl("shaderbag/blacklist"));

public static final TagKey<Biome> is_swamp = createBiomeWrapper(forgeLoc("is_swamp"));
public static final TagKey<Biome> generateClaypan = createBiomeWrapper(rl("generate_hardened_clay_pan"));
public static final TagKey<Biome> generateSeabed = createBiomeWrapper(rl("generate_ancient_seabed"));

static
{
for(EnumMetals m : EnumMetals.values())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
import com.google.common.collect.Multimap;
import com.mojang.datafixers.util.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ColumnPos;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeManager;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.synth.PerlinSimplexNoise;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -130,7 +135,7 @@ public static List<MineralVein> findVeinsForVillager(
return foundVeins;
}

public static void generatePotentialVein(Level world, ChunkPos chunkpos, RandomSource rand)
public static void generatePotentialVein(Level world, WorldGenLevel worldGenLevel, ChunkPos chunkpos, RandomSource rand)
{
int xStart = chunkpos.getMinBlockX();
int zStart = chunkpos.getMinBlockZ();
Expand Down Expand Up @@ -168,7 +173,12 @@ public static void generatePotentialVein(Level world, ChunkPos chunkpos, RandomS
if(!crossover)
{
RecipeHolder<MineralMix> mineralMix = null;
MineralSelection selection = new MineralSelection(world);
Set<Holder<Biome>> biomes = new HashSet<>();
BiomeManager biomeManager = worldGenLevel.getBiomeManager();
int surfaceHeight = worldGenLevel.getHeight(Types.WORLD_SURFACE_WG, finalPos.x(), finalPos.z());
for(int i = worldGenLevel.getMinBuildHeight(); i <= surfaceHeight; i++)
biomes.add(biomeManager.getNoiseBiomeAtPosition(pos.x(), i, pos.z()));
BluSunrize marked this conversation as resolved.
Show resolved Hide resolved
MineralSelection selection = new MineralSelection(world, biomes);
if(selection.getTotalWeight() > 0)
{
int weight = selection.getRandomWeight(rand);
Expand Down Expand Up @@ -222,12 +232,12 @@ public static class MineralSelection
private final int totalWeight;
private final Set<RecipeHolder<MineralMix>> validMinerals;

public MineralSelection(Level dimension)
public MineralSelection(Level world, Set<Holder<Biome>> biomes)
{
int weight = 0;
this.validMinerals = new HashSet<>();
for(RecipeHolder<MineralMix> e : MineralMix.RECIPES.getRecipes(dimension))
if(e.value().validDimension(dimension.dimensionTypeId()))
for(RecipeHolder<MineralMix> e : MineralMix.RECIPES.getRecipes(world))
if(biomes.stream().anyMatch(biome -> e.value().validBiome(biome)))
{
validMinerals.add(e);
weight += e.value().weight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@
import blusunrize.immersiveengineering.api.crafting.*;
import blusunrize.immersiveengineering.api.crafting.cache.CachedRecipeList;
import com.google.common.collect.ImmutableSet;
import net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.dimension.DimensionType;
import net.neoforged.neoforge.registries.DeferredHolder;

import java.util.Collection;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.function.Predicate;

public class MineralMix extends IESerializableRecipe
{
Expand All @@ -36,18 +39,18 @@ public class MineralMix extends IESerializableRecipe
public final List<StackWithChance> spoils;
public final int weight;
public final float failChance;
public final ImmutableSet<ResourceKey<DimensionType>> dimensions;
public final ImmutableSet<BiomeTagPredicate> biomeTagPredicates;
public final Block background;

public MineralMix(List<StackWithChance> outputs, List<StackWithChance> spoils, int weight,
float failChance, List<ResourceKey<DimensionType>> dimensions, Block background)
float failChance, Collection<BiomeTagPredicate> biomeTagPredicates, Block background)
{
super(TagOutput.EMPTY, IERecipeTypes.MINERAL_MIX);
this.weight = weight;
this.failChance = failChance;
this.outputs = outputs;
this.spoils = spoils;
this.dimensions = ImmutableSet.copyOf(dimensions);
this.biomeTagPredicates = ImmutableSet.copyOf(biomeTagPredicates);
this.background = background;
}

Expand Down Expand Up @@ -100,10 +103,30 @@ public ItemStack getRandomSpoil(Random rand)
return ItemStack.EMPTY;
}

public boolean validDimension(ResourceKey<DimensionType> dim)
public boolean validBiome(Holder<Biome> biome)
{
if(dimensions!=null&&!dimensions.isEmpty())
return dimensions.contains(dim);
return true;
if(biomeTagPredicates.isEmpty())
return true;
return biomeTagPredicates.stream().allMatch(
predicate -> predicate.test(biome)
);
}

/**
* A predicate for checking a biome against multiple tags.
* Returns true if ANY of the tags match.
*/
public record BiomeTagPredicate(Set<TagKey<Biome>> tags) implements Predicate<Holder<Biome>>
{
public BiomeTagPredicate(TagKey<Biome> singular)
{
this(ImmutableSet.of(singular));
}

@Override
public boolean test(Holder<Biome> biomeHolder)
{
return this.tags().stream().anyMatch(biomeHolder::is);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* BluSunrize
* Copyright (c) 2022
*
* This code is licensed under "Blu's License of Common Sense"
* Details can be found in the license file in the root folder of this project
*
*/

package blusunrize.immersiveengineering.data;

import blusunrize.immersiveengineering.api.IETags;
import blusunrize.immersiveengineering.api.Lib;
import net.minecraft.core.HolderLookup.Provider;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.BiomeTagsProvider;
import net.minecraft.world.level.biome.Biomes;
import net.neoforged.neoforge.common.data.ExistingFileHelper;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.concurrent.CompletableFuture;

public class BiomeTags extends BiomeTagsProvider
{

public BiomeTags(PackOutput output, CompletableFuture<Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper)
{
super(output, lookupProvider, Lib.MODID, existingFileHelper);
}

@Override
protected void addTags(Provider p_255894_)
{
// swamps
tag(IETags.is_swamp)
.add(Biomes.SWAMP)
.add(Biomes.MANGROVE_SWAMP);
// deserts, plains, mesas, savannas, ice plains
tag(IETags.generateClaypan)
.add(Biomes.DESERT)
.add(Biomes.PLAINS)
.add(Biomes.SUNFLOWER_PLAINS)
.add(Biomes.BADLANDS)
.add(Biomes.SAVANNA)
.add(Biomes.SNOWY_PLAINS);
// swamps, beaches, coral reefs, stony shore
tag(IETags.generateSeabed)
.addTag(IETags.is_swamp)
.addTag(net.minecraft.tags.BiomeTags.IS_BEACH)
.add(Biomes.WARM_OCEAN)
.add(Biomes.STONY_SHORE);
BluSunrize marked this conversation as resolved.
Show resolved Hide resolved
}


@Nonnull
@Override
public String getName()
{
return "IE biome tags";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static void gatherData(GatherDataEvent event)
gen.addProvider(true, new BannerTags(output, lookup, exHelper));
gen.addProvider(true, new PoiTags(output, lookup, exHelper));
gen.addProvider(true, new EntityTypeTags(output, lookup, exHelper));
gen.addProvider(true, new BiomeTags(output, lookup, exHelper));
gen.addProvider(true, new RootRecipeProvider(output));
gen.addProvider(true, new AllLoot(output));
gen.addProvider(true, new BlockStates(output, exHelper));
Expand Down
Loading
Loading