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


Java Block.getX方法代碼示例

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


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

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

示例2: handleRemoval

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Generically handle a blanket, no-drop removal of tracking data. This does not attempt to cover edge cases, just removes things and prays.
 * 
 * @param block The block of interest
 * @param chunk The chunk the block lives in.
 */
private void handleRemoval(final Block block, WorldChunk chunk) {
	int x = block.getX();
	int y = block.getY();
	int z = block.getZ();
	Crop crop = chunk.getCrop(x, y, z);
	Sapling sapling = chunk.getSapling(x, y, z);
	TreeComponent treeComponent = chunk.getTreeComponent(x, y, z);
	if (crop != null) {
		crop.setRemoved();
	}
	if (sapling != null) {
		sapling.setRemoved();
	}
	if (treeComponent != null) {
		Tree tree = CropControl.getDAO().getTree(treeComponent);
		
		treeComponent.setRemoved();
		
		if (CropControl.getDAO().getTreeComponents(treeComponent.getTreeID()).isEmpty()) {
			tree.setRemoved();
		}
	}
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:30,代碼來源:CropControlEventHandler.java

示例3: onBlockPlace

import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler
  public void onBlockPlace(BlockPlaceEvent event) {
if (Walls.getSpectators().contains(event.getPlayer().getName())) {
	event.setCancelled(true);
	return;
}

      if (State.PVP)
          return;
      
      Block b = event.getBlock();
      if (b.getType()==Material.TNT && !State.PVP) {
          Chat.player(event.getPlayer(), "&cYou are not allowed to use TNT before the walls drop!");
          event.setCancelled(true);
      }
      
      
      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,代碼行數:26,代碼來源:Events.java

示例4: renderBlocks

import org.bukkit.block.Block; //導入方法依賴的package包/類
private void renderBlocks(MatchTeam matchTeam) {
        byte color1 = progressingTowardsTeam != null ? ColorConverter.convertChatColorToDyeColor(progressingTowardsTeam.getColor()).getWoolData() : -1;
        byte color2 = controller != null && matchTeam == controller ? ColorConverter.convertChatColorToDyeColor(controller.getColor()).getWoolData() : -1;
        Location center = region.getCenter();
        double x = center.getX();
        double z = center.getZ();
        double percent = Math.toRadians(getPercent() * 3.6);
        for(Block block : region.getBlocks()) {
            if(!Blocks.isVisualMaterial(block.getType())) continue;
            double dx = block.getX() - x;
            double dz = block.getZ() - z;
            double angle = Math.atan2(dz, dx);
            if(angle < 0) angle += 2 * Math.PI;
            byte color = angle < percent ? color1 : color2;
            if (color == -1) {
                Pair<Material,Byte> oldBlock = regionSave.getBlockAt(new BlockVector(block.getLocation().toVector()));
                if (oldBlock.getLeft().equals(block.getType())) color = oldBlock.getRight();
            }
            if (color != -1) {
                block.setData(color);
//                Bukkit.broadcastMessage("set to " + color);
            } else {
//                Bukkit.broadcastMessage("color = -1");
            }
        }
    }
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:27,代碼來源:ControlPoint.java

示例5: onPlayerMove

import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    if (State.PVP)
        return;
    
	Block b = event.getTo().getBlock();
	Team team = Team.getTeam(event.getPlayer());
	if (team == null)
		return;
	
       if (b.getX() < team.getMin().getX() + 1 || b.getZ() < team.getMin().getZ() + 1) {
           Chat.player(event.getPlayer(), "&cYou cannot leave your team's quadrant!");
           event.getPlayer().teleport(event.getFrom());
       }
       if (b.getX() > team.getMax().getX() - 1 || b.getZ() > team.getMax().getZ() - 1) {
           Chat.player(event.getPlayer(), "&cYou cannot leave your team's quadrant!");
           event.getPlayer().teleport(event.getFrom());
       }
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:20,代碼來源:Events.java

示例6: getArmorStand

import org.bukkit.block.Block; //導入方法依賴的package包/類
private static ArmorStand getArmorStand(Block b)
{
    Location l = new Location(b.getWorld(), (double)b.getX() + 0.5D, (double)b.getY() + 1.2D, (double)b.getZ() + 0.5D);
    Entity aentity[];
    int j = (aentity = l.getChunk().getEntities()).length;
    for(int i = 0; i < j; i++)
    {
        Entity n = aentity[i];
        if((n instanceof ArmorStand) && n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D)
            return (ArmorStand)n;
    }

    ArmorStand hologram = ArmorStandFactory.createHidden(l);
    hologram.setCustomNameVisible(false);
    hologram.setCustomName(null);
    return hologram;
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:18,代碼來源:AndroidStatusHologram.java

示例7: getArmorStand

import org.bukkit.block.Block; //導入方法依賴的package包/類
public static ArmorStand getArmorStand(Block hopper)
{
    Location l = new Location(hopper.getWorld(), (double)hopper.getX() + 0.5D, (double)hopper.getY() + 1.2D, (double)hopper.getZ() + 0.5D);
    Entity aentity[];
    int j = (aentity = l.getChunk().getEntities()).length;
    for(int i = 0; i < j; i++)
    {
        Entity n = aentity[i];
        if((n instanceof ArmorStand) && n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D)
            return (ArmorStand)n;
    }

    ArmorStand hologram = ArmorStandFactory.createHidden(l);
    hologram.setCustomNameVisible(false);
    hologram.setCustomName(null);
    return hologram;
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:18,代碼來源:XPCollector.java

示例8: getArmorStand

import org.bukkit.block.Block; //導入方法依賴的package包/類
public static ArmorStand getArmorStand(Block hopper)
{
    Location l = new Location(hopper.getWorld(), (double)hopper.getX() + 0.5D, hopper.getY(), (double)hopper.getZ() + 0.5D);
    Entity aentity[];
    int j = (aentity = l.getChunk().getEntities()).length;
    for(int i = 0; i < j; i++)
    {
        Entity n = aentity[i];
        if((n instanceof ArmorStand) && n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D)
            return (ArmorStand)n;
    }

    ArmorStand hologram = ArmorStandFactory.createHidden(l);
    hologram.setCustomNameVisible(false);
    hologram.setCustomName(null);
    return hologram;
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:18,代碼來源:AutoBreeder.java

示例9: getArmorStand

import org.bukkit.block.Block; //導入方法依賴的package包/類
public static ArmorStand getArmorStand(Block hopper, boolean createIfNoneFound) {
	Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5);
	
	for (Entity n: l.getChunk().getEntities()) {
		if (n instanceof ArmorStand) {
			if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
		}
	}

	if (!createIfNoneFound) {
		return null;
	}
	
	ArmorStand hologram = ArmorStandFactory.createHidden(l);
	hologram.setCustomNameVisible(false);
	hologram.setCustomName(null);
	return hologram;
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:19,代碼來源:InfusedHopper.java

示例10: isBreakableTracked

import org.bukkit.block.Block; //導入方法依賴的package包/類
public boolean isBreakableTracked(Block block) {
	WorldChunk chunk = WorldChunk.getChunk(block.getChunk());
	int x = block.getX();
	int y = block.getY();
	int z = block.getZ();
	return (chunk.getCrop(x, y, z) != null) || (chunk.getSapling(x, y, z) != null);
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:8,代碼來源:DAO.java

示例11: getFace

import org.bukkit.block.Block; //導入方法依賴的package包/類
public BlockFace getFace(final Block block) {
    BlockFace[] values = BlockFace.values();

    for (BlockFace face : values) {
        if ((this.getX() + face.getModX() == block.getX()) &&
            (this.getY() + face.getModY() == block.getY()) &&
            (this.getZ() + face.getModZ() == block.getZ())
        ) {
            return face;
        }
    }

    return null;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:15,代碼來源:CraftBlock.java

示例12: getKitSign

import org.bukkit.block.Block; //導入方法依賴的package包/類
public Sign getKitSign(Sign s) {
	for (Block b : kitSigns) 
		if (b.getX() == s.getX() && b.getY() == s.getY() && b.getZ() == s.getZ())
			if (b.getType() == Material.SIGN || b.getType() == Material.WALL_SIGN)
				return (Sign) b.getState();
	return null;
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:8,代碼來源:Lobby.java

示例13: setBlockSuperFast

import org.bukkit.block.Block; //導入方法依賴的package包/類
@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_12_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_12_R1.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
    int combined = blockId + (data << 12);
    IBlockData ibd = net.minecraft.server.v1_12_R1.Block.getByCombinedId(combined);
    if (applyPhysics) {
        w.setTypeAndData(bp, ibd, 3); 
    } else {
        w.setTypeAndData(bp, ibd, 2); 
    }
    chunk.a(bp, ibd);
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:15,代碼來源:NMSHandler.java

示例14: getArmorStand

import org.bukkit.block.Block; //導入方法依賴的package包/類
private static ArmorStand getArmorStand(Block b)
{
    Location l = new Location(b.getWorld(), (double)b.getX() + 0.5D, (float)b.getY() - 0.7F, (double)b.getZ() + 0.5D);
    Entity aentity[];
    int j = (aentity = l.getChunk().getEntities()).length;
    for(int i = 0; i < j; i++)
    {
        Entity n = aentity[i];
        if((n instanceof ArmorStand) && n.getCustomName() != null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D)
            return (ArmorStand)n;
    }

    ArmorStand hologram = ArmorStandFactory.createHidden(l);
    return hologram;
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:16,代碼來源:EnergyHologram.java

示例15: getNearbyBlocks2D

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Method to return all blocks in a 2-dimensional space (x,z)
 * 
 * @param center
 *            The center block.
 * @param radius
 *            The radius.
 * @return A list containing all blocks.
 */
public static List<Block> getNearbyBlocks2D(Block center, int radius) {

	List<Block> blocks = new ArrayList<>();

	for (int x = center.getX() - radius; x <= center.getX() + radius; x++) {
		for (int z = center.getZ() - radius; z <= center.getZ() + radius; z++) {
			Location loc = new Location(center.getWorld(), x, center.getY(), z);

			blocks.add(loc.getBlock());
		}
	}
	return blocks;
}
 
開發者ID:kadeska,項目名稱:MT_Core,代碼行數:23,代碼來源:WorldUtils.java


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