Class FunctionEffect
java.lang.Object
com.github.thedeathlycow.thermoo.api.temperature.status.v2.effect.FunctionEffect
- All Implemented Interfaces:
TemperatureEffect
An effect which invokes datapack functions (
.mcfunction files).
Note: Datapack functions are generally not very performant. In general, you should prefer to create your own temperature effect implementation when possible. This should only be used if you are limited to using datapacks exclusively.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder object for creating function effects. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<FunctionEffect> Codec for the function effect.Fields inherited from interface TemperatureEffect
DIRECT_CODEC -
Method Summary
Modifier and TypeMethodDescriptionbooleanapply(net.minecraft.world.entity.LivingEntity target, TemperatureEffectContext context) Calls the mainfunction()static FunctionEffect.Builderbuilder(FunctionWithArguments function) Creates a new builder with an apply function.com.mojang.serialization.MapCodec<FunctionEffect> codec()static FunctionEffectcreate(FunctionWithArguments function) Creates a simple function effect which executes at a permission level of 2 and has no cleanup function,function()The main function that applies the effect.static FunctionWithArgumentsfunction(net.minecraft.resources.Identifier functionId) Creates a new function without any macro arguments.static FunctionWithArgumentsfunction(net.minecraft.resources.Identifier functionId, @Nullable net.minecraft.nbt.CompoundTag arguments) Creates a new function with macro arguments.@Range(from=0L,to=4L) intThe permission level that the function is executed at.voidremove(net.minecraft.world.entity.LivingEntity target, TemperatureEffectContext context) Invokes theremoveFunction(), if present.The function that handles cleanup logic for the effect.
-
Field Details
-
CODEC
Codec for the function effect.
-
-
Method Details
-
function
public static FunctionWithArguments function(net.minecraft.resources.Identifier functionId, @Nullable @Nullable net.minecraft.nbt.CompoundTag arguments) Creates a new function with macro arguments.- Parameters:
functionId- The ID of the function. May not benull.arguments- The macro arguments of the function. Ifnull, then no arguments will be supplied.- Throws:
NullPointerException- iffunctionIdisnull
-
function
Creates a new function without any macro arguments.- Parameters:
functionId- The ID of the function. May not benull.- Throws:
NullPointerException- iffunctionIdisnull
-
builder
Creates a new builder with an apply function.- Parameters:
function- The apply function. May not benull.- Throws:
NullPointerException- iffunctionisnull
-
create
Creates a simple function effect which executes at a permission level of 2 and has no cleanup function,- Parameters:
function- The apply function. May not benull.- Throws:
NullPointerException- iffunctionisnull
-
apply
public boolean apply(net.minecraft.world.entity.LivingEntity target, TemperatureEffectContext context) Calls the mainfunction()- Specified by:
applyin interfaceTemperatureEffect- Parameters:
target- The entity receiving the effect.context- Additional context for the effect.- Returns:
- Returns
truewhen executed on the logical server AND the function was successfully executed.
-
remove
public void remove(net.minecraft.world.entity.LivingEntity target, TemperatureEffectContext context) Invokes theremoveFunction(), if present. Any potential cleanup logic should be implemented in that function.- Specified by:
removein interfaceTemperatureEffect- Parameters:
target- The entity the effect is being removed from.context- Additional context for the effect.
-
codec
- Specified by:
codecin interfaceTemperatureEffect- Returns:
- Returns
CODEC
-
function
The main function that applies the effect. -
removeFunction
The function that handles cleanup logic for the effect. Optional. -
permissionLevel
public @Range(from=0L,to=4L) int permissionLevel()The permission level that the function is executed at.- Returns:
- Returns an int between 0 and 4 (inclusive).
-