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


Java Location.getWorld方法代码示例

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


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

示例1: render

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Render calculation
 *
 * @param destroy shouldDestroy
 */
private void render(boolean destroy) {
    if (this.isDestroyed) {
        this.stands = new PacketArmorstand[this.getXWidth()][this.getYWidth()][this.getZWidth()];
        final Location location = this.getDownCornerLocation().toLocation();
        for (int i = 0; i < this.getXWidth(); i++) {
            for (int j = 0; j < this.getYWidth(); j++) {
                for (int k = 0; k < this.getZWidth(); k++) {
                    final Location loc = new Location(location.getWorld(), location.getBlockX() + i, location.getBlockY() + j, location.getBlockZ() + k);
                    if (loc.getBlock().getType() != Material.AIR) {
                        this.stands[i][j][k] = NMSRegistry.createPacketArmorstand(this.player
                                , new Location(loc.getWorld(), loc.getX() + 0.5, loc.getY() - 1.2, loc.getZ() + 0.5), loc.getBlock().getTypeId(), loc.getBlock().getData(), this.watchers);
                        this.stands[i][j][k].spawn();
                    }
                }
            }
        }
        if (destroy) {
            this.destroyBlocks();
        }
        this.isDestroyed = false;
    }
}
 
开发者ID:Shynixn,项目名称:AstralEdit,代码行数:28,代码来源:SelectionHolder.java

示例2: getEntities

import org.bukkit.Location; //导入方法依赖的package包/类
public static List<Entity> getEntities(Location location, double radius) {
    List<Entity> entities = new ArrayList<Entity>();
    World world = location.getWorld();

    // Find chunck by coordinates
    int smallX = MathHelper.floor((location.getX() - radius) / 16.0D);
    int bigX = MathHelper.floor((location.getX() + radius) / 16.0D);
    int smallZ = MathHelper.floor((location.getZ() - radius) / 16.0D);
    int bigZ = MathHelper.floor((location.getZ() + radius) / 16.0D);

    for (int x = smallX; x <= bigX; x++) 
    	for (int z = smallZ; z <= bigZ; z++) 
    		if (world.isChunkLoaded(x, z)) entities.addAll(Arrays.asList(world.getChunkAt(x, z).getEntities()));

    Iterator<Entity> entityIterator = entities.iterator();
    while (entityIterator.hasNext()) 
    	if (entityIterator.next().getLocation().distanceSquared(location) > radius * radius) entityIterator.remove(); 
    
    return entities;
}
 
开发者ID:EpticMC,项目名称:Mob-AI,代码行数:21,代码来源:CommandHandler.java

示例3: destroyAllDuctsOnIsland

import org.bukkit.Location; //导入方法依赖的package包/类
private void destroyAllDuctsOnIsland(Location islandLoc) {
	int dist = 200;
	final Location min = islandLoc.clone().add(-dist, 0, -dist);
	min.setY(0);
	final Location max = islandLoc.clone().add(dist, 0, dist);
	max.setY(max.getWorld().getMaxHeight());

	com.wasteofplastic.acidisland.ASkyBlockAPI skyblockApi = com.wasteofplastic.acidisland.ASkyBlockAPI.getInstance();

	Location tempLoc = new Location(min.getWorld(), 0, 0, 0);
	for (int x = min.getBlockX(); x < max.getBlockX(); x++) {
		for (int y = min.getBlockY(); y < max.getBlockY(); y++) {
			for (int z = min.getBlockZ(); z < max.getBlockZ(); z++) {
				tempLoc.setX(x);
				tempLoc.setY(y);
				tempLoc.setZ(z);
				if (PipeAPI.isDuct(tempLoc, null) && !skyblockApi.islandAtLocation(tempLoc)) {
					PipeAPI.destroyDuct(tempLoc);
				}
			}
		}
	}
}
 
开发者ID:RoboTricker,项目名称:Transport-Pipes,代码行数:24,代码来源:SkyblockAPIUtils.java

示例4: getTopLocation

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

示例5: forEveryPlayerAroundManual

