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


Java Block類代碼示例

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


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

示例1: onPistonExtend

import org.bukkit.block.Block; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onPistonExtend(BlockPistonExtendEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    Location pistonLoc = e.getBlock().getLocation();
    if (Settings.allowPistonPush || !Util.inWorld(pistonLoc)) {
        //plugin.getLogger().info("DEBUG: Not in world");
        return;
    }
    Island island = plugin.getIslands().getProtectedIslandAt(pistonLoc);
    if (island == null || !island.onIsland(pistonLoc)) {
        //plugin.getLogger().info("DEBUG: Not on is island protection zone");
        return;
    }
    // We need to check where the blocks are going to go, not where they are
    for (Block b : e.getBlocks()) {
        if (!island.onIsland(b.getRelative(e.getDirection()).getLocation())) {
            //plugin.getLogger().info("DEBUG: Block is outside protected area");
            e.setCancelled(true);
            return;
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:25,代碼來源:IslandGuard.java

示例2: walkedOnFence

import org.bukkit.block.Block; //導入依賴的package包/類
/**
 * @return if we have walked onto a fence.
 */
public static boolean walkedOnFence(Location location) {
    // check if were already under that block.
    Location subtracted = location.clone().subtract(0, 1, 0);
    Block groundBlock = subtracted.getBlock();
    if (MaterialHelper.isFence(groundBlock.getType()) || MaterialHelper.isFenceGate(groundBlock.getType())) {
        return true;
    }

    LocationBit bit = new LocationBit(0.5);
    for (int i = 1; i <= 4; i++) {
        Location newLocation = location.clone().add(bit.getX(), -1, bit.getZ());
        Block block = newLocation.getBlock();
        if (MaterialHelper.isFence(block.getType()) || MaterialHelper.isFenceGate(block.getType())) {
            return true;
        }
        bit.shift(i);
    }
    return false;
}
 
開發者ID:Vrekt,項目名稱:Arc-v2,代碼行數:23,代碼來源:LocationHelper.java

示例3: onPlayerInteract

import org.bukkit.block.Block; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
        Block block = event.getClickedBlock();
        // Don't prevent opening chests, etc, as these won't throw the Enderpearls anyway
        if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
            Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation());
            if (!(factionAt instanceof ClaimableFaction)) {
                return;
            }

            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem()); // required to update Enderpearl count
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:18,代碼來源:PearlGlitchListener.java

示例4: onBlockBurn

import org.bukkit.block.Block; //導入依賴的package包/類
/**
 * So far specifically handles these cases:
 * 
 * 1) Block burnt is tracked
 * 2) Block burnt is under a tracked block (probably only mushrooms eligible)
 * 3) Block burnt was a jungle tree, checks for cocoa.
 * 4) Burnt block had mushroom on top and cocoa on the sides
 * 
 * @param e The event
 */
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBurn(BlockBurnEvent e) {
	Block block = e.getBlock();
	if (maybeSideTracked(block)) {
		trySideBreak(block, BreakType.FIRE, null);
	}
	if (maybeBelowTracked(block)) {
		block = block.getRelative(BlockFace.UP);
	}
	Location loc = block.getLocation();
	if (!pendingChecks.contains(loc)) {
		pendingChecks.add(loc);
		handleBreak(block, BreakType.FIRE, null, null);
	}
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:26,代碼來源:CropControlEventHandler.java

示例5: Arena

import org.bukkit.block.Block; //導入依賴的package包/類
public Arena(String name, String worldName, int id, Block sign, List<Map> maps) {
	this.name = name;
	this.id = id;
	this.worldName = worldName;		
	this.maps = maps;
	this.index = 0;
	this.signBlock = sign;
	
	this.state = ArenaState.WAITING;
	this.schedule = new ArenaSchedule(this);
	this.schedule.runTaskTimerAsynchronously(Walls.getInstance(), 0, 20);
	
	registerTeams();
	loadWorld();
	
	list.add(this);
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:18,代碼來源:Arena.java

示例6: reloadWeapons

import org.bukkit.block.Block; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public void reloadWeapons(Player p) {

	for (DataBlock dataBlock : craft.dataBlocks) {

		Block theBlock = getWorldBlock(dataBlock.x, dataBlock.y, dataBlock.z);
		if (theBlock.getTypeId() == 23) {

			for (OneCannon onec : AimCannon.getCannons()) {
				if (onec.isThisCannon(theBlock.getLocation(), false)) {
					onec.reload(p);
				}
			}

		}
	}
}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:18,代碼來源:CraftMover.java

示例7: upElevator

import org.bukkit.block.Block; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void upElevator(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    Block b = e.getTo().getBlock().getRelative(BlockFace.DOWN);
    if (p.hasPermission("ironelevators.use") && e.getFrom().getY() < e.getTo().getY()
            && b.getType() == elevatorMaterial) {
        b = b.getRelative(BlockFace.UP, minElevation);
        int i = maxElevation;
        while (i > 0 && !(
                b.getType() == elevatorMaterial
                        && b.getRelative(BlockFace.UP).getType().isTransparent()
                        && b.getRelative(BlockFace.UP, 2).getType().isTransparent()
        )
                ) {
            i--;
            b = b.getRelative(BlockFace.UP);
        }
        if (i > 0) {
            Location l = p.getLocation();
            l.setY(l.getY() + maxElevation + 3 - i);
            p.teleport(l);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
        }
    }
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:26,代碼來源:IronElevators.java

示例8: onPlayerInteract2

import org.bukkit.block.Block; //導入依賴的package包/類
@EventHandler
public void onPlayerInteract2(PlayerInteractEvent e) {
    Player player = e.getPlayer();
    PlayerInventory inventory = player.getInventory();
    if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Material material = inventory.getItemInHand().getType();
        if(material == Material.BOW) {
            DynamicAC.getManager().getBackend().logBowWindUp(player, System.currentTimeMillis());
        } else if(Utilities.isFood(material)) {
            DynamicAC.getManager().getBackend().logEatingStart(player);
        }
    }
    Block block = e.getClickedBlock();
    if(block != null) {
        Distance distance = new Distance(player.getLocation(), block.getLocation());
        DynamicAC.getManager().getBackend().checkLongReachBlock(player,distance.getXDifference(),distance
                .getYDifference(),distance.getZDifference());
    }
}
 
開發者ID:Notoh,項目名稱:DynamicAC,代碼行數:20,代碼來源:PlayerListener.java

示例9: onBlockBreak

import org.bukkit.block.Block; //導入依賴的package包/類
@EventHandler
  public void onBlockBreak(BlockBreakEvent event) {
if (Walls.getSpectators().contains(event.getPlayer().getName())) {
	event.setCancelled(true);
	return;
}
  	
      if (State.PVP)
          return;
      
      Block b = event.getBlock();
      if (b == null)
          return;
      Team team = Team.getTeam(event.getPlayer());
      if (b.getX() < team.getMin().getX() + 1 || b.getZ() < team.getMin().getZ() + 1) {
          event.setCancelled(true);
      }
      if (b.getX() > team.getMax().getX() - 1 || b.getZ() > team.getMax().getZ() - 1) {
          event.setCancelled(true);
      }
  }
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:22,代碼來源:Events.java

示例10: 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

示例11: hitBlock

import org.bukkit.block.Block; //導入依賴的package包/類
public static boolean hitBlock(Player player, Block block) {
    if (player.getGameMode() == GameMode.CREATIVE)
        return true;

    PlayerBlockTracking playerBlockTracking = getPlayerBlockTracking(player);

    if (playerBlockTracking.isBlock(block)) {
        return true;
    }

    long time = playerBlockTracking.getTimeDifference();
    playerBlockTracking.incrementHackingIndicator();
    playerBlockTracking.setBlock(block);
    playerBlockTracking.updateTime();

    int decrement = (int) (time / OrebfuscatorConfig.AntiHitHackDecrementFactor);
    playerBlockTracking.decrementHackingIndicator(decrement);

    if (playerBlockTracking.getHackingIndicator() == OrebfuscatorConfig.AntiHitHackMaxViolation)
        playerBlockTracking.incrementHackingIndicator(OrebfuscatorConfig.AntiHitHackMaxViolation);

    if (playerBlockTracking.getHackingIndicator() > OrebfuscatorConfig.AntiHitHackMaxViolation)
        return false;

    return true;
}
 
開發者ID:SamaGames,項目名稱:AntiCheat,代碼行數:27,代碼來源:BlockHitManager.java

示例12: downElevator

import org.bukkit.block.Block; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void downElevator(PlayerToggleSneakEvent e) {
    Player p = e.getPlayer();
    Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN);
    if (p.hasPermission("ironelevators.use") && !p.isSneaking()
            && b.getType() == elevatorMaterial) {
        b = b.getRelative(BlockFace.DOWN, minElevation);
        int i = maxElevation; //16
        while (i > 0 && !(
                b.getType() == elevatorMaterial
                        && b.getRelative(BlockFace.UP).getType().isTransparent()
                        && b.getRelative(BlockFace.UP, 2).getType().isTransparent()
        )
                ) {
            //e.getPlayer().sendMessage("" + b.getLocation() + b.getType());
            i--;
            b = b.getRelative(BlockFace.DOWN);
        }
        if (i > 0) {
            Location l = p.getLocation();
            l.setY(l.getY() - maxElevation - 3 + i);
            p.teleport(l);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
        }
    }
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:27,代碼來源:IronElevators.java

示例13: openWorkbench

import org.bukkit.block.Block; //導入依賴的package包/類
public InventoryView openWorkbench(Location location, boolean force) {
    if (!force) {
        Block block = location.getBlock();
        if (block.getType() != Material.WORKBENCH) {
            return null;
        }
    }
    if (location == null) {
        location = getLocation();
    }
    getHandle().displayGUIWorkbench(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    if (force) {
        getHandle().openContainer.checkReachable = false;
    }
    return getHandle().openContainer.getBukkitView();
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:17,代碼來源:CraftHumanEntity.java

示例14: countUnsupportedNeighbors

import org.bukkit.block.Block; //導入依賴的package包/類
/**
 * Return the number of unsupported blocks connected to any blocks neighboring the given location.
 * An air block is placed there temporarily if it is not already air. The search may bail out early
 * when the count is >= the given limit, though this cannot be guaranteed.
 */
public int countUnsupportedNeighbors(Block block, int limit) {
    BlockState state = null;
    if(block.getType() != Material.AIR) {
        state = block.getState();
        block.setTypeIdAndData(0, (byte) 0, false);
    }

    int count = countUnsupportedNeighbors(encodePos(block), limit);

    if(state != null) {
        block.setTypeIdAndData(state.getTypeId(), state.getRawData(), false);
    }

    return count;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:21,代碼來源:FallingBlocksMatchModule.java

示例15: getLineOfSight

import org.bukkit.block.Block; //導入依賴的package包/類
private List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance, int maxLength) {
    if (maxDistance > 120) {
        maxDistance = 120;
    }
    ArrayList<Block> blocks = new ArrayList<Block>();
    Iterator<Block> itr = new BlockIterator(this, maxDistance);
    while (itr.hasNext()) {
        Block block = itr.next();
        blocks.add(block);
        if (maxLength != 0 && blocks.size() > maxLength) {
            blocks.remove(0);
        }
        byte id = (byte)block.getTypeId();
        if (transparent == null) {
            if (id != 0) {
                break;
            }
        } else {
            if (!transparent.contains(id)) {
                break;
            }
        }
    }
    return blocks;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:26,代碼來源:CraftLivingEntity.java


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