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


Java Location.distance方法代码示例

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


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

示例1: pullEntityToLocation

import org.bukkit.Location; //导入方法依赖的package包/类
public void pullEntityToLocation(Entity e, Location loc) {
    Location entityLoc = e.getLocation();
    entityLoc.setY(entityLoc.getY() + 0.5D);
    e.teleport(entityLoc);
    double g = -0.08D;
    if (loc.getWorld() != entityLoc.getWorld())
        return;
    double d = loc.distance(entityLoc);
    double t = d;
    double v_x = (1.0D + 0.07000000000000001D * t) * (loc.getX() - entityLoc.getX()) / t;
    double v_y = (1.0D + 0.03D * t) * (loc.getY() - entityLoc.getY()) / t - 0.5D * g * t;
    double v_z = (1.0D + 0.07000000000000001D * t) * (loc.getZ() - entityLoc.getZ()) / t;
    Vector v = e.getVelocity();
    v.setX(v_x);
    v.setY(v_y);
    v.setZ(v_z);
    e.setVelocity(v);
    e.setFallDistance(0f);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:GrappleManager.java

示例2: loadCheckpoints

import org.bukkit.Location; //导入方法依赖的package包/类
private void loadCheckpoints() {
    checkpointSize = Integer.parseInt((String) this.getGameMap().fetchSetting("checkpointRadius"));

    String[] rawCheckpoints = ((String) this.getGameMap().fetchSetting("checkpointLocs")).split(";");

    checkpointLocs = Lists.newArrayList();
    distances = new int[rawCheckpoints.length];
    totalDistance = 0;

    Location previous = start;

    for (int i = 0; i < distances.length; i++) {
        Location location = Utils.parseLocation(rawCheckpoints[i]);
        checkpointLocs.add(location);

        distances[i] = (int) previous.distance(location);
        totalDistance += distances[i];

        previous = location;
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:22,代码来源:HorseRaceGame.java

示例3: onExplosion

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Prevent the Nether spawn from being blown up
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onExplosion(final EntityExplodeEvent e) {
    if (Settings.netherIslands) {
        // Not used in the new nether
        return;
    }
    // Find out what is exploding
    Entity expl = e.getEntity();
    if (expl == null) {
        return;
    }
    // Check world
    if (!e.getEntity().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether")
            || e.getEntity().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
        return;
    }
    Location spawn = e.getLocation().getWorld().getSpawnLocation();
    Location loc = e.getLocation();
    if (spawn.distance(loc) < Settings.netherSpawnRadius) {
        e.blockList().clear();
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:28,代码来源:NetherEvents.java

示例4: flightPath

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Override this class, you can use it to provide particle effects along travel path. 
 * 
 * It is called after all other handling is done. Keep it lightweight
 * 
 * @param start The start location of flight
 * @param end The end location of impact / miss
 * @param type the type of bullet in play
 * @param endOfFlight is the bullet still flying after this or has it impacted?
 */
public void flightPath(Location start, Location end, Bullet type, boolean endOfFlight) {
	// no special flight path stuff. maybe a whizzing sound?

	World world = start.getWorld();
	if (endOfFlight) {
		// make a new sound where it hits.
		world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
	}
	if (type.getFireChance() > 0.0d) {
		if (start != null) {
			double distance = end.distance(start);

			Vector vector = end.subtract(start).toVector();
			vector = vector.multiply(0.1d / distance);
			for (int i = 0; i < distance; i++) {
				world.spawnParticle(Particle.SMOKE_NORMAL, start.add(vector), 5, 0.01, 0.01, 0.01, 0.001);
			}
		}
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:31,代码来源:StandardGun.java

示例5: getKingdomTerritory

import org.bukkit.Location; //导入方法依赖的package包/类
public KingdomType getKingdomTerritory(KingdomFactionsPlayer p) {
	KingdomType type = KingdomType.GEEN;
	if(p.getLocation().getWorld() == Utils.getInstance().getMiningWorld()) {
		return type;
	}
	Location loc = Utils.getInstance().getNewLocation(p.getLocation());
	loc.setY(0);
	   for(Kingdom k : KingdomModule.getInstance().getKingdoms()) {
		   Location spawn = Utils.getInstance().getNewLocation(k.getNexus().getLocation());
		   spawn.setY(0);
		   if(spawn.distance(loc) < ConfigModule.getInstance().getFile(ConfigModule.CONFIG).getConfig().getInt("kingdom.total.protected_region")) {
				   type = k.getType();
		   }
	   }
	return type;


}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:19,代码来源:ProtectionModule.java

示例6: light

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

示例7: MovingTwinkle

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Make a new twinkle with specific color which will move from a to b.
 *
 * @param a First point
 * @param b Second point
 * @param c Color of line
 */
public MovingTwinkle(Location a, Location b, Color c) {
    this.a = a;
    this.b = b;
    this.c = c;
    drawloc = a.clone();
    dist = a.distance(b);
    move = b.toVector().subtract(a.toVector()).multiply(0.5 / dist);
    twinkles.add(this);
}
 
开发者ID:BurnyDaKath,项目名称:OMGPI,代码行数:17,代码来源:MovingTwinkle.java

示例8: distanceFrom

import org.bukkit.Location; //导入方法依赖的package包/类
default double distanceFrom(@Nullable Location deathLocation) {
    if(getOrigin() == null || deathLocation == null) return Double.NaN;

    // When players fall in the void, use y=0 as their death location
    if(deathLocation.getY() < 0) {
        deathLocation = deathLocation.clone();
        deathLocation.setY(0);
    }
    return deathLocation.distance(getOrigin());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:RangedInfo.java

示例9: getDistance

import org.bukkit.Location; //导入方法依赖的package包/类
public double getDistance(KingdomFactionsPlayer p) {
	Location player = Utils.getInstance().getNewLocation(p.getLocation());
	Location nexus = Utils.getInstance().getNewLocation(this.getLocation());
	player.setY(0);
	nexus.setY(0);
	return nexus.distance(player);
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:8,代码来源:Building.java

示例10: getDistance

import org.bukkit.Location; //导入方法依赖的package包/类
public double getDistance(KingdomFactionsPlayer p) {
	Location player = Utils.getInstance().getNewLocation(p.getLocation());
	Location nexus = Utils.getInstance().getNewLocation(this.getPasteLocation());
	player.setY(0);
	nexus.setY(0);
	return nexus.distance(player);
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:8,代码来源:Nexus.java

示例11: getNearbyPlayers

import org.bukkit.Location; //导入方法依赖的package包/类
public List<Player> getNearbyPlayers(Location loc, double radius){
	List<Player> players = new ArrayList<>();
	for(Entity e : loc.getWorld().getEntities()){
		if(e instanceof Player && loc.distance(e.getLocation()) <= radius){
			players.add((Player)e);
		}
	}
	return players;
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:10,代码来源:TribeUtils.java

示例12: getDistanceToMineSpawn

import org.bukkit.Location; //导入方法依赖的package包/类
public int getDistanceToMineSpawn(Location loc) {
	Location loc1 = Utils.getInstance().getNewLocation(miningSpawn);
	Location loc2 = Utils.getInstance().getNewLocation(loc);
	loc1.setY(0);
	loc2.setY(0);
	return (int) loc1.distance(loc2);
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:8,代码来源:Kingdom.java

示例13: goPetToPlayer

import org.bukkit.Location; //导入方法依赖的package包/类
public static void goPetToPlayer(final Player player, final LivingEntity entity) {
    if (!InventoryManager.playerIsLoaded(player) || !player.isOnline() || entity.isDead()) {
        return;
    }

    Location target = player.getLocation();
    if (target.distance(entity.getLocation()) > 20) {
        PetManager.respawnPet(player);
    } else if (target.distance(entity.getLocation()) < 4) {
        return;
    }

    PetType petType = PetManager.getPetFromEntity(entity, player);
    double speedModifier = petType == null ? 1.0 : 0.4 / petType.getSpeed();

    Class<?> entityInsentientClass = MinecraftReflection.getMinecraftClass("EntityInsentient");
    Class<?> navigationAbstractClass = MinecraftReflection.getMinecraftClass("NavigationAbstract");

    try {
        Method getHandle = MinecraftReflection.getCraftEntityClass().getDeclaredMethod("getHandle");
        Object insentient = entityInsentientClass.cast(getHandle.invoke(entity));
        Object navigation = entityInsentientClass.getDeclaredMethod("getNavigation").invoke(insentient);
        navigationAbstractClass.getDeclaredMethod("a", double.class, double.class, double.class, double.class)
                .invoke(navigation, target.getX(), target.getY(), target.getZ(), speedModifier);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        e.printStackTrace();
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:29,代码来源:EntityUtils.java

示例14: onPlayerRespawn

import org.bukkit.Location; //导入方法依赖的package包/类
public void onPlayerRespawn(PlayerRespawnEvent event) {
    if (!plugin.config.handle_player_respawn) {
        return;
    }
    Location respawnLocation = event.getRespawnLocation();
    Location defaultLocation = respawnLocation.getWorld().getSpawnLocation();
    if (respawnLocation.equals(defaultLocation) || respawnLocation.distance(defaultLocation) <= 2) {
        SpawnLocation spawn = plugin.getPlayerSpawn(event.getPlayer());
        event.setRespawnLocation(spawn.getLocation());
        plugin.getLogger().info(I18n.format("log.respawn", event.getPlayer().getName(), spawn.getName()));
    }
}
 
开发者ID:NyaaCat,项目名称:Ourtown,代码行数:13,代码来源:EventListener.java

示例15: gunBulletHitGroundEvent

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * It hit the ground maybe!
 * 
 * @param event the impact event, we ignore any that aren't just blockhits
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void gunBulletHitGroundEvent(ProjectileHitEvent event) {
	if (!EntityType.SMALL_FIREBALL.equals(event.getEntityType()))
		return;
	if (event.getHitBlock() == null)
		return;

	SmallFireball bullet = (SmallFireball) event.getEntity();
	if (!bullet.getName().equals(this.tag))
		return;

	Location end = event.getHitBlock().getLocation().clone().add(0.5, 0.5, 0.5);
	World world = end.getWorld();

	// make a new sound where it hits.
	world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
	
	// make a splash
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.5, 0.0, 0.0), 5);
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add(-0.5, 0.0, 0.0), 5);
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.5, 0.0), 5);
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0,-0.5, 0.0), 5);
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.0, 0.5), 5);
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.0,-0.5), 5);

	Entity hit = event.getEntity();
	if (hit == null) {
		Location start = travelPaths.remove(bullet.getUniqueId());

		if (start != null) {
			double distance = end.distance(start);

			Vector vector = end.subtract(start).toVector();
			vector = vector.multiply(1.0d / distance);
			for (int i = 0; i < distance; i++) {
				world.spawnParticle(Particle.FLAME, start.add(vector), 5);
			}
		}

		bullet.remove();
		return;
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:49,代码来源:RailGun.java


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