import org.bukkit.Location; //导入方法依赖的package包/类
private static void forEveryPlayerAroundManual(Player viewer, Location loc, double radius, Consumer<Player> callback) {
    World world = loc.getWorld();
    double minX = loc.getX() - radius;
    double minY = loc.getY() - radius;
    double minZ = loc.getZ() - radius;
    double maxX = loc.getX() + radius;
    double maxY = loc.getY() + radius;
    double maxZ = loc.getZ() + radius;

    int chMinX = (int) Math.floor(minX - 2.0) >> 4;
    int chMaxX = (int) Math.floor(maxX + 2.0) >> 4;
    int chMinZ = (int) Math.floor(minZ - 2.0) >> 4;
    int chMaxZ = (int) Math.floor(maxZ + 2.0) >> 4;

    Object bb = BoundingBoxNms.toNms(minX, minY, minZ, maxX, maxY, maxZ);

    for (int chX = chMinX; chX <= chMaxX; chX++) {
        for (int chZ = chMinZ; chZ <= chMaxZ; chZ++) {
            if (world.isChunkLoaded(chX, chZ)) {
                for (Entity t : world.getChunkAt(chX, chZ).getEntities()) {
                    if (t instanceof Player && viewer != t) {
                        if (BoundingBoxNms.intersect(bb, EntityNms.getBoundingBox(t))) {
                            callback.accept((Player) t);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:31,代码来源:PlayerUtil.java

示例6: cloneWith

import org.bukkit.Location; //导入方法依赖的package包/类
public static Location cloneWith(Location original, Vector position) {
    return new Location(original.getWorld(),
                        position.getX(),
                        position.getY(),
                        position.getZ(),
                        original.getYaw(),
                        original.getPitch());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:Locations.java

示例7: Region

import org.bukkit.Location; //导入方法依赖的package包/类
protected Region(String name, Location pos1, Location pos2, int levelMin, int levelMax) {
    if (pos1 != null && pos2 != null) {
        if (pos1.getWorld() != null && pos2.getWorld() != null) {
            if (!pos1.getWorld().getUID().equals(pos2.getWorld().getUID())) {
                throw new IllegalStateException("The 2 locations of the region must be in the same world!");
            }
        } else {
            throw new NullPointerException("One/both of the worlds is/are null!");
        }

        this.worldName = pos1.getWorld().getName();

        double x1 = Math.min(pos1.getX(), pos2.getX());
        double y1 = Math.min(pos1.getY(), pos2.getY());
        double z1 = Math.min(pos1.getZ(), pos2.getZ());
        double x2 = Math.max(pos1.getX(), pos2.getX());
        double y2 = Math.max(pos1.getY(), pos2.getY());
        double z2 = Math.max(pos1.getZ(), pos2.getZ());

        this.min = new Vector(x1, y1, z1);
        this.max = new Vector(x2, y2, z2);
    }

    if (levelMax < 0 || levelMin < 0) {
        throw new IllegalArgumentException("Max/min level cannot be less than 0!");
    }

    if (levelMax < levelMin) {
        throw new IllegalArgumentException("Max level cannot be less than min level!");
    }

    this.levelMin = levelMin;
    this.levelMax = levelMax;
    this.name = name;
    this.npcs = new HashMap<>();
    this.rewards = new ArrayList<>();
    this.id = IDs++;
}
 
开发者ID:Dragovorn,项目名称:OpenRPG,代码行数:39,代码来源:Region.java

示例8: getMaterial

import org.bukkit.Location; //导入方法依赖的package包/类
private Material getMaterial(Location center)
{
    int radius = 2;
    int bX = center.getBlockX();
    int bY = center.getBlockY();
    int bZ = center.getBlockZ();
    int level = 0;
    int x = bX - radius;

    while (x < bX + radius)
    {
        int y = bY - radius;
        while (y < bY + radius)
        {
            int z = bZ - radius;
            while (z < bZ + radius)
            {

                double distance = (bX - x) * (bX - x) + (bZ - z) * (bZ - z) + (bY - y) * (bY - y);
                Location block = new Location(center.getWorld(), (double)x, (double)y, (double)z);
                if (distance < (double)(radius * radius)
                        && (block.getBlock().getType() != Material.BEDROCK)
                        && (block.getBlock().getType() != Material.AIR))
                {
                    if ((level < Priority.getPriority(block.getWorld().getBlockAt(block).getType()).level)
                            &&  ! block.getBlock().hasMetadata("blockBreaker"))
                    {

                        mat = block.getWorld().getBlockAt(block).getType();
                        level = Priority.getPriority(mat).level;
                    }
                } ++ z;
            } ++ y;
        } ++ x;
    }
    return mat;
}
 
开发者ID:ThePhilderbeast,项目名称:prisonPicks,代码行数:38,代码来源:XPickoPlenty.java

示例9: Island

import org.bukkit.Location; //导入方法依赖的package包/类
public Island(Location location, UUID owner, int protectionRange) {
    this.members.add(owner);
    this.owner = owner;
    this.createdDate = System.currentTimeMillis();
    this.updatedDate = System.currentTimeMillis();
    this.world = location.getWorld();
    this.center = location;
    this.range = Settings.islandDistance;
    this.minX = center.getBlockX() - range;
    this.minZ = center.getBlockZ() - range;
    this.protectionRange = protectionRange;
    this.minProtectedX = center.getBlockX() - protectionRange;
    this.minProtectedZ = center.getBlockZ() - protectionRange;
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:15,代码来源:Island.java

示例10: getRandomLocation

import org.bukkit.Location; //导入方法依赖的package包/类
public static Location getRandomLocation(Location player, int Xminimum, int Xmaximum, int Zminimum, int Zmaximum) {
    try {
        World world = player.getWorld();
        double x = Double.parseDouble(
                Integer.toString(Xminimum + ((int) (Math.random() * ((Xmaximum - Xminimum) + 1))))) + 0.5d;
        double z = Double.parseDouble(
                Integer.toString(Zminimum + ((int) (Math.random() * ((Zmaximum - Zminimum) + 1))))) + 0.5d;
        player.setY(200);
        return new Location(world, x, player.getY(), z);
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:15,代码来源:LocationUtil.java

示例11: onBlockBreak

import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreak(final BlockBreakEvent event) {
    Player player = event.getPlayer();
    if (player.getGameMode() != GameMode.CREATIVE) {
        if (player.hasPermission("hcf.listener.autosmeltore")) {
            ItemStack stack = player.getItemInHand();
            if (stack != null && stack.getType() != Material.AIR
                    && !stack.containsEnchantment(Enchantment.SILK_TOUCH)) {
                Block block = event.getBlock();
                Material dropType = null;
                switch (block.getType()) {
                    case IRON_ORE: {
                        dropType = Material.IRON_INGOT;
                        break;
                    }
                    case GOLD_ORE: {
                        dropType = Material.GOLD_INGOT;
                        break;
                    }
                    default: {
                        return;
                    }
                }
                 Location location = block.getLocation();
                 World world = location.getWorld();
                 ItemStack drop = new ItemStack(dropType, 1);
                world.dropItemNaturally(location, drop);
                block.setType(Material.AIR);
                block.getState().update();
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:34,代码来源:AutoSmeltOreListener.java

示例12: teleportSpotDown

import org.bukkit.Location; //导入方法依赖的package包/类
public Location teleportSpotDown(Location loc, int min, int max) {
    int k = min;
    while (k > max) {
    	Material m = new Location(loc.getWorld(), loc.getBlockX(), k - 1, loc.getBlockZ()).getBlock().getType();
        Material m1 = new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ()).getBlock().getType();
        Material m2 = new Location(loc.getWorld(), loc.getBlockX(), (k + 1), loc.getBlockZ()).getBlock().getType();
        if (m1.equals(Material.AIR) && m2.equals(Material.AIR) && m.isSolid() && !m.equals(Material.SIGN_POST) && !m.equals(Material.WALL_SIGN)) {
            return new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ());
        }
        --k;
    }
    return new Location(loc.getWorld(), loc.getBlockX(), loc.getWorld().getHighestBlockYAt(loc.getBlockX(), loc.getBlockZ()), loc.getBlockZ());
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:ElevatorListener.java

示例13: getPipeAtLocation

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Returns the pipe object at the given location or null if there is no pipe.
 */
public static Pipe getPipeAtLocation(Location blockLoc) {
	World world = blockLoc.getWorld();
	BlockLoc bl = new BlockLoc(blockLoc.getBlockX(), blockLoc.getBlockY(), blockLoc.getBlockZ());
	if (TransportPipes.instance.getDuctMap(world) != null) {
		Duct duct = TransportPipes.instance.getDuctMap(world).get(bl);
		return duct != null && duct instanceof Pipe ? (Pipe) duct : null;
	}
	return null;
}
 
开发者ID:RoboTricker,项目名称:Transport-Pipes,代码行数:13,代码来源:PipeAPI.java

示例14: teleportSpotUp

import org.bukkit.Location; //导入方法依赖的package包/类
public Location teleportSpotUp(Location loc, int min, int max) {
    int k = min;
    while (k < max) {
    	Material m = new Location(loc.getWorld(), loc.getBlockX(), k - 1, loc.getBlockZ()).getBlock().getType();
        Material m1 = new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ()).getBlock().getType();
        Material m2 = new Location(loc.getWorld(), loc.getBlockX(), (k + 1), loc.getBlockZ()).getBlock().getType();
        if (m1.equals(Material.AIR) && m2.equals(Material.AIR) && m.isSolid() && !m.equals(Material.SIGN_POST) && !m.equals(Material.WALL_SIGN)) {
            return new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ());
        }
        ++k;
    }
    return new Location(loc.getWorld(), loc.getBlockX(), loc.getWorld().getHighestBlockYAt(loc.getBlockX(), loc.getBlockZ()), loc.getBlockZ());
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:ElevatorListener.java

示例15: face

import org.bukkit.Location; //导入方法依赖的package包/类
public void face(OpenPlayer player) {
    Location to = player.getLocation();

    if (this.entity.getBukkitEntity().getWorld() != to.getWorld()) {
        return;
    }

    Location fromLocation = this.entity.getBukkitEntity().getLocation();

    double xDiff = to.getX() - fromLocation.getX();
    double yDiff = to.getY() - fromLocation.getY();
    double zDiff = to.getZ() - fromLocation.getZ();

    double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
    double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff);

    double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ));
    double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90.0D;

    if (zDiff < 0.0D) {
        yaw += Math.abs(180.0D - yaw) * 2.0D;
    }

    yaw -= 90;

    PlayerConnection connection = player.getConnection();

    connection.sendPacket(new PacketPlayOutEntity.PacketPlayOutEntityLook(this.entity.getId(), getCompressedAngle((float) yaw), getCompressedAngle((float) pitch), true));
    connection.sendPacket(new PacketPlayOutEntityHeadRotation(this.entity, getCompressedAngle((float) yaw)));
}
 
开发者ID:Dragovorn,项目名称:OpenRPG,代码行数:31,代码来源:NPC.java


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