当前位置: 首页>>代码示例>>Java>>正文


Java Block.getLocation方法代码示例

本文整理汇总了Java中org.bukkit.block.Block.getLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Block.getLocation方法的具体用法?Java Block.getLocation怎么用?Java Block.getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.block.Block的用法示例。


在下文中一共展示了Block.getLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHighestLocation

import org.bukkit.block.Block; //导入方法依赖的package包/类
public static Location getHighestLocation(final Location origin, final Location def) {
    Preconditions.checkNotNull((Object) origin, (Object) "The location cannot be null");
    final Location cloned = origin.clone();
    final World world = cloned.getWorld();
    final int x = cloned.getBlockX();
    int y = world.getMaxHeight();
    final int z = cloned.getBlockZ();
    while (y > origin.getBlockY()) {
        final Block block = world.getBlockAt(x, --y, z);
        if (!block.isEmpty()) {
            final Location next = block.getLocation();
            next.setPitch(origin.getPitch());
            next.setYaw(origin.getYaw());
            return next;
        }
    }
    return def;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:19,代码来源:BukkitUtils.java

示例2: onBlockBreak

import org.bukkit.block.Block; //导入方法依赖的package包/类
/**
 * So far specifically handles these cases:
 * 
 * 1) Block broken is tracked
 * 2) Block breaks by not-players
 * 3) Block breaks by players
 * 4) Indirect block breaks -- destroying block supporting a crop or collapsible tree, or under mushrooms
 * 5) Indirect block break of cocoa bearing logs
 * 6) Block broken had mushroom on top and cocoa on the sides
 * 
 * @param e The event
 */
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
	Block block = e.getBlock();
	Player player = e.getPlayer();
	BreakType type = player != null ? BreakType.PLAYER : BreakType.NATURAL;
	UUID uuid = player != null ? player.getUniqueId() : null;
	if (maybeSideTracked(block)) {
		trySideBreak(block, type, uuid);
	}
	if (maybeBelowTracked(block)) {
		block = block.getRelative(BlockFace.UP);
	}
	Location loc = block.getLocation();
	if (!pendingChecks.contains(loc)) {
		pendingChecks.add(loc);
		handleBreak(block, type, uuid, null);
	}
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:31,代码来源:CropControlEventHandler.java

示例3: onWoodBreak

import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler
public void onWoodBreak(BlockBreakEvent event) {
    final Block b = event.getBlock();
    if (b != null && (b.getType() == Material.LOG || b.getType() == Material.LOG_2)) {
        Material handType = event.getPlayer().getItemInHand().getType();
        if (handType == Material.WOOD_AXE || handType == Material.STONE_AXE || handType == Material.IRON_AXE || handType == Material.GOLD_AXE || handType == Material.DIAMOND_AXE) {
            dataMap.put(b, b.getData());
            b.setType(Material.WOOL);
            b.setData(DyeColor.BLACK.getWoolData());
            Player p = event.getPlayer();
            event.getPlayer().sendMessage("> +1 Woodcutting EXP");
            Location loc = b.getLocation();
            Vector v = p.getLocation().subtract(loc).toVector().normalize().multiply(0.5);
            DropManager.dropItem(new ItemStack(Material.LOG), loc, event.getPlayer().getUniqueId()).setVelocity(v);
            RScheduler.schedule(plugin, () -> {
                b.setType(Material.LOG);
                b.setData(dataMap.getOrDefault(b, (byte) 0));
            }, RTicks.seconds(2));
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:22,代码来源:SkillManager.java

示例4: onBlockBreak

import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event)
{
  Block block = event.getBlock();
  if (isEventSign(block))
  {
    BlockState state = block.getState();
    Sign sign = (Sign)state;
    ItemStack stack = new ItemStack(Material.SIGN, 1);
    ItemMeta meta = stack.getItemMeta();
    meta.setDisplayName(EVENT_SIGN_ITEM_NAME);
    meta.setLore(Arrays.asList(sign.getLines()));
    stack.setItemMeta(meta);
    
    Player player = event.getPlayer();
    World world = player.getWorld();
    Location blockLocation = block.getLocation();
    if ((player.getGameMode() != GameMode.CREATIVE) && (world.isGameRule("doTileDrops"))) {
      world.dropItemNaturally(blockLocation, stack);
    }
    event.setCancelled(true);
    block.setType(Material.AIR);
    state.update();
  }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:26,代码来源:EventSignListener.java

示例5: trySideBreak

import org.bukkit.block.Block; //导入方法依赖的package包/类
/**
 * Propagates cocoa breaks
 * 
 * @param block
 * @param type
 * @param player
 */
private void trySideBreak(Block block, BreakType type, UUID player) {
	for (BlockFace face : directions) {
		Block faceBlock = block.getRelative(face);
		Location loc = faceBlock.getLocation();
		if (Material.COCOA.equals(faceBlock.getType()) && !pendingChecks.contains(loc)) {
			pendingChecks.add(loc);
			handleBreak(faceBlock, type, player, null);
		}
	}
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:18,代码来源:CropControlEventHandler.java

示例6: onLeafDecay

import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onLeafDecay(LeavesDecayEvent e) {
	Block block = e.getBlock();
	Location loc = block.getLocation();
	if (!pendingChecks.contains(loc)) {
		pendingChecks.add(loc);
		handleBreak(block, BreakType.NATURAL, null, null);
	}
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:10,代码来源:CropControlEventHandler.java

示例7: onEntityChangeBlock

import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
	Block block = e.getBlock();
	if (maybeSideTracked(block)) {
		trySideBreak(block, BreakType.NATURAL, null);
	}
	if (maybeBelowTracked(block)) {
		block = block.getRelative(BlockFace.UP);
	}
	Location loc = block.getLocation();
	if (!pendingChecks.contains(loc)) {
		pendingChecks.add(loc);
		handleBreak(block, BreakType.NATURAL, null, null);
	}
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:16,代码来源:CropControlEventHandler.java

示例8: cast

import org.bukkit.block.Block; //导入方法依赖的package包/类
@Override
public boolean cast(final Player p, final PlayerDataRPG pd, final int level) {
    int damage = pd.getDamage(true);
    switch (level) {
        case 1:
            damage *= 1.2;
            break;
        case 2:
            damage *= 1.4;
            break;
        case 3:
            damage *= 1.6;
            break;
        case 4:
            damage *= 1.9;
            break;
        case 5:
            damage *= 2.2;
            break;
        case 6:
            damage *= 2.6;
            break;
        case 7:
            damage *= 3.0;
            break;
        case 8:
            damage *= 3.5;
            break;
    }
    Block b = p.getTargetBlock((Set<Material>) null, 20);
    if (b == null) {
        p.sendMessage(ChatColor.RED + "Point at a block to cast Lightning Bolt!");
        return false;
    }
    Location loc = b.getLocation();
    RParticles.sendLightning(p, loc);
    Spell.damageNearby(damage, p, loc, 2.5, new ArrayList<Entity>());
    Spell.notify(p, "You summon a bolt of lightning to strike the ground.");
    return true;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:41,代码来源:LightningBolt.java

示例9: onBlockBreak

import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
    final Player player = e.getPlayer();
    final Block block = e.getBlock();

    if(player != null) {
        DACManager.getBackend().checkFastBreak(player, block);
        Distance distance = new Distance(player.getLocation(),block.getLocation());
        DACManager.getBackend().checkLongReachBlock(player,distance.getXDifference(), distance
                .getYDifference(),distance.getZDifference());
        DACManager.getBackend().logBlockBreak(player);
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:14,代码来源:BlockListener.java

示例10: onBlockPistonExtend

import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler
public void onBlockPistonExtend(BlockPistonExtendEvent e) {
	//Check if there are cauldrons on activity on pushed blocks 
	for(Block block : e.getBlocks()) {
		Location loc = block.getLocation();
		for(UUID uuid : plugin.caulLoc.keySet()) {
			Location caul = plugin.caulLoc.get(uuid);
			if(caul.getBlock().getLocation().distance(loc) == 0) {
				e.setCancelled(true);
				return;
			}
		}
	}
}
 
开发者ID:Slaymd,项目名称:CaulCrafting,代码行数:15,代码来源:BlockPistonExtendListener.java

示例11: onBlockBreak

import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockBreak(final BlockBreakEvent event) {
    final Player player = event.getPlayer();
    if(player.getGameMode() == GameMode.CREATIVE) {
        return;
    }
    if(player.getItemInHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)) return;;
    final Block block = event.getBlock();
    final Location blockLocation = block.getLocation();
    if(block.getType() == FoundDiamondsListener.SEARCH_TYPE && this.foundLocations.add(blockLocation.toString())) {
        int count = 1;
        for(int x = -5; x < 5; ++x) {
            for(int y = -5; y < 5; ++y) {
                for(int z = -5; z < 5; ++z) {
                    final Block otherBlock = blockLocation.clone().add((double) x, (double) y, (double) z).getBlock();
                    if(!otherBlock.equals(block) && otherBlock.getType() == FoundDiamondsListener.SEARCH_TYPE && this.foundLocations.add(otherBlock.getLocation().toString())) {
                        ++count;
                    }
                }
            }
        }
       
        String message;
        for(Player on : Bukkit.getOnlinePlayers()) {
            if(plugin.getFactionManager().getPlayerFaction(player.getUniqueId()) != null) {
                 message = plugin.getFactionManager().getPlayerFaction(player.getUniqueId()).getRelation(on).toChatColour() + player.getName() + ChatColor.GRAY + " has found " + ChatColor.AQUA + count + ChatColor.GRAY + " diamond(s).";
                on.sendMessage(message);
            }else{
                message = ChatColor.AQUA + "[" + ChatColor.GRAY + "♠" + ChatColor.AQUA + "]" + ChatColor.GRAY + " " + ChatColor.AQUA + player.getName() + ChatColor.GRAY + " has just spotted " + ChatColor.BLUE + count + ChatColor.GRAY +" diamonds!";
                on.sendMessage(message);
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:35,代码来源:FoundDiamondsListener.java

示例12: createCraft

import org.bukkit.block.Block; //导入方法依赖的package包/类
public Craft createCraft(Player player, CraftType craftType, int x, int y, int z, String name, float dr, Block signBlock, boolean autoShip) {
	//if( npcMerchantThread == null )
		//npcMerchantThread();
	
	if (DebugMode == true)
		player.sendMessage("Attempting to create " + craftType.name
				+ "at coordinates " + Integer.toString(x) + ", "
				+ Integer.toString(y) + ", " + Integer.toString(z));

	if( signBlock == null )
		signBlock = player.getLocation().getBlock();
	Craft craft = new Craft(craftType, player, name, dr, signBlock.getLocation(), this);

	
	// auto-detect and create the craft
	if (!CraftBuilder.detect(craft, x, y, z, autoShip)) {
		return null;
	}
	
	if( autoShip )
		craft.captainName = null;
	
	
	CraftMover cm = new CraftMover(craft, this);
	cm.structureUpdate(null,false);


	Craft.addCraftList.add(craft);
	//craft.cloneCraft();
	
	
	if( craft.type.canFly )
	{
		craft.type.maxEngineSpeed = 10;
	}else if( craft.type.isTerrestrial )
	{
		craft.type.maxEngineSpeed = 4;
	}else
	{
		craft.type.maxEngineSpeed = 6;
	}
	
	
	if( checkSpawnRegion(new Location(craft.world, craft.minX, craft.minY, craft.minZ)) || checkSpawnRegion(new Location(craft.world, craft.maxX, craft.maxY, craft.maxZ)) )
	{
		craft.speedChange(player, true);
	}
	
	if( !autoShip )
	{
		craft.driverName = craft.captainName;
		if(craft.type.listenItem == true)
			player.sendMessage(ChatColor.GRAY + "With a gold sword in your hand, right-click in the direction you want to go.");
		if(craft.type.listenAnimation == true)
			player.sendMessage(ChatColor.GRAY + "Swing your arm in the direction you want to go.");
		if(craft.type.listenMovement == true)
			player.sendMessage(ChatColor.GRAY + "Move in the direction you want to go.");
	}
	return craft;
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:61,代码来源:NavyCraft.java

示例13: returnUpwardsBlocks

import org.bukkit.block.Block; //导入方法依赖的package包/类
public Set<Location> returnUpwardsBlocks(Block startBlock, Material upwardBlockMaterial) {
	Set<Location> checkedLocations = new HashSet<Location>();

	Set<Location> uncheckedLocations = new HashSet<Location>();

	Crop crop = CropControl.getDAO().getChunk(startBlock.getChunk()).getCrop(startBlock.getX(), startBlock.getY(), startBlock.getZ());
	if (crop != null) {
		if (getTrackedCropMaterial(crop.getCropType()) == upwardBlockMaterial) {
			uncheckedLocations.add(startBlock.getLocation());
		}
	} else {
		return checkedLocations; // failfast
	}

	Set<Location> toAddLocations = new HashSet<Location>();
	
	do {
		for (Location unchecked : uncheckedLocations) {
			if (CropControl.getDAO().isTracked(unchecked.getBlock())
					&& !checkedLocations.contains(unchecked)) {
				checkedLocations.add(unchecked);
			}
		}

		for (Location location : uncheckedLocations) {
			Block upBlock = location.getBlock().getRelative(BlockFace.UP);
			Location up = upBlock.getLocation();
			if (CropControl.getDAO().isTracked(upBlock)
					&& !toAddLocations.contains(up)
					&& !checkedLocations.contains(up)) {
				
				if (getTrackedCropMaterial(
						CropControl.getDAO().getChunk(upBlock.getChunk()).getCrop(upBlock.getX(), upBlock.getY(), upBlock.getZ())
								.getCropType()) == upwardBlockMaterial)
					toAddLocations.add(up);
			}
		}

		uncheckedLocations.clear();

		uncheckedLocations.addAll(toAddLocations);

		toAddLocations.clear();

	} while (!uncheckedLocations.isEmpty());

	return checkedLocations;
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:49,代码来源:CropControlEventHandler.java

示例14: from

import org.bukkit.block.Block; //导入方法依赖的package包/类
public static Position from(Block block) {
    return new Position(block.getLocation());
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:4,代码来源:Position.java

示例15: pasteSchematic

import org.bukkit.block.Block; //导入方法依赖的package包/类
private static ArrayList<Object[]> pasteSchematic(Player p, World world, Location loc, Schematic schematic, int xoffset, int yoffset, int zoffset, boolean air) {
    short[] blocks = schematic.getBlocks();
    byte[] blockData = schematic.getData();

    short width = schematic.getWidth();
    short length = schematic.getLength();
    short height = schematic.getHeight();

    loc.setX(loc.getX() - width / 2);
    loc.setZ(loc.getZ() - length / 2);

    ArrayList<Object[]> hist = new ArrayList<Object[]>();

    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            for (int z = 0; z < length; ++z) {
                try {
                    int index = (y * length + z) * width + x;
                    Block block = new Location(world, loc.getX() + x + xoffset, loc.getY() + y + yoffset, loc.getZ() + z + zoffset).getBlock();
                    //                        if (!air && blocks[index] == 0)
                    //                            continue;
                    if (getConfig(p).filter.contains(Material.getMaterial(blocks[index])))
                        continue;
                    Object[] o = new Object[6];
                    o[0] = block.getWorld();
                    o[1] = block.getLocation();
                    o[2] = block.getType();
                    o[3] = block.getData();
                    block.setType(Material.AIR);
                    block.setType(Material.getMaterial(blocks[index]));
                    block.setData(blockData[index]);
                    o[4] = block.getType();
                    o[5] = block.getData();
                    hist.add(o);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return hist;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:43,代码来源:SchematicManager.java


注:本文中的org.bukkit.block.Block.getLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。