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


Java Location.setBlockType方法代码示例

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


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

示例1: checkLocationForLobbySign

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
private boolean checkLocationForLobbySign(Location3D location) throws IllegalArgumentException {
    checkArgument(location.getWorld().isPresent(), "Location for lobby sign must contain world");
    java.util.Optional<World> world = Sponge.getServer().getWorld(location.getWorld().get());
    if (!world.isPresent()) {
        throw new IllegalArgumentException("Invalid world for lobby sign location");
    }

    Location<World> loc = WorldLocationConverter.of(location);
    if (!getLobbySignMap().containsKey(location)) {
        java.util.Optional<TileEntity> tile = loc.getExtent().getTileEntity(LocationConverter.floor(location));
        if (!tile.isPresent() || tile.get().getType() != TileEntityTypes.SIGN) {
            //TODO: maybe detect which sign type it should be?
            loc.setBlockType(BlockTypes.WALL_SIGN,
                    Cause.of(NamedCause.of("inferno:lobbyCreation", InfernoPlugin.getInstance())));
        }
        return true;
    }
    return false;
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:20,代码来源:InfernoArena.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

示例3: setIce

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
private void setIce(Location<World> loc) {
    if (loc.getBlock().getType().equals(BlockTypes.AIR)) {
        loc.setBlockType(BlockTypes.PACKED_ICE);
    }
}
 
开发者ID:prism,项目名称:Bedrock,代码行数:6,代码来源:JailManager.java

示例4: removeIce

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
private void removeIce(Location<World> loc) {
    if (loc.getBlock().getType().equals(BlockTypes.PACKED_ICE)) {
        loc.setBlockType(BlockTypes.AIR);
    }
}
 
开发者ID:prism,项目名称:Bedrock,代码行数:6,代码来源:JailManager.java

示例5: placeBlock

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
/**
 * Constructs a custom block and places it in the world.
 *
 * @param block The block location
 * @param cause The cause
 * @return The wrapped block
 */
default T placeBlock(Block block, BlockChangeFlag flag, Cause cause) {
    Location<World> location = block.getLocation()
            .orElseThrow(() -> new IllegalStateException("Could not access the location of the provided block."));
    World world = location.getExtent();

    // Remove the previous custom block
    CustomItemLibrary.getInstance().getService().removeArmorStandsAt(block);

    location.setBlockType(CustomBlock.BLOCK_TYPE_CUSTOM, flag, cause);

    ArmorStand armorStand = createDummyArmorStand(block);
    Vector3d rotation = Vector3d.ZERO;

    if(isRotateHorizontally()) {
        Optional<Player> player = cause.first(Player.class);

        if(player.isPresent()) {
            Vector3d headRotation = player.get().getHeadRotation();
            double angle = Math.floorMod(180 + (int) Math.floor(headRotation.getY()), 360);
            angle += 45;
            angle = Math.floorMod((int) Math.floor(angle), 360);
            angle = (int) (angle / 90);
            angle = angle * 90;
            rotation = Vector3d.from(0, angle, 0);
        }
    }

    armorStand.offer(createDefaultCustomFeatureData());
    armorStand.offer(new CustomBlockData());
    armorStand.setRotation(rotation);

    world.spawnEntity(armorStand, cause);

    T result = customizeBlock(block, armorStand, cause);

    result.setModel(getDefaultModel());
    CustomItemLibrary.getInstance().getService().registerBlockAsLoaded(result);

    return result;
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:48,代码来源:CustomBlockDefinition.java


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