Skip to content

Commit

Permalink
Overhaul Mineral Veins (#5902)
Browse files Browse the repository at this point in the history
* Overhaul vein infrastructure to work with biome tags

* Adjust datagen to match

* Change text generation for the manual page on mineral veins

* Reorder data-creation for mineral veins

No changes to content

* Add new mineral vein: Banded Iron

* Add new mineral vein: Lazulitic Intrusion

* Add new mineral vein: Alluvial Sift

* Rebalance a variety of veins to make them more usable, including more ores and less sulfur

* Drop old todo note

* Update Pentandite to be rich in nickel and include platinum and osmium if present. Drop Cooperite as it was the old platinum vein

* Update Wolframite to be more focused on tungsten and include tin if present. Drop Cassiterite as a result.

* Fix biome condition for Beryl

* Add biome tags for specific IE veins

* Limit Silt, Claypan and Seabed to specific biomes

* Add manual documentation for biome tags

* Remove gravel from silt veins, instead increasing it in the spoils

* Remove dimension keys, they are no longer needed

* Allow survey tools to be used more easily in the nether

* Simplify codec for BiomeTagPredicates

* Change ancient seabed to use is_beach tag

* Change localization for biome tags

* Change datagen for minerals to allow varargs

* Add a forge-namespace tag for swamps

* Put Silt in swamps and oceans as well

* Add Rich Auricupride in mesa biomes, reduce gold content in normal Auricupride

* Fix datagen after rebase
  • Loading branch information
BluSunrize committed Apr 1, 2024
1 parent 5146778 commit f49f7d5
Show file tree
Hide file tree
Showing 40 changed files with 764 additions and 333 deletions.
5 changes: 5 additions & 0 deletions src/api/java/blusunrize/immersiveengineering/api/IETags.java
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
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()));
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
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);
}
}
}
@@ -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);
}


@Nonnull
@Override
public String getName()
{
return "IE biome tags";
}
}
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

0 comments on commit f49f7d5

Please sign in to comment.