本文整理汇总了Java中org.bukkit.Location.setZ方法的典型用法代码示例。如果您正苦于以下问题:Java Location.setZ方法的具体用法?Java Location.setZ怎么用?Java Location.setZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Location
的用法示例。
在下文中一共展示了Location.setZ方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPearlClip
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPearlClip(PlayerTeleportEvent event) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
Location to = event.getTo();
if (blockedPearlTypes.contains(to.getBlock().getType())) {
Player player = event.getPlayer();
player.sendMessage(ChatColor.RED + "You cannot pearl there.");
removeCooldown(player);
event.setCancelled(true);
return;
}
to.setX(to.getBlockX() + 0.5D);
to.setZ(to.getBlockZ() + 0.5D);
event.setTo(to);
}
}
示例2: onPearlClip
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPearlClip(PlayerTeleportEvent event) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
Location to = event.getTo();
if (blockedPearlTypes.contains(to.getBlock().getType())) {
Player player = event.getPlayer();
player.sendMessage(ChatColor.YELLOW + "You have been detected trying to pearl glitch, your pearl has been refunded and cooldown wiped.");
plugin.getTimerManager().getEnderPearlTimer().refund(player);
event.setCancelled(true);
return;
}
to.setX(to.getBlockX() + 0.5);
to.setZ(to.getBlockZ() + 0.5);
event.setTo(to);
}
}
示例3: Region
import org.bukkit.Location; //导入方法依赖的package包/类
public Region(Location pointA, Location pointB) {
Validate.isTrue(pointA.getWorld().equals(pointB.getWorld()), "Two worlds are different.");
double minX = Math.min(pointA.getBlockX(), pointB.getBlockX());
double maxX = Math.max(pointA.getBlockX(), pointB.getBlockX()) + 1;
double minY = Math.min(pointA.getBlockY(), pointB.getBlockY());
double maxY = Math.max(pointA.getBlockY(), pointB.getBlockY());
double minZ = Math.min(pointA.getBlockZ(), pointB.getBlockZ());
double maxZ = Math.max(pointA.getBlockZ(), pointB.getBlockZ()) + 1;
pointA.setX(minX);
pointA.setY(minY);
pointA.setZ(minZ);
pointB.setX(maxX);
pointB.setY(maxY);
pointB.setZ(maxZ);
this.world = pointA.getWorld().getName();
this.min = pointA.toVector();
this.max = pointB.toVector();
}
示例4: teleportPlayer
import org.bukkit.Location; //导入方法依赖的package包/类
public void teleportPlayer(Entity p, int dx, int dy, int dz) {
NavyCraft.instance.DebugMessage("Teleporting entity " + p.getEntityId(), 4);
Location pLoc = p.getLocation();
pLoc.setWorld(craft.world);
pLoc.setX(pLoc.getX() + dx);
pLoc.setY(pLoc.getY() + dy + .05);
pLoc.setZ(pLoc.getZ() + dz);
if (p instanceof Player) {
playerTeleports.put((Player) p, pLoc);
} else {
p.teleport(pLoc);
}
}
示例5: 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);
}
}
}
}
}
示例6: dropItemNaturally
import org.bukkit.Location; //导入方法依赖的package包/类
public org.bukkit.entity.Item dropItemNaturally(Location loc, ItemStack item) {
double xs = world.rand.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double ys = world.rand.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double zs = world.rand.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
loc = loc.clone();
loc.setX(loc.getX() + xs);
loc.setY(loc.getY() + ys);
loc.setZ(loc.getZ() + zs);
return dropItem(loc, item);
}
示例7: getCenterLocation
import org.bukkit.Location; //导入方法依赖的package包/类
public Location getCenterLocation(Location loc1, Location loc2){
Location loc = new Location(loc1.getWorld(), 0, 0, 0);
double x = (loc1.getX() + loc2.getX()) / 2;
double z = (loc1.getZ() + loc2.getZ()) / 2;
loc.setX(x);
loc.setY(loc1.getY());
loc.setZ(z);
return loc;
}
示例8: spawnEntity
import org.bukkit.Location; //导入方法依赖的package包/类
public static void spawnEntity(String player, int challenge, String str, int amount) {
EntityType entity = EntityType.valueOf(str);
Location loc1 = plugin.getChallengesFile().getFirstLocation(challenge);
Location loc2 = plugin.getChallengesFile().getSecondLocation(challenge);
Location spawnLoc = loc1;
for(int i = 0; i < amount; i++) {
spawnLoc.setX(getRandom(loc1.getBlockX(), loc2.getBlockX()));
spawnLoc.setY(getRandom(loc1.getBlockY(), loc2.getBlockY()));
spawnLoc.setZ(getRandom(loc1.getBlockZ(), loc2.getBlockZ()));
Entity e = loc1.getWorld().spawnEntity(spawnLoc, entity);
e.setMetadata("challenge", new FixedMetadataValue(plugin, String.valueOf(challenge) + ", " + player));
}
}
示例9: spawn
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void spawn(final PlayerInitialSpawnEvent event) {
Location location = spawnLocation(event.getWorld());
double radius = spawnRadius(event.getWorld());
Random random = new Random();
// Random point in circle
double angle = random.nextDouble() * Math.PI * 2;
double hyp = random.nextDouble() + random.nextDouble();
hyp = (hyp < 1D ? hyp : 2 - hyp) * radius;
location.setX(Math.cos(angle) * hyp + location.getX());
location.setZ(Math.sin(angle) * hyp + location.getZ());
event.setSpawnLocation(location);
}
示例10: clampToBorder
import org.bukkit.Location; //导入方法依赖的package包/类
public static boolean clampToBorder(Location location) {
WorldBorder border = location.getWorld().getWorldBorder();
Location center = border.getCenter();
double radius = border.getSize() / 2d;
double xMin = center.getX() - radius;
double xMax = center.getX() + radius;
double zMin = center.getZ() - radius;
double zMax = center.getZ() + radius;
boolean moved = false;
if(location.getX() < xMin) {
location.setX(xMin);
moved = true;
}
if(location.getX() > xMax) {
location.setX(xMax);
moved = true;
}
if(location.getZ() < zMin) {
location.setZ(zMin);
moved = true;
}
if(location.getZ() > zMax) {
location.setZ(zMax);
moved = true;
}
return moved;
}
示例11: base
import org.bukkit.Location; //导入方法依赖的package包/类
/**
* Return the "base" {@link Location} of the block at the given location,
* which is the bottom center point on the block (i.e. the location of any
* block-shaped entity that is aligned with the block).
*/
public static Location base(Location location) {
Location center = location.clone();
center.setX(center.getBlockX() + 0.5);
center.setY(center.getBlockY());
center.setZ(center.getBlockZ() + 0.5);
return center;
}
示例12: movePlayer
import org.bukkit.Location; //导入方法依赖的package包/类
public void movePlayer(Entity p, int dx, int dy, int dz) {
NavyCraft.instance.DebugMessage("Moving player", 4);
int mccraftspeed = craft.speed;
if (mccraftspeed > 2) {
mccraftspeed = 2;
}
Vector pVel = p.getVelocity();
if (dx > 0) {
dx = craft.speed;
} else {
dx = craft.speed * -1;
}
if (dy > 0) {
dy = craft.speed;
} else {
dy = craft.speed * -1;
}
if (dz > 0) {
dz = craft.speed;
} else {
dz = craft.speed * -1;
}
pVel = pVel.add(new Vector(dx, dy, dz));
if ((pVel.getX() > 10) || (pVel.getZ() > 10) || (pVel.getY() > 10)) {
System.out.println("Velocity is too high, have to teleport " + p.getEntityId());
Location pLoc = p.getLocation();
pLoc.setX(pLoc.getX() + pVel.getX());
pLoc.setY(pLoc.getY() + pVel.getY() + .05);
pLoc.setZ(pLoc.getZ() + pVel.getZ());
p.teleport(pLoc);
} else {
p.setVelocity(pVel);
}
}
示例13: getLocation
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public Location getLocation(Location loc)
{
loc.setWorld(location.getWorld());
loc.setDirection(location.getDirection());
loc.setX(location.getX());
loc.setY(location.getY());
loc.setZ(location.getZ());
return loc;
}
示例14: onPlayerJoin
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
joinTimes.put(event.getPlayer().getName(), new Date());
event.setJoinMessage(null);
p.setHealth(20);
p.setFoodLevel(20);
p.getInventory().clear();
Location l = event.getPlayer().getWorld().getSpawnLocation();
l.setX(14.5);
l.setY(10.5);
l.setZ(-795.5);
l.setPitch(0.5F);
l.setYaw(90 * RandomUtil.between(1, 4));
p.teleport(l);
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().addItem(Lobby.book);
p.getInventory().addItem(Lobby.compass);
Lobby.addPotionEffect(event.getPlayer(), new PotionEffect(PotionEffectType.SPEED, 2147483647, 2));
if (Gamer.get(p.getName()).getRank().getLevel() >= RankType.ADMIN.getLevel())
event.getPlayer().addAttachment(Lobby.getInstance(), "bukkit.command.gamemode", true);
}
示例15: center
import org.bukkit.Location; //导入方法依赖的package包/类
public static Location center(Location location) {
String x = "" + location.getX();
String z = "" + location.getZ();
if(x.contains(".")) x = x.substring(0, x.indexOf("."));
if(z.contains(".")) z = z.substring(0, z.indexOf("."));
x+=".5";
z+=".5";
location.setX(Double.parseDouble(x));
location.setZ(Double.parseDouble(z));
return resetRotation(location);
}