当前位置: 首页>>代码示例>>Java>>正文


Java Selector.get方法代码示例

本文整理汇总了Java中org.spongepowered.api.text.selector.Selector.get方法的典型用法代码示例。如果您正苦于以下问题:Java Selector.get方法的具体用法?Java Selector.get怎么用?Java Selector.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.text.selector.Selector的用法示例。


在下文中一共展示了Selector.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addRotationFilters

import org.spongepowered.api.text.selector.Selector; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:27,代码来源:SelectorResolver.java

示例2: addGamemodeFilters

import org.spongepowered.api.text.selector.Selector; //导入方法依赖的package包/类
private void addGamemodeFilters(List<Predicate<Entity>> filters) {
    Selector sel = this.selector;
    Optional<GameMode> gamemode = sel.get(ArgumentTypes.GAME_MODE);
    // If the game mode is NOT_SET, that means accept any
    if (gamemode.isPresent() && gamemode.get() != GameModes.NOT_SET) {
        final GameMode actualMode = gamemode.get();
        filters.add(input -> {
            Optional<GameModeData> mode = input.get(GameModeData.class);
            return mode.isPresent() && mode.get() == actualMode;
        });
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:13,代码来源:SelectorResolver.java

示例3: addRadiusFilters

import org.spongepowered.api.text.selector.Selector; //导入方法依赖的package包/类
private void addRadiusFilters(final Vector3d position, List<Predicate<Entity>> filters) {
    final Selector sel = this.selector;
    Optional<Integer> radiusMin = sel.get(ArgumentTypes.RADIUS.minimum());
    Optional<Integer> radiusMax = sel.get(ArgumentTypes.RADIUS.maximum());
    if (radiusMin.isPresent()) {
        int radMin = radiusMin.get();
        int radMinSquared = radMin * radMin;
        filters.add(input -> input.getLocation().getPosition().distanceSquared(position) >= radMinSquared);
    }
    if (radiusMax.isPresent()) {
        int radMax = radiusMax.get();
        int radMaxSquared = radMax * radMax;
        filters.add(input -> input.getLocation().getPosition().distanceSquared(position) <= radMaxSquared);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:16,代码来源:SelectorResolver.java


注:本文中的org.spongepowered.api.text.selector.Selector.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。