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


Java Block.getData方法代碼示例

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


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

示例1: clearVisualBlock

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Clears a visual block at a given location for a player.
 *
 * @param player
 *            the player to clear for
 * @param location
 *            the location to clear at
 * @param sendRemovalPacket
 *            if a packet to send a block change should be sent (this is used to prevent unnecessary packets sent when disconnecting or changing worlds, for example)
 * @return if the visual block was shown in the first place
 */
public boolean clearVisualBlock(Player player, Location location, boolean sendRemovalPacket) {
    synchronized (storedVisualises) {
        VisualBlock visualBlock = this.storedVisualises.remove(player.getUniqueId(), location);
        if (sendRemovalPacket && visualBlock != null) {
            // Have to send a packet to the original block type, don't send if the fake block has the same data properties though.
            Block block = location.getBlock();
            VisualBlockData visualBlockData = visualBlock.getBlockData();
            if (visualBlockData.getBlockType() != block.getType() || visualBlockData.getData() != block.getData()) {
                player.sendBlockChange(location, block.getType(), block.getData());
            }

            return true;
        }
    }

    return false;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:29,代碼來源:VisualiseHandler.java

示例2: placeBlock

import org.bukkit.block.Block; //導入方法依賴的package包/類
@SuppressWarnings( value = "deprecation" )
private void placeBlock( int seq, int data )
{
    int x = seq % 1000;
    int z = seq / 1000;
    
    Block block = this.getWorld().getBlockAt( x, this.getHeight(), z );
    
    if( block.getType() != Material.WOOL )
    {
        block.setType( Material.WOOL );
    }
    
    byte woolColor = PlaceColor.getColorById( data ).getWoolColor();
    if( block.getData() != woolColor )
    {
        block.setData( woolColor );
        
        FallingBlock fb = this.getWorld().spawnFallingBlock( new Location( this.getWorld(), x, this.getFallingBlockHeight(), z ), Material.WOOL, woolColor );
        fb.setDropItem( false );
        fb.setHurtEntities( false );
    }
}
 
開發者ID:PickAxis,項目名稱:MinePlace,代碼行數:24,代碼來源:PaintBlocksTask.java

示例3: onInteract

import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onInteract(PlayerInteractEvent evt) {
    if (!evt.getPlayer().equals(currentPainter))
        return;

    Block target = evt.getPlayer().getTargetBlock((Set<Material>) null, 50);
    if (target.getZ() != ARENA_Z || target.getX() < MIN_X || target.getX() > MAX_X)
        return; // Not clicking on the canvas.

    if (target.getY() > MAX_Y && target.getY() <= MAX_Y + 5) { // Pick color.
        penTime = 0;
        currentColor = target.getData();
        updateActionBar();
        currentPainter.playSound(currentPainter.getLocation(), Sound.BLOCK_BREWING_STAND_BREW, 0.75F, 1.75F);
    } else if (evt.getAction() == Action.RIGHT_CLICK_AIR) { // Pen Tool
        penTime = System.currentTimeMillis() + 200;
        placeInk();
        evt.setCancelled(true); // Prevent "cl
    } else if (evt.getAction() == Action.LEFT_CLICK_AIR) { // Fill
        playSound(Sound.ENTITY_BOBBER_SPLASH, 1.5F, 0.5F);
        floodFill(target);
    }
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:24,代碼來源:Pictionary.java

示例4: maybeSideTracked

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Addresses cocoa on sides of trees; can be on any side, but not top, not bottom
 * 
 * @param block The block to test type on
 * @return True if maybe could possible contain cocoa
 */
@SuppressWarnings("deprecation")
private boolean maybeSideTracked(Block block) {
	if (Material.LOG.equals(block.getType()) && block.getData() == 3) {
		return true;
	} else {
		return false;
	}
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:15,代碼來源:CropControlEventHandler.java

示例5: fillData

import org.bukkit.block.Block; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static byte fillData(Block block) {
    byte data = block.getData();
    int id = block.getTypeId();
    if (id == 17) {
        switch (data) {
            case 0:
            case 4:
            case 8:
                return 12;
            case 1:
            case 5:
            case 9:
                return 13;
            case 2:
            case 6:
            case 10:
                return 14;
            case 3:
            case 7:
            case 11:
                return 15;
        }
    }
    
    if (id == 162) {
        switch (data) {
            case 0:
            case 4:
            case 8:
                return 12;
            case 1:
            case 5:
            case 9:
                return 13;
        }
    }
    
    throw new UnsupportedOperationException();
}
 
開發者ID:Recraft,項目名稱:Recreator,代碼行數:41,代碼來源:ItemDrawKnife.java

示例6: onPlayerInteract

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Handle blocks that need special treatment
 * Tilling of coarse dirt into dirt using off-hand (regular hand is in 1.8)
 * Usually prevented because it could lead to an endless supply of dirt with gravel
 *
 * @param e
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 " + e.getEventName());
    }
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getInventory().getItemInOffHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:43,代碼來源:IslandGuard1_9.java

示例7: onPlayerInteract

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Handle V1.8 blocks that need special treatment
 * Tilling of coarse dirt into dirt
 * Usually prevented because it could lead to an endless supply of dirt with gravel
 *
 * @param e
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + e.getEventName());
    }
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getItemInHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:43,代碼來源:IslandGuard1_8.java

