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


Java World.getChunkAt方法代码示例

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


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

示例1: asBukkitChunk

import org.bukkit.World; //导入方法依赖的package包/类
public Chunk asBukkitChunk(World world) {
    Chunk chunk = null;
    if (bukkit == null) {
        chunk = world.getChunkAt(x, z);
        bukkit = new WeakReference<>(chunk);
    } else {
        chunk = bukkit.get();
    }
    return chunk;
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:11,代码来源:LazyChunk.java

示例2: getBlock

import org.bukkit.World; //导入方法依赖的package包/类
private Block getBlock(World world, int x, int y, int z)
{
    int cx = x >> 4;
    int cz = z >> 4;

    if ((!world.isChunkLoaded(cx, cz)) && (!world.loadChunk(cx, cz, false)))
        return null;

    Chunk chunk = world.getChunkAt(cx, cz);

    if (chunk == null)
        return null;

    return chunk.getBlock(x & 0xF, y, z & 0xF);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:16,代码来源:OrePopulator.java

示例3: getChunk

import org.bukkit.World; //导入方法依赖的package包/类
public Chunk getChunk(World world) {
    return world.getChunkAt(x, z);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:ChunkPosition.java

示例4: getRealChunkSync

import org.bukkit.World; //导入方法依赖的package包/类
public Chunk getRealChunkSync() {
	World world = Bukkit.getWorld(worldName);
	return world.getChunkAt(chunkX, chunkZ);
}
 
开发者ID:RoboTricker,项目名称:Transport-Pipes,代码行数:5,代码来源:BlockChangeListener.java

示例5: searchForMarkers

import org.bukkit.World; //导入方法依赖的package包/类
/**
 * Searches the map for "markers". Most of the time these are implemented as tile entities (skulls)
 *
 * @param map    the map to scan
 * @param center the center location
 * @param range  the range in where to scan
 */
public void searchForMarkers(@Nonnull Map map, @Nonnull Vector3D center, int range, @Nonnull UUID gameid) {
    World world = Bukkit.getWorld(map.getLoadedName(gameid));
    if (world == null) {
        throw new MapException("Could not find world " + map.getLoadedName(gameid) + "(" + map.getInfo().getName() + ")" + ". Is it loaded?");
    }

    List<Marker> markers = new ArrayList<>();
    List<ChestMarker> chestMarkers = new ArrayList<>();

    int startX = (int) center.getX();
    int startY = (int) center.getZ();

    int minX = Math.min(startX - range, startX + range);
    int minZ = Math.min(startY - range, startY + range);

    int maxX = Math.max(startX - range, startX + range);
    int maxZ = Math.max(startY - range, startY + range);

    for (int x = minX; x <= maxX; x += 16) {
        for (int z = minZ; z <= maxZ; z += 16) {
            Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
            for (BlockState te : chunk.getTileEntities()) {
                if (te.getType() == Material.SKULL) {
                    Skull skull = (Skull) te;
                    if (skull.getSkullType() == SkullType.PLAYER) {
                        String markerData = getMarkerData(skull);
                        if (markerData == null) continue;
                        MarkerDefinition markerDefinition = mapHandler.createMarkerDefinition(markerData);
                        markers.add(new Marker(new Vector3D(skull.getX(), skull.getY(), skull.getZ()),
                                DirectionUtil.directionToYaw(skull.getRotation()),
                                markerData, markerDefinition));
                    }
                } else if (te.getType() == Material.CHEST) {
                    Chest chest = (Chest) te;
                    String name = chest.getBlockInventory().getName();
                    ItemStack[] items = new ItemStack[chest.getBlockInventory()
                            .getStorageContents().length];
                    for (int i = 0; i < items.length; i++) {
                        ItemStack is = chest.getBlockInventory().getItem(i);
                        if (is == null) {
                            items[i] = new ItemStack(Material.AIR);
                        } else {
                            items[i] = is;
                        }
                    }
                    chestMarkers
                            .add(new ChestMarker(new Vector3D(chest.getX(), chest.getY(), chest.getZ()), name,
                                    items));
                }
            }
        }
    }

    map.setMarkers(markers);
    map.setChestMarkers(chestMarkers);
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:64,代码来源:MapScanner.java

示例6: run

import org.bukkit.World; //导入方法依赖的package包/类
@Override
public void run() {
	if (this.secondsUntilRespawn > 0) {
		if (announceRespawn) {
			if (this.currentMessage >= announceMessages.size()) this.currentMessage = 0;
			
			// Show actionbar messages
			String message = announceMessages.get(currentMessage++)
					.replace("%time%", String.valueOf(secondsUntilRespawn))
					.replace("%formatted-time%", this.getFormattedTime(secondsUntilRespawn));
			plugin.getNMSAbstract().broadcastActionBar(message, worldWrapper.getWorld());
		}

		this.secondsUntilRespawn--;
		return;
	}
	
	// Only respawn if a Player is in the World
	World world = this.worldWrapper.getWorld();
	if (world.getPlayers().size() <= 0) return;
	
	// Start respawn process
	PortalCrystal crystalPos = PortalCrystal.values()[currentCrystal++];
	Location crystalLocation = crystalPos.getRelativeToPortal(world);
	World crystalWorld = crystalLocation.getWorld();
	
	Chunk crystalChunk = crystalWorld.getChunkAt(crystalLocation);
	if (!crystalChunk.isLoaded()) 
		crystalChunk.load();
	
	// Remove any existing crystal
	EnderCrystal existingCrystal = crystalPos.get(world);
	if (existingCrystal != null) existingCrystal.remove();
	
	crystalPos.spawn(world);
	crystalWorld.createExplosion(crystalLocation.getX(), crystalLocation.getY(), crystalLocation.getZ(), 0F, false, false);
	crystalWorld.spawnParticle(Particle.EXPLOSION_HUGE, crystalLocation, 0);
	
	// All crystals respawned
	if (currentCrystal >= 4) {
		
		// If dragon already exists, cancel the respawn process
		if (crystalWorld.getEntitiesByClass(EnderDragon.class).size() >= 1) {
			plugin.getLogger().warning("An EnderDragon is already present in world " + crystalWorld.getName() + ". Dragon respawn cancelled");
			this.nmsAbstract.broadcastActionBar(ChatColor.RED + "Dragon respawn abandonned! Dragon already exists! Slay it!", crystalWorld);
			
			// Destroy all crystals
			for (PortalCrystal portalCrystal : PortalCrystal.values()) {
				Location location = portalCrystal.getRelativeToPortal(world);
				
				portalCrystal.get(world).remove();
				
				crystalWorld.getPlayers().forEach(p -> p.playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 1000, 1));
				crystalWorld.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
			}
			
			this.cancel();
			return;
		}
		
		this.dragonBattle.respawnEnderDragon();
		RespawnSafeguardRunnable.newTimeout(plugin, worldWrapper.getWorld(), dragonBattle);
		
		BattleStateChangeEvent bscEventRespawning = new BattleStateChangeEvent(dragonBattle, dragon, BattleState.CRYSTALS_SPAWNING, BattleState.DRAGON_RESPAWNING);
		Bukkit.getPluginManager().callEvent(bscEventRespawning);
		
		this.worldWrapper.stopRespawn();
		this.cancel();
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:71,代码来源:RespawnRunnable.java


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