Player Ability Checking

Enhance ability validation: add method to check if an ability can be resolved without deep copy and prune invalid unlocked abilities during load
This commit is contained in:
Kam committed 2026-02-16 01:40:51 -05:00
commit f4ad421c2e
26 files changed
+1387 -97

No files matched your search

@@ -9,8 +9,11 @@ import noppes.npcs.LogWriter;
import noppes.npcs.api.handler.IAbilityHandler;
import noppes.npcs.util.NBTJsonUtil;
import net.minecraft.entity.player.EntityPlayer;
import java.io.File;
import java.util.*;
import java.util.function.Predicate;
import java.util.function.Supplier;
public class AbilityController implements IAbilityHandler {
@@ -26,6 +29,7 @@ public class AbilityController implements IAbilityHandler {
private final Map<String, List<AbilityVariant>> externalVariants = new LinkedHashMap<>();
private final List<IAbilityFieldProvider> fieldProviders = new ArrayList<>();
private final List<IAbilityExtender> extenders = new ArrayList<>();
private final List<Predicate<EntityPlayer>> flightCheckers = new ArrayList<>();
// ── Derived State ────────────────────────────────────────────────────────
private final Set<String> builtInTypeIds = new HashSet<>();
@@ -413,6 +417,18 @@ public class AbilityController implements IAbilityHandler {
return extenders;
}
public void registerFlightChecker(Predicate<EntityPlayer> checker) {
flightCheckers.add(checker);
}
public boolean isPlayerFlying(EntityPlayer player) {
if (player.capabilities.isFlying) return true;
for (Predicate<EntityPlayer> checker : flightCheckers) {
if (checker.test(player)) return true;
}
return false;
}
/**
* Fire onAbilityStart on all extenders. Returns false if ANY extender cancels.
*/