当前位置: 首页>>代码示例>>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;未经允许,请勿转载。