本文整理汇总了Java中org.bukkit.Location.setX方法的典型用法代码示例。如果您正苦于以下问题:Java Location.setX方法的具体用法?Java Location.setX怎么用?Java Location.setX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Location
的用法示例。
在下文中一共展示了Location.setX方法的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: onPlayerDamage
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player))
return;
event.setCancelled(true);
if (event.getCause()==DamageCause.VOID) {
Location l = event.getEntity().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));
event.getEntity().teleport(l);
}
}
示例5: tirarhuevo
import org.bukkit.Location; //导入方法依赖的package包/类
/** @EVENTS **/
@EventHandler
public void tirarhuevo(PlayerEggThrowEvent e){
if (e.isHatching()){
Location loc = e.getPlayer().getLocation();
for(int i = 0; i <360; i+=5) {
Location particleloc = loc;
particleloc.setZ(particleloc.getZ() + Math.cos(i) * 0.6);
particleloc.setX(particleloc.getX() + Math.sin(i) * 0.5);
particleloc.setY(particleloc.getY() + 0.05);
loc.getWorld().playEffect(particleloc, Effect.valueOf(plugin.particle), 51);
}
Location location = e.getPlayer().getLocation();
e.getPlayer().playSound(location, Sound.valueOf(plugin.sound), 1, 1);
}
}
示例6: getLocation
import org.bukkit.Location; //导入方法依赖的package包/类
public Location getLocation(Location loc) {
if (loc != null) {
loc.setWorld(world);
loc.setX(x);
loc.setY(y);
loc.setZ(z);
loc.setYaw(0);
loc.setPitch(0);
}
return loc;
}
示例7: getLocation
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public Location getLocation( Location location ) {
location.setX( getX() );
location.setY( getY() );
location.setZ( getZ() );
return location;
}
示例8: nextGridLocation
import org.bukkit.Location; //导入方法依赖的package包/类
/**
* Finds the next free island spot based off the last known island Uses
* island_distance setting from the config file Builds up in a grid fashion
*
* @param lastIsland
* @return Location of next free island
*/
private Location nextGridLocation(final Location lastIsland) {
int x = lastIsland.getBlockX();
int z = lastIsland.getBlockZ();
Location nextPos = lastIsland;
if (x < z) {
if (-1 * x < z) {
nextPos.setX(nextPos.getX() + Settings.islandDistance*2);
return nextPos;
}
nextPos.setZ(nextPos.getZ() + Settings.islandDistance*2);
return nextPos;
}
if (x > z) {
if (-1 * x >= z) {
nextPos.setX(nextPos.getX() - Settings.islandDistance*2);
return nextPos;
}
nextPos.setZ(nextPos.getZ() - Settings.islandDistance*2);
return nextPos;
}
if (x <= 0) {
nextPos.setZ(nextPos.getZ() + Settings.islandDistance*2);
return nextPos;
}
nextPos.setZ(nextPos.getZ() - Settings.islandDistance*2);
return nextPos;
}
示例9: roundToBlock
import org.bukkit.Location; //导入方法依赖的package包/类
private Location roundToBlock(Location loc) {
Location newLoc = loc.clone();
newLoc.setX(Math.floor(loc.getX()) + 0.5);
newLoc.setY(Math.floor(loc.getY()));
newLoc.setZ(Math.floor(loc.getZ()) + 0.5);
return newLoc;
}
示例10: getLocation
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public Location getLocation( Location location ) {
location.setX( this.location.getX() );
location.setY( this.location.getY() );
location.setZ( this.location.getZ() );
location.setYaw( this.location.getYaw() );
location.setPitch( this.location.getPitch() );
return location;
}
示例11: onTeleport
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.NORMAL)
public void onTeleport(PlayerTeleportEvent event) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
Location to = event.getTo();
if (this.blockedTypes.contains(to.getBlock().getType())) {
event.setCancelled(true);
return;
}
to.setX(to.getBlockX() + 0.5D);
to.setZ(to.getBlockZ() + 0.5D);
event.setTo(to);
}
}
示例12: 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));
}
}
示例13: 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;
}
示例14: 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);
}
}
示例15: 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;
}