org.bukkit.Material#POWERED_RAIL源码实例Demo

下面列出了org.bukkit.Material#POWERED_RAIL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Civs   文件: ConveyorEffect.java
private void checkForPoweredRail(Region region) {
    Location l = region.getLocation();
    RegionType regionType = (RegionType) ItemManager.getInstance().getItemType(region.getType());
    double radius = regionType.getBuildRadius();
    double x0 = l.getX();
    double y0 = l.getY();
    double z0 = l.getZ();
    outer: for (int x = (int) (x0 - radius); x < x0 + radius; x++) {
        for (int y = (int) (y0 - radius); y < y0 + radius; y++) {
            for (int z = (int) (z0 - radius); z < z0 + radius; z++) {
                Block b = l.getWorld().getBlockAt(x, y, z);
                if (b.getType() == Material.POWERED_RAIL) {
                    Location location = b.getRelative(BlockFace.UP).getLocation();
                    location = Region.idToLocation(Region.blockLocationToString(location));
                    cacheSpawnPoints.put(region, location);
                    break outer;
                }
            }
        }
    }
}
 
源代码2 项目: Civs   文件: ConveyorEffect.java
@EventHandler
public void onPoweredRailBreak(BlockBreakEvent event) {
    if (event.isCancelled() || event.getBlock().getType() != Material.POWERED_RAIL) {
        return;
    }
    Location location = Region.idToLocation(Region.blockLocationToString(event.getBlock().getLocation()));
    ArrayList<Region> regions = new ArrayList<>(RegionManager.getInstance()
            .getRegions(location, 0, false));
    if (regions.isEmpty()) {
        return;
    }
    cacheSpawnPoints.remove(regions.get(0));
}
 
源代码3 项目: Civs   文件: ConveyorEffect.java
@EventHandler(ignoreCancelled = true)
public void onPoweredRailPlace(BlockPlaceEvent event) {
    if (event.getBlockPlaced().getType() != Material.POWERED_RAIL) {
        return;
    }
    checkForPoweredRail(event.getBlockPlaced().getLocation());
}
 
源代码4 项目: Shopkeepers   文件: ChestProtectListener.java
@EventHandler(ignoreCancelled = true)
void onBlockPlace(BlockPlaceEvent event) {
	Block block = event.getBlock();
	Material type = block.getType();
	Player player = event.getPlayer();
	if (Utils.isChest(type)) {
		if (plugin.getProtectedChests().isChestProtected(block, player)) {
			Log.debug("Cancelled placing of chest block by '" + player.getName() + "' at '"
					+ Utils.getLocationString(block) + "': Protected chest nearby");
			event.setCancelled(true);
		}
	} else if (type == Material.HOPPER) {
		if (plugin.getProtectedChests().isProtectedChestAroundHopper(block, player)) {
			Log.debug("Cancelled placing of hopper block by '" + player.getName() + "' at '"
					+ Utils.getLocationString(block) + "': Protected chest nearby");
			event.setCancelled(true);
		}
	} else if (type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL || type == Material.ACTIVATOR_RAIL) {
		Block upperBlock = block.getRelative(BlockFace.UP);
		if (Utils.isChest(upperBlock.getType()) && plugin.getProtectedChests().isChestProtected(upperBlock, player)) {
			Log.debug("Cancelled placing of rail block by '" + player.getName() + "' at '"
					+ Utils.getLocationString(block) + "': Protected chest nearby");
			event.setCancelled(true);
			return;
		}
	}
}
 
源代码5 项目: Kettle   文件: PoweredRail.java
public PoweredRail() {
    super(Material.POWERED_RAIL);
}
 
 方法所在类
 同类方法