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


Java Location.getBlock方法代码示例

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


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

示例1: obfuscateBlock

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
private void obfuscateBlock(Predicate<BlockState> filter, Location<World> location, NetworkChunk chunk, BlockModifier blockModifier){
    BlockState blockState = location.getBlock();
    if (filter.test(blockState)) {
        BlockState response = blockModifier.handleBlock(blockState, location, getSurrounding(location));
        if (response != blockState) {
            chunk.set(location, response);
        }
    }
}
 
开发者ID:thomas15v,项目名称:NoXray,代码行数:10,代码来源:NetworkBlockContainer.java

示例2: open

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
@Override
public void open(Player player, Manager manager) {
    PlayerOpenCrateEvent open_event = new PlayerOpenCrateEvent(player, manager);
    Sponge.getEventManager().post(open_event);
    if (open_event.isCancelled()) return;
    Location<World> location = player.getLocation();
    Vector3i position = player.getLocation().getBlockPosition();
    World world = location.getExtent();
    int loc_x = position.getX();
    int loc_y = position.getY();
    int loc_z = position.getZ();
    HashMap<Location<World>, BlockState> original_block_states = new HashMap<Location<World>, BlockState>();
    for (int x = -2; x <= 2; x++) {
        for (int y = -1; y <= 3; y++) {
            for (int z = -2; z <= 2; z++) {
                Location loc = new Location<World>(
                        world, loc_x + x, loc_y + y, loc_z + z);
                BlockState loc_state = loc.getBlock();
                original_block_states.put(loc, loc_state);
                location.setBlockType(BlockTypes.AIR, BlockChangeFlags.NONE);
            }
        }
    }
    for (int x = -2; x <= 2; x++) {
        for (int z = -2; z <= 2; z++) {
            new Location<World>(world, loc_x + x, loc_y - 1, loc_z + z).
                    setBlockType(floor_block_type, BlockChangeFlags.NONE);
            if (z == 2 || z == -2 || x == 2 || x == -2) {
                new Location<World>(world, loc_x + x, loc_y , loc_z + z).
                        setBlockType(fence_block_type, BlockChangeFlags.NONE);
            }
        }
    }
    HashSet<HologramsService.Hologram> holograms = new HashSet<HologramsService.Hologram>();
    Location<World> loc1 = new Location<World>(world, loc_x + 2, loc_y, loc_z);
    loc1.setBlock(BlockState.builder().
                    blockType(crate_block_type).
                    add(Keys.DIRECTION, Direction.WEST).
                    build(),
            BlockChangeFlags.NONE);
    Location<World> loc2 = new Location<World>(world, loc_x - 2, loc_y, loc_z);
    loc2.setBlock(BlockState.builder().
                    blockType(crate_block_type).
                    add(Keys.DIRECTION, Direction.EAST).
                    build(),
            BlockChangeFlags.NONE);
    Location<World> loc3 = new Location<World>(world, loc_x, loc_y, loc_z + 2);
    loc3.setBlock(BlockState.builder().
                    blockType(crate_block_type).
                    add(Keys.DIRECTION, Direction.NORTH).
                    build(),
            BlockChangeFlags.NONE);
    Location<World> loc4 = new Location<World>(world, loc_x, loc_y, loc_z - 2);
    loc4.setBlock(BlockState.builder().
                    blockType(crate_block_type).
                    add(Keys.DIRECTION, Direction.SOUTH).
                    build(),
            BlockChangeFlags.NONE);
    Utils.tryCreateHologram(loc1, hologram).ifPresent(holograms::add);
    Utils.tryCreateHologram(loc2, hologram).ifPresent(holograms::add);
    Utils.tryCreateHologram(loc3, hologram).ifPresent(holograms::add);
    Utils.tryCreateHologram(loc4, hologram).ifPresent(holograms::add);
    getOpenSound().ifPresent(sound -> player.playSound(sound, player.getLocation().getPosition(), 1.));
    PLAYERS_OPENING_ANIMATION1.put(player, new Information(this, manager,
            new HashMap<Location<World>, Boolean>(){{
                put(loc1, false);
                put(loc2, false);
                put(loc3, false);
                put(loc4, false);
            }}, original_block_states, holograms));
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:72,代码来源:Animation1OpenManager.java


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