Class DifficultyContext
java.lang.Object
johnsmith.enchantingoverhauled.api.enchantment.value.DifficultyContext
Global context holder providing the active world
Difficulty for DifficultyBasedValue
evaluations where a Level reference is not directly passed by vanilla's
LevelBasedValue.calculate(int) signature.-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.DifficultyResolves the current worldDifficulty, preferring the active server's world data and falling back to the client difficulty supplier.static voidsetClientFallback(Supplier<net.minecraft.world.Difficulty> fallback) Sets the client-side fallback supplier used to query difficulty from the client level.static voidsetServer(@Nullable net.minecraft.server.MinecraftServer server) Sets or clears the activeMinecraftServerreference on server startup/shutdown.
-
Method Details
-
setServer
public static void setServer(@Nullable @Nullable net.minecraft.server.MinecraftServer server) Sets or clears the activeMinecraftServerreference on server startup/shutdown.- Parameters:
server- The activeMinecraftServer, ornullwhen the server stops.
-
setClientFallback
Sets the client-side fallback supplier used to query difficulty from the client level.- Parameters:
fallback- A supplier returning the client's currentDifficulty.
-
getDifficulty
public static net.minecraft.world.Difficulty getDifficulty()Resolves the current worldDifficulty, preferring the active server's world data and falling back to the client difficulty supplier.- Returns:
- The active
Difficulty.
-