本文整理汇总了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;
}
示例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 );
}
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
}
示例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!");
}
}
示例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);
}
}
}
}
}
示例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);
}
}
}
}
}
示例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.
}
}
}
示例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);
}
}
示例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.
}