當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockState.setType方法代碼示例

本文整理匯總了Java中org.bukkit.block.BlockState.setType方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockState.setType方法的具體用法?Java BlockState.setType怎麽用?Java BlockState.setType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.block.BlockState的用法示例。


在下文中一共展示了BlockState.setType方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onTreeGrow

import org.bukkit.block.BlockState; //導入方法依賴的package包/類
/**
 * Converts trees to gravel and glowstone
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());

    if (!Settings.netherTrees) {
        return;
    }
    if (!Settings.netherGenerate || IslandWorld.getNetherWorld() == null) {
        return;
    }
    // Check world
    if (!e.getLocation().getWorld().equals(IslandWorld.getNetherWorld())) {
        return;
    }
    for (BlockState b : e.getBlocks()) {
        if (b.getType() == Material.LOG || b.getType() == Material.LOG_2) {
            b.setType(Material.GRAVEL);
        } else if (b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
            b.setType(Material.GLOWSTONE);
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:29,代碼來源:NetherEvents.java

示例2: replaceBlock

import org.bukkit.block.BlockState; //導入方法依賴的package包/類
private void replaceBlock(BlockDrops drops, Block block, MatchPlayer player) {
    if(drops.replacement != null) {
        EntityChangeBlockEvent event = new EntityChangeBlockEvent(player.getBukkit(), block, drops.replacement);
        getMatch().callEvent(event);

        if(!event.isCancelled()) {
            BlockState state = block.getState();
            state.setType(drops.replacement.getItemType());
            state.setData(drops.replacement);
            state.update(true, true);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:14,代碼來源:BlockDropsMatchModule.java

示例3: getNewState

import org.bukkit.block.BlockState; //導入方法依賴的package包/類
public BlockState getNewState() {
    if(this.drops == null || this.drops.replacement == null) {
        return this.newState;
    } else {
        BlockState state = this.newState.getBlock().getState();
        state.setType(this.drops.replacement.getItemType());
        state.setData(this.drops.replacement);
        return state;
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:11,代碼來源:BlockTransformEvent.java

示例4: onBlockFromTo

import org.bukkit.block.BlockState; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventWrapper
public void onBlockFromTo(BlockFromToEvent event) {
    if(event.getToBlock().getType() != event.getBlock().getType()) {
        BlockState oldState = event.getToBlock().getState();
        BlockState newState = event.getToBlock().getState();
        newState.setType(event.getBlock().getType());
        newState.setRawData(event.getBlock().getData());

        // Check for lava ownership
        this.callEvent(event, oldState, newState, blockResolver.getOwner(event.getBlock()));
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:14,代碼來源:BlockTransformListener.java

示例5: onBlockPistonExtend

import org.bukkit.block.BlockState; //導入方法依賴的package包/類
@EventWrapper
public void onBlockPistonExtend(final BlockPistonExtendEvent event) {
    Map<Block, BlockState> newStates = new HashMap<>();

    // Add the arm of the piston, which will extend into the adjacent block.
    PistonExtensionMaterial pistonExtension = new PistonExtensionMaterial(Material.PISTON_EXTENSION);
    pistonExtension.setFacingDirection(event.getDirection());
    BlockState pistonExtensionState = event.getBlock().getRelative(event.getDirection()).getState();
    pistonExtensionState.setType(pistonExtension.getItemType());
    pistonExtensionState.setData(pistonExtension);
    newStates.put(event.getBlock(), pistonExtensionState);

    this.onPistonMove(event, event.getBlocks(), newStates);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:15,代碼來源:BlockTransformListener.java

示例6: cloneWithMaterial

import org.bukkit.block.BlockState; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static BlockState cloneWithMaterial(Block block, Material material, byte data) {
    BlockState state = block.getState();
    state.setType(material);
    state.setRawData(data);
    return state;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:8,代碼來源:BlockStateUtils.java

示例7: toAir

import org.bukkit.block.BlockState; //導入方法依賴的package包/類
public static BlockState toAir(Block block) {
    BlockState newState = block.getState(); // this creates a new copy of the state
    newState.setType(Material.AIR);
    newState.setRawData((byte) 0);
    return newState;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:7,代碼來源:BlockStateUtils.java

示例8: clientNewSign

import org.bukkit.block.BlockState; //導入方法依賴的package包/類
public void clientNewSign(ChannelHandlerContext ctx, int x, int y, int z, int face, String text) {
    if (!allowSigns) {
        webSocketServerThread.sendLine(ctx.channel(), "T,Writing on signs is not allowed");
        // TODO: revert on client
        return;
    }

    BlockFace blockFace;
    switch (face) {
        case 0: // west
            blockFace = BlockFace.WEST;
            x -= 1;
            break;
        case 1: // east
            blockFace = BlockFace.EAST;
            x += 1;
            break;
        default:
        case 2: // north
            blockFace = BlockFace.NORTH;
            z -= 1;
            break;
        case 3: // south
            blockFace = BlockFace.SOUTH;
            z += 1;
            break;
    }
    org.bukkit.material.Sign signDirection = new org.bukkit.material.Sign();
    signDirection.setFacingDirection(blockFace);

    Location location = toBukkitLocation(x, y, z);
    if (!withinSandboxRange(location)) {
        webSocketServerThread.log(Level.FINEST, "client tried to write a sign outside sandbox range");
        return;
    }

    // Create the sign
    Block block = location.getWorld().getBlockAt(location);
    /*
    block.setTypeIdAndData(Material.WALL_SIGN.getId(), data, applyPhysics);
    webSocketServerThread.log(Level.FINEST, "setting sign at "+location+" data="+data);
    */
    BlockState blockState = block.getState();
    blockState.setType(Material.WALL_SIGN);
    blockState.setData(signDirection);
    boolean force = true;
    boolean applyPhysics = false;
    blockState.update(force, applyPhysics);
    webSocketServerThread.log(Level.FINEST, "setting sign at "+location+" blockFace="+blockFace);

    // Set the sign text
    blockState = block.getState();
    if (!(blockState instanceof Sign)) {
        webSocketServerThread.log(Level.WARNING, "failed to place sign at "+location);
        return;
    }
    Sign sign = (Sign) blockState;

    // TODO: text lines by 15 characters into 5 lines
    sign.setLine(0, text);
    sign.update(force, applyPhysics);
    webSocketServerThread.log(Level.FINEST, "set sign text="+text+", signDirection="+signDirection+", blockFace="+blockFace+", block="+block+", face="+face);

    // SignChangeEvent not posted when signs created programmatically; notify web clients ourselves
    notifySignChange(location, block.getType(), block.getState(), sign.getLines());
}
 
開發者ID:satoshinm,項目名稱:WebSandboxMC,代碼行數:67,代碼來源:BlockBridge.java


注:本文中的org.bukkit.block.BlockState.setType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。