/
MeleeVariable.java
43 lines (35 loc) · 1.86 KB
/
MeleeVariable.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package slimeknights.tconstruct.library.json.variable.melee;
import net.minecraft.world.entity.LivingEntity;
import slimeknights.mantle.data.registry.GenericLoaderRegistry;
import slimeknights.mantle.data.registry.GenericLoaderRegistry.IGenericLoader;
import slimeknights.mantle.data.registry.GenericLoaderRegistry.IHaveLoader;
import slimeknights.tconstruct.library.json.variable.VariableLoaderRegistry;
import slimeknights.tconstruct.library.json.variable.VariableLoaderRegistry.ConstantLoader;
import slimeknights.tconstruct.library.modifiers.modules.combat.ConditionalMeleeDamageModule;
import slimeknights.tconstruct.library.tools.context.ToolAttackContext;
import slimeknights.tconstruct.library.tools.nbt.IToolStackView;
import javax.annotation.Nullable;
/** Variable for use in {@link ConditionalMeleeDamageModule} */
public interface MeleeVariable extends IHaveLoader {
GenericLoaderRegistry<MeleeVariable> LOADER = new VariableLoaderRegistry<>("Melee Variable", Constant.LOADER.constructor());
/**
* Gets the value of the variable
* @param tool Tool instance
* @param context Attack context, will be null in tooltips
* @param attacker Entity using the tool, may be null conditionally in tooltips
* @return Value of this variable
*/
float getValue(IToolStackView tool, @Nullable ToolAttackContext context, @Nullable LivingEntity attacker);
/** Constant value instance for this object */
record Constant(float value) implements VariableLoaderRegistry.ConstantFloat, MeleeVariable {
public static final ConstantLoader<Constant> LOADER = new ConstantLoader<>(Constant::new);
@Override
public float getValue(IToolStackView tool, @Nullable ToolAttackContext context, @Nullable LivingEntity attacker) {
return value;
}
@Override
public IGenericLoader<? extends MeleeVariable> getLoader() {
return LOADER;
}
}
}