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


Java Location.setYaw方法代码示例

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


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

示例1: setDirection

import org.bukkit.Location; //导入方法依赖的package包/类
public static Location setDirection(Location location, Vector vector) {
    final double _2PI = 2 * Math.PI;
    final double x = vector.getX();
    final double z = vector.getZ();

    if (x == 0 && z == 0) {
        location.setPitch(vector.getY() > 0 ? -90 : 90);
        return location;
    }

    double theta = Math.atan2(-x, z);
    location.setYaw((float) Math.toDegrees((theta + _2PI) % _2PI));

    double x2 = Numbers.square(x);
    double z2 = Numbers.square(z);
    double xz = Math.sqrt(x2 + z2);
    location.setPitch((float) Math.toDegrees(Math.atan(-vector.getY() / xz)));

    return location;
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:21,代码来源:Locations.java

示例2: setNewYaw

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Sets the new yaw
 *
 * @param amount amount
 * @return location
 */
private Location setNewYaw(double amount) {
    double yaw = this.getRotation();
    if (yaw + amount < 0) {
        amount -= yaw;
        yaw = 360;
    }
    if (yaw + amount > 360) {
        amount -= (360 - yaw);
        yaw = 0;
    }
    yaw += amount;
    final double yaw1 = yaw;
    final Location location = this.getLocation();
    location.setYaw((float) yaw1);
    return location;
}
 
开发者ID:Shynixn,项目名称:AstralEdit,代码行数:23,代码来源:SelectionHolder.java

示例3: resetPosition

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Modify the to location of the given event to prevent the movement and
 * move the player so they are standing on the center of the block at the
 * from location.
 */
private static void resetPosition(final PlayerMoveEvent event) {
    Location newLoc;
    double yValue = event.getFrom().getY();

    if(yValue <= 0 || event instanceof PlayerTeleportEvent) {
        newLoc = event.getFrom();
    } else {
        newLoc = BlockUtils.center(event.getFrom()).subtract(new Vector(0, 0.5, 0));
        if(newLoc.getBlock() != null) {
            switch(newLoc.getBlock().getType()) {
            case STEP:
            case WOOD_STEP:
                newLoc.add(new Vector(0, 0.5, 0));
                break;
            default: break;
            }
        }
    }

    newLoc.setPitch(event.getTo().getPitch());
    newLoc.setYaw(event.getTo().getYaw());
    event.setCancelled(false);
    event.setTo(newLoc);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:30,代码来源:PlayerMovementListener.java

示例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);
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:17,代码来源:Events.java

示例5: onPlayerMove

import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
	Gamer g = Gamer.get(event.getPlayer().getName());
	if (Scheduler.getState() == State.WAITING && !g.getBoolean("moveable")) {

		Location to = g.getLocation("spawn-block");
		if (to == null)
			return;
		
		if (Map.getCurrent().getWorld() != g.getPlayer().getWorld()) {
			event.getPlayer().teleport(to);
			return;
		}

		to.setYaw(event.getPlayer().getLocation().getYaw());
		to.setPitch(event.getPlayer().getLocation().getPitch());
		if (to.getBlock().getX() != event.getTo().getBlock().getX())
			event.getPlayer().teleport(to);
		else if (to.getBlock().getZ() != event.getTo().getBlock().getZ())
			event.getPlayer().teleport(to);
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:23,代码来源:Events.java

示例6: clientMoved

import org.bukkit.Location; //导入方法依赖的package包/类
public void clientMoved(final Channel channel, final double x, final double y, final double z, final double rx, final double ry) {
    if (this.entityClass == null) {
        // No bukkit entity, no web-bsaed entity for other players either TODO: synthesize a placeholder entity id for web-to-web only?
        return;
    }

    final Entity entity = this.channelId2Entity.get(channel.id());

    Location location = webSocketServerThread.blockBridge.toBukkitPlayerLocation(x, y, z);

    if (constrainToSandbox && !webSocketServerThread.blockBridge.withinSandboxRange(location)) {
        webSocketServerThread.log(Level.FINEST, "client tried to move outside of sandbox: "+location);
        return;
    }

    // Opposite of PlayerBridge encodeLocation - given negated radians, convert to degrees
    location.setYaw((float)(-rx * 180 / Math.PI));
    location.setPitch((float)(-ry * 180 / Math.PI));

    // Move the surrogate entity to represent where the web player is
    entity.teleport(location);

    // Notify other web clients (except this one) they moved
    webSocketServerThread.broadcastLineExcept(channel.id(), "P,"+entity.getEntityId()+","+webSocketServerThread.playersBridge.encodeLocation(location));
}
 
开发者ID:satoshinm,项目名称:WebSandboxMC,代码行数:26,代码来源:WebPlayerBridge.java

示例7: getLocationNearPlayer

import org.bukkit.Location; //导入方法依赖的package包/类
public static Location getLocationNearPlayer(Player player, int radius) {
    Block playerBlock = player.getLocation().getBlock();
    List<Location> availableLocations = new ArrayList<>();

    World world = player.getWorld();
    for (int x = playerBlock.getX() - radius; x < playerBlock.getX() + radius; x++) {
        for (int y = playerBlock.getY() - radius; y < playerBlock.getY() + radius; y++) {
            for (int z = playerBlock.getZ() - radius; z < playerBlock.getZ() + radius; z++) {
                Location loc = getBlockCenter(new Location(world, x, y, z));
                if (loc.getBlock().isEmpty()) {
                    Block underBlock = loc.clone().subtract(0, 1, 0).getBlock();
                    if (!underBlock.isEmpty() && !underBlock.isLiquid()) {
                        loc.setYaw((float) (-180 + Math.random() * 360));
                        availableLocations.add(loc);
                    }
                }
            }
        }
    }

    if (availableLocations.size() == 0) {
        return getBlockCenter(playerBlock.getLocation().clone());
    }

    return availableLocations.get(new Random().nextInt(availableLocations.size()));
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:27,代码来源:LocationUtils.java

示例8: onPlayerMoveWhenNotLoaded

import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onPlayerMoveWhenNotLoaded(PlayerMoveEvent event) {
    Player player = event.getPlayer();

    if (!InventoryManager.isAllowedWorld(player.getWorld()) || InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (PlayerLoader.isPreparedPlayer(player)) {
        PlayerLoader.removePlayer(player);
        player.kickPlayer(RPGInventory.getLanguage().getMessage("error.rp.denied"));
        event.setCancelled(true);
    } else {
        Location toLocation = event.getTo();
        Location newLocation = event.getFrom().clone();
        //noinspection deprecation
        if (!player.isOnGround()) {
            newLocation.setY(toLocation.getY());
        }

        newLocation.setPitch(toLocation.getPitch());
        newLocation.setYaw(toLocation.getYaw());
        event.setTo(newLocation);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:26,代码来源:PlayerListener.java

示例9: getLocation

import org.bukkit.Location; //导入方法依赖的package包/类
public Location getLocation(Location loc) {
    if (loc != null) {
        loc.setWorld(getWorld());
        loc.setX(x);
        loc.setY(y);
        loc.setZ(z);
        loc.setYaw(0);
        loc.setPitch(0);
    }

    return loc;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:13,代码来源:CraftBlock.java

示例10: onJoin

import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void onJoin(PlayerJoinEvent evt){
    Location l = evt.getPlayer().getLocation().clone();
    l.setYaw(-90);
    evt.getPlayer().teleport(l);
    evt.setJoinMessage("");
    Player p = evt.getPlayer();
    if(ViaVersion.getInstance().isPorted(evt.getPlayer())) {
        ResourcePackAPI.setResourcepack(p,"http://rank.mcndsj.com/texts/CounterStrike19.zip","f1b8ed12b150e86edec5d5ecc28443f905d1f3da");
    }else {
        ResourcePackAPI.setResourcepack(p,"http://rank.mcndsj.com/texts/CounterStrike.zip","f1b8ed12b150e86edec5d5ecc28443f905d1f3da");
    }
}
 
开发者ID:JHXSMatthew,项目名称:CSGO_lobby,代码行数:14,代码来源:PlayerListener.java

示例11: getReturnPoint

import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public Location getReturnPoint(Flag flag, AngleProvider yawProvider) {
    Location location = getReturnPoint(flag);
    if(location instanceof PointProviderLocation && !((PointProviderLocation) location).hasYaw()) {
        location.setYaw(yawProvider.getAngle(location.toVector()));
    }
    return location;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:Post.java

示例12: onPlayerMove

import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event) {
    if(freeze.isFrozen(event.getPlayer())) {
        Location old = event.getFrom();
        old.setPitch(event.getTo().getPitch());
        old.setYaw(event.getTo().getYaw());
        event.setTo(old);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:FreezeListener.java

示例13: lookAt

import org.bukkit.Location; //导入方法依赖的package包/类
public static Location lookAt(Location loc, Location lookat)
{
       //Clone the loc to prevent applied changes to the input loc
       loc = loc.clone();

       // Values of change in distance (make it relative)
       double dx = lookat.getX() - loc.getX();
       double dy = lookat.getY() - loc.getY();
       double dz = lookat.getZ() - loc.getZ();

       // Set yaw
       if (dx != 0)
       {
           // Set yaw start value based on dx
           if (dx < 0)
               loc.setYaw((float) (1.5 * Math.PI));
           else
               loc.setYaw((float) (0.5 * Math.PI));
           
           loc.setYaw((float) loc.getYaw() - (float) Math.atan(dz / dx));
       }
       else if (dz < 0)
           loc.setYaw((float) Math.PI);

       // Get the distance from dx/dz
       double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));

       // Set pitch
       loc.setPitch((float) -Math.atan(dy / dxz));

       // Set values, convert to degrees (invert the yaw since Bukkit uses a different yaw dimension format)
       loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI);
       loc.setPitch(loc.getPitch() * 180f / (float) Math.PI);

       return loc;
   }
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:37,代码来源:Survival.java

示例14: 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;
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:10,代码来源:FlexEntity.java

示例15: lookAt

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Change the yaw & pitch of a {@link Location} to make it look at another {@link Location}
 *
 * @param loc    the {@link Location} which yaw & pitch should be modified
 * @param lookat the {@link Location} to look at
 * @return the new modified {@link Location}
 */
public static Location lookAt(Location loc, Location lookat) {
    loc = loc.clone();
    double dx = lookat.getX() - loc.getX();
    double dy = lookat.getY() - loc.getY();
    double dz = lookat.getZ() - loc.getZ();

    if (dx != 0) {
        if (dx < 0) {
            loc.setYaw((float) (1.5 * Math.PI));
        } else {
            loc.setYaw((float) (0.5 * Math.PI));
        }
        loc.setYaw(loc.getYaw() - (float) Math.atan(dz / dx));
    } else if (dz < 0) {
        loc.setYaw((float) Math.PI);
    }

    double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));

    loc.setPitch((float) -Math.atan(dy / dxz));

    loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI);
    loc.setPitch(loc.getPitch() * 180f / (float) Math.PI);

    return loc;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:34,代码来源:LocationUtil.java


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