/
IWeaponAttack.java
36 lines (31 loc) · 1.48 KB
/
IWeaponAttack.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
package slimeknights.tconstruct.library.tools.definition.weapon;
import slimeknights.mantle.data.registry.DefaultingLoaderRegistry;
import slimeknights.mantle.data.registry.GenericLoaderRegistry.IGenericLoader;
import slimeknights.mantle.data.registry.GenericLoaderRegistry.IHaveLoader;
import slimeknights.tconstruct.library.tools.context.ToolAttackContext;
import slimeknights.tconstruct.library.tools.helper.ToolAttackUtil;
import slimeknights.tconstruct.library.tools.nbt.IToolStackView;
/** Attack logic for a modifiable weapon */
public interface IWeaponAttack extends IHaveLoader {
/** Default weapon attack */
IWeaponAttack DEFAULT = new IWeaponAttack() {
@Override
public boolean dealDamage(IToolStackView tool, ToolAttackContext context, float damage) {
return ToolAttackUtil.dealDefaultDamage(context.getAttacker(), context.getTarget(), damage);
}
@Override
public IGenericLoader<? extends IWeaponAttack> getLoader() {
throw new UnsupportedOperationException("Attempt to serialize empty AOE iterator");
}
};
/** Registry of all weapon attack loaders */
DefaultingLoaderRegistry<IWeaponAttack> LOADER = new DefaultingLoaderRegistry<>("Weapon Attack", DEFAULT, false);
/**
* Deals damage using the tool
* @param tool Tool instance
* @param context Attack context
* @param damage Damage to deal
* @return True if we successfully attacked
*/
boolean dealDamage(IToolStackView tool, ToolAttackContext context, float damage);
}