示例8: getAttachedBlock

import org.bukkit.block.Block; //導入方法依賴的package包/類
private static Block getAttachedBlock(Block block)
{
    if(block.getData() == 2)
        return block.getRelative(BlockFace.SOUTH);
    if(block.getData() == 3)
        return block.getRelative(BlockFace.NORTH);
    if(block.getData() == 4)
        return block.getRelative(BlockFace.EAST);
    if(block.getData() == 5)
        return block.getRelative(BlockFace.WEST);
    else
        return null;
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:14,代碼來源:CargoNet.java

示例9: checkChunk

import org.bukkit.block.Block; //導入方法依賴的package包/類
private void checkChunk(ChunkPosition pos, @Nullable Chunk chunk) {
    if(repairedChunks.add(pos)) {
        if(chunk == null) {
            chunk = pos.getChunk(match.getWorld());
        }

        for(BlockState state : chunk.getTileEntities()) {
            if(state instanceof Skull) {
                if(!NMSHacks.isSkullCached((Skull) state)) {
                    Location loc = state.getLocation();
                    broadcastDeveloperWarning("Uncached skull \"" + ((Skull) state).getOwner() + "\" at " + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ());
                }
            }
        }

        // Replace formerly invisible half-iron-door blocks with barriers
        for(Block ironDoor : chunk.getBlocks(Material.IRON_DOOR_BLOCK)) {
            BlockFace half = (ironDoor.getData() & 8) == 0 ? BlockFace.DOWN : BlockFace.UP;
            if(ironDoor.getRelative(half.getOppositeFace()).getType() != Material.IRON_DOOR_BLOCK) {
                ironDoor.setType(Material.BARRIER, false);
            }
        }

        // Remove all block 36 and remember the ones at y=0 so VoidFilter can check them
        for(Block block36 : chunk.getBlocks(Material.PISTON_MOVING_PIECE)) {
            if(block36.getY() == 0) {
                block36Locations.add(block36.getX(), block36.getY(), block36.getZ());
            }
            block36.setType(Material.AIR, false);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:33,代碼來源:WorldProblemMatchModule.java

示例10: run

import org.bukkit.block.Block; //導入方法依賴的package包/類
@Override
public void run() {
    int updated = 0;

    while (!queue.isEmpty()) {
        BlockPlacement p = queue.remove();

        Block b = world.getBlockAt(p.x, 30, p.y);

        if (p.definitelyNew || b.getData() != p.blockType) {
            b.setData(p.blockType);
            updated++;
            Firework f = (Firework) world.spawn(new Location(world, p.x, 30, p.y), Firework.class);
            FireworkMeta fm = f.getFireworkMeta();
            fm.addEffect(FireworkEffect.builder()
                    .flicker(false)
                    .trail(true)
                    .with(FireworkEffect.Type.BALL)
                    .withColor(DyeColor.getByWoolData(p.blockType).getColor())
                    .withFade(DyeColor.getByWoolData(p.blockType).getColor())
                    .build());
            fm.setPower(0);
            f.setFireworkMeta(fm);
        }
    }

    if (updated > 0) {
        plugin.getServer().broadcastMessage(ChatColor.DARK_GREEN + "Updated " + ChatColor.GREEN + updated + ChatColor.DARK_GREEN + " blocks!");
    }
}
 
開發者ID:PlaceDevs,項目名稱:placemc,代碼行數:31,代碼來源:PlaceBlocksTask.java

示例11: removeSupportBlocks

import org.bukkit.block.Block; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void removeSupportBlocks() {
	short blockId;
	Block block;
	
	for (int x = 0; x < craft.sizeX; x++) {
		for (int z = 0; z < craft.sizeZ; z++) {
			for (int y = craft.sizeY - 1; y > -1; y--) {
			//for (int y = 0; y < craft.sizeY; y++) {

				blockId = craft.matrix[x][y][z];

				// craft block, replace by air
				if (BlocksInfo.needsSupport(blockId)) {

					//Block block = world.getBlockAt(posX + x, posY + y, posZ + z);
					block = getWorldBlock(x, y, z);

					// special case for doors
					// we need to remove the lower part of the door only, or the door will pop
					// lower part have data 0 - 7, upper part have data 8 - 15
					if (blockId == 64 || blockId == 71) { // wooden door and steel door
						if (block.getData() >= 8)
							continue;
					}
					
					if(blockId == 26) { //bed
						if(block.getData() >= 4)
							continue;
					}

					setBlock(0, block);
				}
			}
		}
	}
}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:38,代碼來源:CraftRotator.java

示例12: removeSupportBlocks

import org.bukkit.block.Block; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void removeSupportBlocks() {
	short blockId;
	Block block;
	if( craft.matrix == null )
		return;
	
	for (int x = 0; x < craft.sizeX; x++) {
		for (int z = 0; z < craft.sizeZ; z++) {
			for (int y = craft.sizeY - 1; y > -1; y--) {
				// for (int y = 0; y < craft.sizeY; y++) {
				
				if( craft.matrix == null )
					return;
				blockId = craft.matrix[x][y][z];

				// craft block, replace by air
				if (BlocksInfo.needsSupport(blockId)) {

					// Block block = world.getBlockAt(posX + x, posY + y, posZ + z);
					block = getWorldBlock(x, y, z);

					if (blockId == 26) { // bed
						if (block.getData() >= 4) {
							continue;
						}
					}

					// special case for doors
					// we need to remove the lower part of the door only, or the door will pop
					// lower part have data 0 - 7, upper part have data 8 - 15

					setBlock(0, block);
				}
			}
		}
	}
}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:39,代碼來源:CraftMover.java

示例13: drawBoard

import org.bukkit.block.Block; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private void drawBoard(boolean disable) {
    for (int x = 22; x < 32; x++) {
        for (int z = 73; z < 87; z++) {
            Block bk = getWorld().getBlockAt(x, 63, z);
            if (bk.getType() == Material.WOOL && (bk.getData() != 15 || !isGoing())) // If the game isn't going, that means we should reset all parts of the board.
                bk.setData(disable ? (byte) 15 : randColor(true)); // If the board is being disabled, set everything to black.
        }
    }
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:11,代碼來源:DJBooth.java

示例14: addQueue

import org.bukkit.block.Block; //導入方法依賴的package包/類
private void addQueue(List<Block> queue, List<Block> covered, Block target, byte oldColor, int xOffset, int yOffset) {
    target = target.getLocation().add(xOffset, yOffset, 0).getBlock();
    if (target.getType() == Material.WOOL && target.getData() == oldColor && !covered.contains(target)) {
        queue.add(target);
        covered.add(target);
    }
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:8,代碼來源:Pictionary.java

示例15: scanBoard

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Scan the board to check if it's correct.
 */
private void scanBoard() {
    for (int x = -8; x < -2; x++) {
        for (int z = -40; z < -32; z++) {
            Block b = new Location(getDungeon().getWorld(), x, 10, z).getBlock();
            if (b.getType() == Material.WOOL && b.getData() != b.getLocation().add(0, -2, 0).getBlock().getData())
                return;
        }
    }
    complete(); // All of the board matches.
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:14,代碼來源:MatchPuzzle.java


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