当前位置: 首页>>代码示例>>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;未经允许,请勿转载。