for (Map.Entry<Vector, Double> neighbor : getNeighbors(current.toLocation( startPoint.getWorld()), materialWeights, Sets.newHashSet(blockedMaterials)).entrySet()) {
neighbor.toLocation(location.getWorld())).getType(); neighbor.add(new Vector(0, -1, 0)).toLocation( location.getWorld())).getType().equals(Material.AIR)) { continue; neighbor.add(new Vector(0, 1, 0)).toLocation( location.getWorld())).getType().isSolid()) { continue;
private boolean safe(ChunkSnapshot chunk, int x, int y, int z, World world) { Vector newSpot = new Vector((chunk.getX() << 4) + x + 0.5D, y + 1, (chunk.getZ() << 4) + z + 0.5D); if (portal) { if (bestSpot == null) { // Stash the best spot bestSpot = newSpot.toLocation(world); } return false; } else { teleportEntity(newSpot.toLocation(world)); return true; } }
public void debug() { for (Player player : Bukkit.getOnlinePlayers()) { for (PathEntry entry : path) { player.sendBlockChange(entry.vector.toLocation(player.getWorld()), YELLOW_FLOWER, (byte) 0); } } }
/** * Pastes the clipboard to island location * @param world - world in which to paste * @param island - location to paste * @param task - task to run after pasting */ public void pasteIsland(World world, Island island, Runnable task) { // Offset due to bedrock Vector off = new Vector(0,0,0); if (blockConfig.contains(BEDROCK)) { String[] offset = blockConfig.getString(BEDROCK).split(","); off = new Vector(Integer.valueOf(offset[0]), Integer.valueOf(offset[1]), Integer.valueOf(offset[2])); } // Calculate location for pasting Location loc = island.getCenter().toVector().subtract(off).toLocation(world); // Paste paste(world, island, loc, task); }
public void update() { if (this.center != null) { if (this.size > 0) { if (this.world == null) { this.world = Bukkit.getWorld("world"); } if (this.world != null) { int lx = this.center.getBlockX() + this.size; int lz = this.center.getBlockZ() + this.size; int px = this.center.getBlockX() - this.size; int pz = this.center.getBlockZ() - this.size; Vector l = new Vector(lx, 0, lz); Vector p = new Vector(px, this.height, pz); this.l = l.toLocation(this.world); this.p = p.toLocation(this.world); } } } }
public synchronized void update() { super.changes(); if (this.center == null) { return; } if (this.size < 1) { return; } if (this.world == null) { this.world = Bukkit.getWorlds().get(0); } if (this.world != null) { int lx = this.center.getBlockX() + this.size; int lz = this.center.getBlockZ() + this.size; int px = this.center.getBlockX() - this.size; int pz = this.center.getBlockZ() - this.size; Vector l = new Vector(lx, 0, lz); Vector p = new Vector(px, this.world.getMaxHeight(), pz); this.firstCorner = l.toLocation(this.world); this.secondCorner = p.toLocation(this.world); } }
public void debugEnd() { for (Player player : Bukkit.getOnlinePlayers()) { for (PathEntry entry : path) { Block block = entry.vector.toLocation(player.getWorld()).getBlock(); player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); } } }
final Location l3 = l2.clone().toVector().add(this.player.getLocation().clone().getDirection().multiply(j)).toLocation(this.player.getWorld()); if (!this.canPlaceBlock(l3.getBlock()) || !this.canPlaceBlock(l2.getBlock()) || !this.canPlaceBlock(l1.getBlock())) { this.left.clear();
final Location r3 = r2.clone().toVector().add(this.player.getLocation().clone().getDirection().multiply(j)).toLocation(this.player.getWorld()); if (!this.canPlaceBlock(r3.getBlock()) || !this.canPlaceBlock(r2.getBlock()) || !this.canPlaceBlock(r1.getBlock())) { this.right.clear();
} else { if (getIslands().hasIsland(getWorld(), targetUUID) || getIslands().inTeam(getWorld(), targetUUID)) { Location warpSpot = getIslands().getIslandLocation(getWorld(), targetUUID).toVector().toLocation(getWorld()); if (getLabel().equals("tpnether")) { warpSpot = getIslands().getIslandLocation(getWorld(), targetUUID).toVector().toLocation(getPlugin().getIWM().getNetherWorld(getWorld())); } else if (getLabel().equals("tpend")) { warpSpot = getIslands().getIslandLocation(getWorld(), targetUUID).toVector().toLocation(getPlugin().getIWM().getEndWorld(getWorld()));
/** * Returns a spot to run to if running in a certain direction. * Returns null if can't reasonable run that direction. */ public static Location findSpotForRunDirection(Location start, double distance, Vector direction) { VectorGoal goal = new VectorGoal(start.clone().add(direction.clone().multiply(distance)), 4); VectorNode startNode = new VectorNode(goal, start, new ChunkBlockSource(start, (float)distance + 10), examiner); Path resultPath = (Path) ASTAR.runFully(goal, startNode, (int)(distance * 50)); if (resultPath == null || resultPath.isComplete()) { return null; } Vector current = resultPath.getCurrentVector(); while (!resultPath.isComplete()) { current = resultPath.getCurrentVector(); resultPath.update(null); } return current.toLocation(start.getWorld()); }
Location to = plugin.getIslands().getIslandAt(e.getFrom()).map(i -> i.getSpawnPoint(Environment.NORMAL)).orElse(e.getFrom().toVector().toLocation(overWorld)); e.setCancelled(true); Location to = plugin.getIslands().getIslandAt(e.getFrom()).map(i -> i.getSpawnPoint(Environment.NETHER)).orElse(e.getFrom().toVector().toLocation(nether)); e.setCancelled(true);
/** * Handle end portals * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEndIslandPortal(PlayerPortalEvent e) { if (!e.getCause().equals(TeleportCause.END_PORTAL) || !plugin.getIWM().inWorld(e.getFrom())) { return; } World overWorld = Util.getWorld(e.getFrom().getWorld()); // If entering a portal in the end, teleport home if you have one, else do nothing if (e.getFrom().getWorld().getEnvironment().equals(Environment.THE_END)) { if (plugin.getIslands().hasIsland(overWorld, e.getPlayer().getUniqueId())) { e.setCancelled(true); plugin.getIslands().homeTeleport(overWorld, e.getPlayer()); } return; } // Going to the end, then go to the same location in the end world if (plugin.getIWM().isEndGenerate(overWorld) && plugin.getIWM().isEndIslands(overWorld)) { World endWorld = plugin.getIWM().getEndWorld(overWorld); // End exists and end islands are being used Location to = plugin.getIslands().getIslandAt(e.getFrom()).map(i -> i.getSpawnPoint(Environment.THE_END)).orElse(e.getFrom().toVector().toLocation(endWorld)); e.setCancelled(true); new SafeSpotTeleport.Builder(plugin) .entity(e.getPlayer()) .location(to) .build(); } }
Location location = corner.toLocation(player.getWorld());
for (double offset = 0.0; offset <= distance; offset += (distance / 25.0)) Block block = playerPostion.clone().add(playerDirection.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
break; } else { newLoc = result.getHitPosition().toLocation(world);