當前位置: 首頁>>代碼示例>>Java>>正文


Java Location.getY方法代碼示例

本文整理匯總了Java中org.bukkit.Location.getY方法的典型用法代碼示例。如果您正苦於以下問題:Java Location.getY方法的具體用法?Java Location.getY怎麽用?Java Location.getY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.Location的用法示例。


在下文中一共展示了Location.getY方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: set

import org.bukkit.Location; //導入方法依賴的package包/類
public void set(String s, Object o) {
	if (o instanceof Location) {
		Location l = (Location) o;

        String world = l.getWorld().getName();
		double x = l.getX();
		double y = l.getY();
		double z = l.getZ();
		double yaw = l.getYaw();
		double pitch = l.getPitch();

           config.set(s + ".world", world);
           config.set(s + ".x", x);
		config.set(s + ".y", y);
		config.set(s + ".z", z);
		config.set(s + ".yaw", yaw);
		config.set(s + ".pitch", pitch);
	}
	else {
		config.set(s, o);
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:23,代碼來源:ConfigAPI.java

示例2: onEntityDamage

import org.bukkit.Location; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event) {
    if(event.getEntity() instanceof Player) {
        Player victim = (Player) event.getEntity();
        Location location = victim.getBoundingBox().center().toLocation(match.getWorld());
        if(event.getDamage() > 0 && location.getY() >= 0 && !victim.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
            EntityUtils.entities(match.getWorld(), Player.class)
                 .filter(player -> settings.getManager(player).getValue(Settings.BLOOD, Boolean.class, false))
                 .forEach(player -> {
                     if(event instanceof EntityDamageByEntityEvent) {
                         player.playEffect(location, Effect.STEP_SOUND, Material.REDSTONE_WIRE);
                     } else {
                         player.playEffect(location, Effect.STEP_SOUND, Material.LAVA);
                     }
                 });
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:19,代碼來源:BloodMatchModule.java

示例3: serializeLocation

import org.bukkit.Location; //導入方法依賴的package包/類
public static String serializeLocation(Location loc) {
    StringBuilder sb = new StringBuilder();
    sb.append(loc.getX());
    sb.append(LOCATION_DIVIDER);
    if (loc.getY() < 1)
        sb.append("1.0");
    else
        sb.append(loc.getY());
    sb.append(LOCATION_DIVIDER);
    sb.append(loc.getZ());
    sb.append(LOCATION_DIVIDER);
    sb.append(loc.getYaw());
    sb.append(LOCATION_DIVIDER);
    sb.append(loc.getPitch());
    sb.append(LOCATION_DIVIDER);
    sb.append(loc.getWorld().getName());
    return sb.toString();
}
 
開發者ID:edasaki,項目名稱:ZentrelaCore,代碼行數:19,代碼來源:RSerializer.java

示例4: MessageS05SpawnPlayer

import org.bukkit.Location; //導入方法依賴的package包/類
public MessageS05SpawnPlayer( int entityId, UUID uuid, Location location, EntityMetaData metaData ) {
    this.entityId = entityId;
    this.uuid = uuid;
    this.x = location.getX();
    this.y = location.getY();
    this.z = location.getZ();
    this.yaw = location.getYaw();
    this.pitch = location.getPitch();
    this.metaData = metaData;
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:11,代碼來源:MessageS05SpawnPlayer.java

示例5: isInside

import org.bukkit.Location; //導入方法依賴的package包/類
/**
 * Checks if a {@link Location} is inside a square of two other locations
 *
 * @param loc the {@link Location} to check for
 * @param l1  the first corner of the square
 * @param l2  the seconds corner of the square
 * @return
 */
public static boolean isInside(Location loc, Location l1, Location l2) {
    int x1 = Math.min(l1.getBlockX(), l2.getBlockX());
    int y1 = Math.min(l1.getBlockY(), l2.getBlockY());
    int z1 = Math.min(l1.getBlockZ(), l2.getBlockZ());
    int x2 = Math.max(l1.getBlockX(), l2.getBlockX());
    int y2 = Math.max(l1.getBlockY(), l2.getBlockY());
    int z2 = Math.max(l1.getBlockZ(), l2.getBlockZ());

    return loc.getX() >= x1 && loc.getX() <= x2
            && loc.getY() >= y1 && loc.getY() <= y2
            && loc.getZ() >= z1 && loc.getZ() <= z2;
}
 
開發者ID:AlphaHelixDev,項目名稱:AlphaLibary,代碼行數:21,代碼來源:LocationUtil.java

示例6: getPlotAllLocations

import org.bukkit.Location; //導入方法依賴的package包/類
private static Location[] getPlotAllLocations(Location location) {
	double locationY = location.getY();

	double locationX = location.getX();
	double locationZ = location.getZ();

	double[] allLocationX = new double[3];
	allLocationX[0] = (locationX + 1.0D);
	allLocationX[1] = locationX;
	allLocationX[2] = (locationX - 1.0D);

	double[] allLocationZ = new double[3];
	allLocationZ[0] = (locationZ + 1.0D);
	allLocationZ[1] = locationZ;
	allLocationZ[2] = (locationZ - 1.0D);

	Location[] locations = new Location[9];

	World world = location.getWorld();
	byte number = 0;
	double[] arrayOfDouble1;
	int j = (arrayOfDouble1 = allLocationX).length;
	for (int i = 0; i < j; i++) {
		double FOR_locationX = arrayOfDouble1[i];
		double[] arrayOfDouble2;
		int m = (arrayOfDouble2 = allLocationZ).length;
		for (int k = 0; k < m; k++) {
			double FOR_locationZ = arrayOfDouble2[k];
			locations[number] = new Location(world, FOR_locationX, locationY, FOR_locationZ);
			number = (byte) (number + 1);
		}
	}
	return locations;
}
 
開發者ID:Soldier233,項目名稱:SlimefunBugFixer,代碼行數:35,代碼來源:ListenersRes4.java

示例7: contains

import org.bukkit.Location; //導入方法依賴的package包/類
@Override
public boolean contains(Location location) {
    if (Math.sqrt(location.distanceSquared(base)) <= radius) {
        if (location.getY() >= base.getY() && location.getY() <= base.getY() + height) {
            return true;
        }
    }
    return false;
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:10,代碼來源:CylinderRegion.java

示例8: spawnPlayerPacket

import org.bukkit.Location; //導入方法依賴的package包/類
public static Packet spawnPlayerPacket(int entityId, UUID uuid, Location location, Player player) {
    return new PacketPlayOutNamedEntitySpawn(entityId,
                                             uuid,
                                             location.getX(), location.getY(), location.getZ(),
                                             encodeAngle(location.getYaw()),
                                             encodeAngle(location.getPitch()),
                                             copyEntityMetadata(player));
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:9,代碼來源:NMSHacks.java

示例9: updateFakeLocations

import org.bukkit.Location; //導入方法依賴的package包/類
private void updateFakeLocations(Location c) {
    final double y = c.getY() - (FAKE_HEIGHT - PLAYER_HEIGHT) / 2;

    final double h = (width - FAKE_WIDTH) / 2;
    final double px = c.getX() + h;
    final double mx = c.getX() - h;
    final double pz = c.getZ() + h;
    final double mz = c.getZ() - h;

    locations[0].setPosition(mx, y, mz);
    locations[1].setPosition(px, y, mz);
    locations[2].setPosition(mx, y, pz);
    locations[3].setPosition(px, y, pz);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:15,代碼來源:HitboxPlayerFacet.java

示例10: onBlockCanBuild

import org.bukkit.Location; //導入方法依賴的package包/類
@EventHandler
protected void onBlockCanBuild(BlockCanBuildEvent e) {
	if (!e.isBuildable()) {
		Location blockL = e.getBlock().getLocation(); 
		
		boolean allowed = false; 
		
		for (Player target : SkyWarsReloaded.get().getServer().getOnlinePlayers()) {
			if (target.getWorld().equals(e.getBlock().getWorld()) && SkyWarsReloaded.getPC().getPlayer(target.getUniqueId()).isSpectating()) { 
				Location playerL = target.getLocation();
				
				if (playerL.getX() > blockL.getBlockX()-1 && playerL.getX() < blockL.getBlockX()+1) {
					if (playerL.getZ() > blockL.getBlockZ()-1 && playerL.getZ() < blockL.getBlockZ()+1) { 
						if (playerL.getY() > blockL.getBlockY()-2 && playerL.getY() < blockL.getBlockY()+1) {
							if (SkyWarsReloaded.getPC().getPlayer(target.getUniqueId()).isSpectating()) {
								allowed = true;
								target.teleport(e.getBlock().getLocation().add(0, 5, 0), TeleportCause.PLUGIN);
								target.sendMessage(new Messaging.MessageFormatter().withPrefix().format("spectate.teleport-from-block"));
							} else {
								allowed = false;
								break;
							}
						}
					}
				}
				
			}
		}
		e.setBuildable(allowed);
	}
}
 
開發者ID:smessie,項目名稱:SkyWarsReloaded,代碼行數:32,代碼來源:SpectatorListener.java

示例11: 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

示例12: unwrapValue

import org.bukkit.Location; //導入方法依賴的package包/類
@Override
public String unwrapValue(Location location)
{
    return location.getWorld().getName() + ":" + location.getX() + ":" + location.getY() + ":" + location.getZ();
}
 
開發者ID:WoutDev,項目名稱:Mega-Walls,代碼行數:6,代碼來源:LocationScalarTypeConverter.java

示例13: run

import org.bukkit.Location; //導入方法依賴的package包/類
public void run() {
	for (final Player player : Bukkit.getOnlinePlayers()) {
		// Only affect survival and adventure mode players
		if (player.getGameMode() != GameMode.SURVIVAL && player.getGameMode() != GameMode.ADVENTURE) {
			continue;
		}

		// If the player has sunscreen
		if (settings.hasSunscreen(player)) {
			continue;
		}

		// Skip if disabled world.
		final World world = player.getWorld();
		if (settings.isDisabledWorld(world)) {
			continue;
		}

		// If it is raining.
		if (world.hasStorm() || world.isThundering()) {
			continue;
		}

		// If there is a block above them.
		final Location locHead = player.getLocation().add(0, 1, 0);
		final Location locFeet = player.getLocation();

		if (locHead.getY() <= world.getHighestBlockAt(locHead).getY()) {
			continue;
		}

		// If the player is in water
		final Block blockFeet = locFeet.getBlock();
		final Block blockHead = locHead.getBlock();
		if (blockFeet.getType() == Material.WATER || blockFeet.getType() == Material.STATIONARY_WATER
				|| blockHead.getType() == Material.WATER || blockHead.getType() == Material.STATIONARY_WATER) {
			continue;
		}

		// If the light level at the location isn't bright enough
		if (locHead.getBlock().getLightLevel() < 15 && locFeet.getBlock().getLightLevel() < 15) {
			continue;
		}

		// If the player is wearing a helmet.
		if (player.getInventory().getHelmet() != null
				&& player.getInventory().getHelmet().getType() != Material.AIR) {
			continue;
		}

		// Set the player on fire.
		player.setFireTicks(80);
	}
}
 
開發者ID:homiedion,項目名稱:Sunscreen,代碼行數:55,代碼來源:PlayerCombustTask.java

示例14: frezeplayer

import org.bukkit.Location; //導入方法依賴的package包/類
public void frezeplayer(Player p, Player damager){
	Location pl = p.getLocation();
	pl.setX( ( pl.getBlockX()) + 0.5 );
	pl.setZ( ( pl.getBlockZ()) + 0.5 );
	// set ice blocks
	Location locs[] = new Location[7]; // actual locations
	Location bla[] = new Location[7]; // before locations added
	bla[0] = new Location(p.getWorld(), pl.getX(), pl.getY(), pl.getZ());
	bla[1] = new Location(p.getWorld(), pl.getX()+1, pl.getY(), pl.getZ());
	bla[2] = new Location(p.getWorld(), pl.getX()-1, pl.getY(), pl.getZ());
	bla[3] = new Location(p.getWorld(), pl.getX(), pl.getY(), pl.getZ()+1);
	bla[4] = new Location(p.getWorld(), pl.getX(), pl.getY(), pl.getZ()-1);
	bla[5] = new Location(p.getWorld(), pl.getX(), pl.getY()+1, pl.getZ());
	bla[6] = new Location(p.getWorld(), pl.getX(), pl.getY()+2, pl.getZ());
	int arrl = 0;
	for(int k = 0; k < 7; k++){
		if(bla[k].getBlock().getType() == Material.AIR){
			locs[k] = bla[k];
			arrl++;
		}else{
			damager.sendMessage(ChatColor.RED + "Could not freeze player, they are too close to a wall");
			return;
		}
	}
	p.teleport(pl);
	final int arrl2 = arrl;
	final Location flocs[] = locs; // locations, finalled
	Bukkit.getScheduler().runTaskLater(this, new Runnable(){
		public void run() {
			// remove ice blocks
			for(int j = 0; j < arrl2; j++){
				flocs[j].getBlock().setType(Material.AIR);
			}
		}
	}, 40L
	);
	for(int i = 0; i < arrl2; i++){
		locs[i].getBlock().setType(Material.PACKED_ICE);
	}
	p.teleport(pl);
}
 
開發者ID:OverloadedCore,項目名稱:chaoticWeapons,代碼行數:42,代碼來源:Core.java

示例15: strikeLightningEffect

import org.bukkit.Location; //導入方法依賴的package包/類
public LightningStrike strikeLightningEffect(Location loc) {
    net.minecraft.entity.effect.EntityLightningBolt lightning = new net.minecraft.entity.effect.EntityLightningBolt(world, loc.getX(), loc.getY(), loc.getZ(), true);
    world.addWeatherEffect(lightning);
    return new CraftLightningStrike(server, lightning);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:6,代碼來源:CraftWorld.java


注:本文中的org.bukkit.Location.getY方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。