Class SeasonalEnvironmentProvider<S extends Enum<S> & net.minecraft.util.StringRepresentable>
java.lang.Object
com.github.thedeathlycow.thermoo.api.environment.v2.provider.SeasonalEnvironmentProvider<S>
- All Implemented Interfaces:
EnvironmentProvider
- Direct Known Subclasses:
TemperateSeasonSelector, TropicalSeasonSelector
public abstract sealed class SeasonalEnvironmentProvider<S extends Enum<S> & net.minecraft.util.StringRepresentable>
extends Object
implements EnvironmentProvider
permits TemperateSeasonSelector, TropicalSeasonSelector
An environment provider that dispatches to another provider based on the current season state of a world.
-
Field Summary
Fields inherited from interface EnvironmentProvider
ELEMENT_CODEC, HOLDER_CODEC -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSeasonalEnvironmentProvider(Optional<S> fallbackSeason, Map<S, net.minecraft.core.Holder<EnvironmentProvider>> seasons, Class<S> seasonClass) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidbuildCurrentComponents(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biome, net.minecraft.core.component.DataComponentMap.Builder builder) Builds the environment components based on the world's current season state, generally using theseason API.protected static <S extends Enum<S> & net.minecraft.util.StringRepresentable>
com.mojang.serialization.MapCodec<Map<S, net.minecraft.core.Holder<EnvironmentProvider>>> createSeasonMapCodec(com.mojang.serialization.Codec<S> baseCodec, S[] values) The fallback season to use if no season mod is installed.getCurrentSeason(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) Gets the current season state of the world at a position (usually by delegating to a season event.final Map<S, net.minecraft.core.Holder<EnvironmentProvider>> seasons()The season-to-provider lookup back.protected static <S extends Enum<S> & net.minecraft.util.StringRepresentable, T extends SeasonalEnvironmentProvider<S>>
com.mojang.serialization.MapCodec<T> validate(com.mojang.serialization.MapCodec<T> codec) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EnvironmentProvider
codec
-
Constructor Details
-
SeasonalEnvironmentProvider
-
-
Method Details
-
buildCurrentComponents
public final void buildCurrentComponents(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biome, net.minecraft.core.component.DataComponentMap.Builder builder) Builds the environment components based on the world's current season state, generally using theseason API.If no seasons mod is installed, or if the tropical/temperate season state does not exist at this world position, then this will use the components provided by the
fallback season.If there is no fallback season, then this does nothing.
- Specified by:
buildCurrentComponentsin interfaceEnvironmentProvider- Parameters:
level- The world/level being queriedpos- The position in the world to querybiome- The biome at the position in the worldbuilder- Component map builder to append to
-
fallbackSeason
The fallback season to use if no season mod is installed. If specified, the fallback season must be a key in theseasons()map. If no fallback season is provided, and there is no season mod installed, then this provider will return nothing.- Returns:
- Returns
fallbackSeason
-
seasons
The season-to-provider lookup back. Used to dispatch this provider to another provider based on the current season of a world.- Returns:
- Returns an unmodifiable map of
seasons
-
getCurrentSeason
protected abstract Optional<S> getCurrentSeason(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) Gets the current season state of the world at a position (usually by delegating to a season event.- Parameters:
level- The world to query the season state ofpos- The position to query the season state at- Returns:
- Returns the season state of a particular world position, or empty if no season state exists there or if a season mod is not loaded.
-
createSeasonMapCodec
protected static <S extends Enum<S> & net.minecraft.util.StringRepresentable> com.mojang.serialization.MapCodec<Map<S, net.minecraft.core.Holder<EnvironmentProvider>>> createSeasonMapCodec(com.mojang.serialization.Codec<S> baseCodec, S[] values) -
validate
protected static <S extends Enum<S> & net.minecraft.util.StringRepresentable, T extends SeasonalEnvironmentProvider<S>> com.mojang.serialization.MapCodec<T> validate(com.mojang.serialization.MapCodec<T> codec)
-