WIP starting work on supers for archery/crossbow

This commit is contained in:
nossr50
2023-12-20 19:26:22 -08:00
parent 3e11b7da2c
commit 7e3826a4d6
6 changed files with 103 additions and 3 deletions

View File

@@ -36,14 +36,33 @@ public final class ItemUtils {
* @param item Item to check
* @return true if the item is a bow, false otherwise
*/
// TODO: Unit tests
public static boolean isBow(@NotNull ItemStack item) {
return mcMMO.getMaterialMapStore().isBow(item.getType().getKey().getKey());
}
// TODO: Unit tests
public static boolean isCrossbow(@NotNull ItemStack item) {
return mcMMO.getMaterialMapStore().isCrossbow(item.getType().getKey().getKey());
}
// TODO: Unit tests
public static boolean isBowOrCrossbow(@NotNull ItemStack item) {
return isBow(item) || isCrossbow(item);
}
// TODO: Unit tests
public static BowType getBowType(@NotNull ItemStack item) {
if (isBow(item)) {
return BowType.BOW;
} else if (isCrossbow(item)) {
return BowType.CROSSBOW;
}
throw new IllegalArgumentException(item + " is not a bow or crossbow");
}
// TODO: Unit tests
public static boolean isTrident(@NotNull ItemStack item) {
return mcMMO.getMaterialMapStore().isTrident(item.getType().getKey().getKey());
}

View File

@@ -49,6 +49,14 @@ public final class CombatUtils {
return mcMMO.getMetadataService().getMobMetadataService();
}
// TODO: Unit tests
public static void processProjectileSkillSuperAbilityActivation(McMMOPlayer mmoPlayer, ItemStack heldItem) {
if (heldItem != null && mmoPlayer != null) {
if (ItemUtils.isBowOrCrossbow(heldItem))
mmoPlayer.checkAbilityActivationProjectiles(ItemUtils.getBowType(heldItem));
}
}
//Likely.. because who knows what plugins are throwing around
public static boolean isDamageLikelyFromNormalCombat(@NotNull DamageCause damageCause) {
return switch (damageCause) {