use of org.spongepowered.api.text.selector.Selector in project LanternServer by LanternPowered.
the class SelectorResolver method addTypeFilters.
private void addTypeFilters(List<Predicate<Entity>> filters) {
Selector sel = this.selector;
Optional<Argument.Invertible<EntityType>> typeOpt = sel.getArgument(ArgumentTypes.ENTITY_TYPE);
if (typeOpt.isPresent()) {
Argument.Invertible<EntityType> typeArg = typeOpt.get();
boolean inverted = typeArg.isInverted();
EntityType type = typeArg.getValue();
filters.add(input -> inverted ^ input.getType() == type);
}
}
use of org.spongepowered.api.text.selector.Selector in project LanternServer by LanternPowered.
the class SelectorResolver method addRotationFilters.
private void addRotationFilters(List<Predicate<Entity>> filters) {
Selector sel = this.selector;
// If the Z's are uncommented, don't forget to implement them
// Optional<Double> rotMinZ = sel.get(ArgumentTypes.ROTATION.minimum().z());
// Optional<Double> rotMaxZ = sel.get(ArgumentTypes.ROTATION.maximum().z());
Optional<Double> rotMinX = sel.get(ArgumentTypes.ROTATION.minimum().x());
if (rotMinX.isPresent()) {
double rmx = rotMinX.get();
filters.add(input -> input.getRotation().getX() >= rmx);
}
Optional<Double> rotMinY = sel.get(ArgumentTypes.ROTATION.minimum().y());
if (rotMinY.isPresent()) {
double rmy = rotMinY.get();
filters.add(input -> input.getRotation().getY() >= rmy);
}
Optional<Double> rotMaxX = sel.get(ArgumentTypes.ROTATION.maximum().x());
if (rotMaxX.isPresent()) {
double rx = rotMaxX.get();
filters.add(input -> input.getRotation().getX() <= rx);
}
Optional<Double> rotMaxY = sel.get(ArgumentTypes.ROTATION.maximum().y());
if (rotMaxY.isPresent()) {
double ry = rotMaxY.get();
filters.add(input -> input.getRotation().getY() <= ry);
}
}
Aggregations