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


Java World.getBlockAt方法代码示例

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


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

示例1: genRegionMap

import org.bukkit.World; //导入方法依赖的package包/类
public static void genRegionMap(World world) {
    double sizexz = world.getWorldBorder().getSize();
    map = new String[(int)sizexz][(int)sizexz];
    System.out.println("Generating 2d world map, worldborder size: " + sizexz);
    for (double x=0; x < sizexz; x++) {
        for (double z=0; z < sizexz; z++) {
            Block currentBlock = world.getBlockAt(new Location(world, x,lavalevel,z));

            if (currentBlock.getType().equals(Material.LAVA) ||  currentBlock.getType().equals(Material.STATIONARY_LAVA)) {
                // lava block
                map[(int)x][(int)z] = "lava";
            } else {
                // non lava block
                map[(int)x][(int)z] = "unknown";
            }

        }
    }


    System.out.println("Finished generating 2d world map: " + map.toString());
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:23,代码来源:RegionMapGen.java

示例2: updateSign

import org.bukkit.World; //导入方法依赖的package包/类
public void updateSign(int gameNumber) {
	GameSign gameSign = signJoinGames.get(gameNumber);
	if (gameSign != null) {
		World world = SkyWarsReloaded.get().getServer().getWorld(gameSign.getWorld());
		if (world != null) {
			Block b = world.getBlockAt(gameSign.getX(), gameSign.getY(), gameSign.getZ());
			if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST) {
				Sign s = (Sign) b.getState();
				meteSign = (org.bukkit.material.Sign) b.getState().getData();
				Block attachedBlock = b.getRelative(meteSign.getAttachedFace());
				String state = getStatusName(getGame(gameNumber));
				setMaterial(getStatus(getGame(gameNumber)), attachedBlock);
				int max = getGame(gameNumber).getNumberOfSpawns();
				int count = getGame(gameNumber).getPlayers().size();
				if (s != null) {
					s.getBlock().getChunk().load();
					s.setLine(0, new Messaging.MessageFormatter().format("signJoinSigns.line1"));
					s.setLine(1, new Messaging.MessageFormatter().setVariable("mapName", gameSign.getName().toUpperCase()).format("signJoinSigns.line2"));
					s.setLine(2, new Messaging.MessageFormatter().setVariable("gameStatus", state).format("signJoinSigns.line3"));
					s.setLine(3, new Messaging.MessageFormatter().setVariable("count", "" + count).setVariable("max", "" + max).format("signJoinSigns.line4"));
					s.update();
				}
			}
		}
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:27,代码来源:GameController.java

示例3: rayTraceBlock

import org.bukkit.World; //导入方法依赖的package包/类
public static Block rayTraceBlock(World world, Vector start, Vector end, boolean stopOnLiquid, boolean ignoreBlockWithoutBoundingBox, boolean returnLastUncollidableBlock) throws ReflectiveOperationException {
    Class craftWorld = ReflectionUtils.getOBCClass("CraftWorld");
    Method getHandleMethod = ReflectionUtils.getMethod(craftWorld, "getHandle");
    Class<?> vec3D = ReflectionUtils.getNMSClass("Vec3D");
    Class<?> nmsWorld = ReflectionUtils.getNMSClass("World");
    Class<?> mopClass = ReflectionUtils.getNMSClass("MovingObjectPosition");
    Method mop_getBlockPosMethod = ReflectionUtils.getMethod(mopClass, "a");
    Class<?> baseBlockPosition = ReflectionUtils.getNMSClass("BaseBlockPosition");
    Method bbp_getX = ReflectionUtils.getMethod(baseBlockPosition, "getX");
    Method bbp_getY = ReflectionUtils.getMethod(baseBlockPosition, "getY");
    Method bbp_getZ = ReflectionUtils.getMethod(baseBlockPosition, "getZ");
    Object worldServer = getHandleMethod.invoke(world);
    Method rayTraceMethod = ReflectionUtils.getMethod(nmsWorld, "rayTrace", vec3D, vec3D, boolean.class, boolean.class, boolean.class);
    Object mop = rayTraceMethod.invoke(worldServer, toVec3D(start), toVec3D(end),
            stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock);
    if (mop != null) {
        Object blockPos = mop_getBlockPosMethod.invoke(mop);
        return world.getBlockAt((int) bbp_getX.invoke(blockPos), (int) bbp_getY.invoke(blockPos), (int) bbp_getZ.invoke(blockPos));
    }
    return null;
}
 
开发者ID:NyaaCat,项目名称:NyaaCore,代码行数:22,代码来源:RayTraceUtils.java

示例4: getHighestLocation

import org.bukkit.World; //导入方法依赖的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

示例5: light

import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void light(LightningStrikeEvent evt) {
    Location target = evt.getLightning().getLocation();
    World world = target.getWorld();
    
    for (Location each : locs) {
        if (each.getWorld() != world) return;
        
        Block self = world.getBlockAt(each);
        if (self == null) {
            locs.remove(target);
            return;
        }
        Structure s = StructureChangeListener.match(self);
        if (s == null || !(s instanceof StructureConductor)) {
            locs.remove(target);
            return;
        }
        
        if (target.distance(each) <= 50) {
            evt.setCancelled(true);
            world.strikeLightning(each);
        }
    }
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:26,代码来源:StructureConductor.java

示例6: getSafeLocationUnder

import org.bukkit.World; //导入方法依赖的package包/类
private static Vector getSafeLocationUnder(Block block) {
    World world = block.getWorld();
    for(int y = block.getY() - 2; y >= 0; y--) {
        Block feet = world.getBlockAt(block.getX(), y, block.getZ());
        Block head = world.getBlockAt(block.getX(), y + 1, block.getZ());
        if(feet.getType() == Material.AIR && head.getType() == Material.AIR) {
            return new Vector(block.getX() + 0.5, y, block.getZ() + 0.5);
        }
    }
    return new Vector(block.getX() + 0.5, -2, block.getZ() + 0.5);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:LaneMatchModule.java

示例7: blockAt

import org.bukkit.World; //导入方法依赖的package包/类
/**
 * Return the {@link Block} in the given {@link World}, at the given encoded location.
 * This method is more efficient than creating an intermediate {@link BlockVector},
 * and more convenient.
 */
public static Block blockAt(World world, long encoded) {
    return world.getBlockAt(
        (int) unpack(encoded, 0),
        (int) unpack(encoded, SHIFT),
        (int) unpack(encoded, SHIFT + SHIFT)
    );
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:13,代码来源:BlockUtils.java

示例8: corners

import org.bukkit.World; //导入方法依赖的package包/类
/**
 * Get the Blocks at the eight corners of the Cuboid.
 *
 * @return array of Block objects representing the Cuboid corners
 */
public Block[] corners() {
    Block[] res = new Block[8];
    World w = this.getWorld();
    res[0] = w.getBlockAt(this.x1, this.y1, this.z1);
    res[1] = w.getBlockAt(this.x1, this.y1, this.z2);
    res[2] = w.getBlockAt(this.x1, this.y2, this.z1);
    res[3] = w.getBlockAt(this.x1, this.y2, this.z2);
    res[4] = w.getBlockAt(this.x2, this.y1, this.z1);
    res[5] = w.getBlockAt(this.x2, this.y1, this.z2);
    res[6] = w.getBlockAt(this.x2, this.y2, this.z1);
    res[7] = w.getBlockAt(this.x2, this.y2, this.z2);
    return res;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:19,代码来源:Cuboid.java

示例9: signRemoved

import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler
  public void signRemoved(BlockBreakEvent event) {
      Location blockLocation = event.getBlock().getLocation();
      World w = blockLocation.getWorld();
  	Block b = w.getBlockAt(blockLocation);
if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST){
   	Sign sign = (Sign) b.getState();
   	String line1 = ChatColor.stripColor(sign.getLine(0));
	if (line1.equalsIgnoreCase(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', new Messaging.MessageFormatter().format("signJoinSigns.line1"))))) {
          	 String world = blockLocation.getWorld().getName().toString();
       		 int x = blockLocation.getBlockX();
       		 int y = blockLocation.getBlockY();
       		 int z = blockLocation.getBlockZ();
       		 File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");
       		 if (signJoinFile.exists()) {
       			FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
                  for (String gameNumber : storage.getConfigurationSection("games.").getKeys(false)) {
                  	String world1 = storage.getString("games." + gameNumber + ".world");
                  	int x1 = storage.getInt("games." + gameNumber + ".x");
                  	int y1 = storage.getInt("games." + gameNumber + ".y");
                  	int z1 = storage.getInt("games." + gameNumber + ".z");
                  	if (x1 == x && y1 == y && z1 == z && world.equalsIgnoreCase(world1)) {
                  		if (event.getPlayer().hasPermission("swr.signs")) {
                        		SkyWarsReloaded.getGC().removeSignJoinGame(gameNumber);
                        	} else {
                        		event.setCancelled(true);
                          	event.getPlayer().sendMessage(ChatColor.RED + "YOU DO NOT HAVE PERMISSION TO DESTROY SWR SIGNS");
                  		}
                  	}
             	 	} 
       		 }
           }
}
  }
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:35,代码来源:SignListener.java

示例10: getTopLocation

import org.bukkit.World; //导入方法依赖的package包/类
public static Location getTopLocation(Location location) {
    World world = location.getWorld();
    int height = world.getMaxHeight();
    int x = location.getBlockX();
    int z = location.getBlockZ();
    for (int i = height; i >= 0; i--) {
        Block block = world.getBlockAt(x, i, z);
        if (block.getType().isSolid())
            return new Location(world, x, i + 1, z);
    }

    return location;
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:14,代码来源:Locations.java

示例11: getEmptyLocation

import org.bukkit.World; //导入方法依赖的package包/类
public static Location getEmptyLocation(Location location, Predicate<Block> filter) {
    World world = location.getWorld();
    int maxHeight = world.getMaxHeight();
    int x = location.getBlockX();
    int z = location.getBlockZ();
    for (int i = location.getBlockY(); i < maxHeight; i++) {
        Block block = world.getBlockAt(x, i, z);
        if (block.getType() == Material.AIR
                && filter.test(block))
            return new Location(world, x, i, z);
    }

    return location;
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:15,代码来源:Locations.java

示例12: openRemoteTerminal

import org.bukkit.World; //导入方法依赖的package包/类
private void openRemoteTerminal(Player p, ItemStack stack, String loc, int range) {
	if (loc.equals("�8\u21E8 �7Linked to: �cNowhere")) {
		p.sendMessage("�4Failed �c- This Device has not been linked to a Chest Terminal!");
		return;
	}
	loc = loc.replace("�8\u21E8 �7Linked to: �8", "");
	World world = Bukkit.getWorld(loc.split(" X: ")[0]);
	if (world == null) {
		p.sendMessage("�4Failed �c- The Chest Terminal that this Device has been linked to no longer exists!");
		return;
	}
	int x = Integer.parseInt(loc.split(" X: ")[1].split(" Y: ")[0]);
	int y = Integer.parseInt(loc.split(" Y: ")[1].split(" Z: ")[0]);
	int z = Integer.parseInt(loc.split(" Z: ")[1]);
	
	Block block = world.getBlockAt(x, y, z);
	
	if (!BlockStorage.check(block, "CHEST_TERMINAL")) {
		p.sendMessage("�4Failed �c- The Chest Terminal that this Device has been linked to no longer exists!");
		return;
	}
	
	float charge = ItemEnergy.getStoredEnergy(stack);
	if (charge < 0.5F) {
		p.sendMessage("�4Failed �c- You are out of Energy!");
		return;
	}

	if (range > 0 && !world.getUID().equals(p.getWorld().getUID())) {
		p.sendMessage("�4Failed �c- You are out of Range!");
		return;
	}
	if (range > 0 && block.getLocation().distance(p.getLocation()) > range) {
		p.sendMessage("�4Failed �c- You are out of Range!");
		return;
	}

	p.getInventory().setItemInMainHand(ItemEnergy.chargeItem(stack, -0.5F));
	PlayerInventory.update(p);
	BlockStorage.getInventory(block).open(p);
}
 
开发者ID:TheBusyBiscuit,项目名称:ChestTerminal,代码行数:42,代码来源:ChestTerminal.java

示例13: signPlaced

import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler
public void signPlaced(SignChangeEvent event) {
    String[] lines = event.getLines();
    if (lines[0].equalsIgnoreCase("[swr]")) {
    	if (event.getPlayer().hasPermission("swr.signs")) {
    		if (SkyWarsReloaded.getCfg().signJoinMode()) {
    			Location signLocation = event.getBlock().getLocation();
                World w = signLocation.getWorld();
            	Block b = w.getBlockAt(signLocation);
            	if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST){
           			event.setCancelled(true);
		        	String world = event.getPlayer().getWorld().getName();
		        	Location spawn = SkyWarsReloaded.getCfg().getSpawn();
		        	if (spawn != null) {
		        		String lobbyWorld = spawn.getWorld().getName();
    		    		if (world.equalsIgnoreCase(lobbyWorld)) {
                   			boolean added = SkyWarsReloaded.getGC().addSignJoinGame(signLocation, lines[1].toLowerCase());
                   			if (added) {
                   				event.getPlayer().sendMessage(ChatColor.GREEN + "Game Sign Succefully Added");
                   			} else {
                   				event.getPlayer().sendMessage(ChatColor.GREEN + "There is no map with that Name");
                   			}
               			} else {
               				event.getPlayer().sendMessage(ChatColor.RED + "SWR SIGNS CAN ONLY BE PLACED IN THE LOBBY WORLD");
               				event.setCancelled(true);
               			}
		        	} else {
           				event.getPlayer().sendMessage(ChatColor.RED + "YOU MUST SET SPAWN IN THE LOBBY WORLD WITH /SWR SETSPAWN BEFORE STARTING A GAME");
           				SkyWarsReloaded.get().getLogger().info("YOU MUST SET SPAWN IN THE LOBBY WORLD WITH /SWR SETSPAWN BEFORE STARTING A GAME");
           				event.setCancelled(true);
           			}
            	}
    		} else {
        		event.getPlayer().sendMessage(ChatColor.RED + "SIGN JOIN MODE IS NOT ENABLED");
    			event.setCancelled(true);
    		}
        } else {
        		event.getPlayer().sendMessage(ChatColor.RED + "YOU DO NOT HAVE PERMISSION TO CREATE SWR SIGNS");
    			event.setCancelled(true);
    } 
   }
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:43,代码来源:SignListener.java

示例14: getBlock

import org.bukkit.World; //导入方法依赖的package包/类
public Block getBlock(World world) {
	return world.getBlockAt((int) (0 + x), (int) (0 + y), (int) (0 + z));
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:4,代码来源:Coordinate.java

示例15: loadCourses

import org.bukkit.World; //导入方法依赖的package包/类
public void loadCourses() {
	Course.getList().clear();
	for (String id : configAPI.getConfig().getKeys(false)) {
		if (id.equalsIgnoreCase("void"))
			continue;
		
		String title = configAPI.getString(id + ".title");
		
		
		if (configAPI.getConfig().getConfigurationSection(id).getKeys(false).size() < 5) {
			new Course(id, title);
			continue;
		}
		
		
		Location start = configAPI.getLocation(id + ".start");
		int buttonX = configAPI.getInt(id + ".button.x");
		int buttonY = configAPI.getInt(id + ".button.y");
		int buttonZ = configAPI.getInt(id + ".button.z");
		String buttonWorld = configAPI.getString(id + ".button.world");
		
		int endX = configAPI.getInt(id + ".end.x");
		int endY = configAPI.getInt(id + ".end.y");
		int endZ = configAPI.getInt(id + ".end.z");
		String endWorld = configAPI.getString(id + ".end.world");
		
		String next = null;
		if (configAPI.contains(id + ".next"))
			next = configAPI.getString(id + ".next");

		if (buttonWorld == null || endWorld == null)
			continue;
		
		World s = Bukkit.getWorld(buttonWorld);
		if (s == null)
			continue;
		World e = Bukkit.getWorld(endWorld);
		if (e == null)
			continue;
		
		Course c = new Course(id, title, start, s.getBlockAt(buttonX, buttonY, buttonZ), e.getBlockAt(endX, endY, endZ));
		c.setNextCourse(next);
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:45,代码来源:Parkour.java


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