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


Java Location.setDirection方法代码示例

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


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

示例1: shoot

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * A basic shoot method, it _can_ be overridden but take care.
 * Handles passing the bullet to its BulletType for configuration, sets shooter, velocity, etc.
 * 
 * @param begin The location to shoot from
 * @param bulletType the Bullet type of this bullet
 * @param shooter the entity shooting
 * @param velocity the velocity to use as base for this shooting, if any
 * @param overrideVelocity if true, use the passed velocity and override anything set up by the bullet type.
 * @return the new Projectile that has been unleashed.
 */
public Projectile shoot(Location begin, Bullet bulletType, ProjectileSource shooter, Vector velocity, boolean overrideVelocity) {
	World world = begin.getWorld();
	begin = begin.clone();
	begin.setDirection(velocity);
	Projectile newBullet = world.spawn(begin, bulletType.getProjectileType() );
			
	newBullet.setCustomName(this.bulletTag);
	newBullet.setBounce(false);
	newBullet.setGravity(true);
	newBullet.setShooter(shooter);
	
	bulletType.configureBullet(newBullet, world, shooter, velocity);
	
	if (overrideVelocity) {
		newBullet.setVelocity(velocity);
	}

	return newBullet;
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:31,代码来源:StandardGun.java

示例2: onPlayerMoveEvent

import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent e) {
	for (Entity en : e.getPlayer().getWorld().getEntities()) {
		if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().distance(e.getTo()) <= 1) {
			Location l = en.getLocation();
			//e.getPlayer().sendMessage(getPlayerDirection(e.getPlayer()));
			if (getPlayerDirection(e.getPlayer()).equals("north")) {
				l.add(-1.2, 0, 0);	
			}
			else if (getPlayerDirection(e.getPlayer()).equals("south")) {
				l.add(1.2, 0, 0);	
			}
			else if (getPlayerDirection(e.getPlayer()).equals("east")) {
				l.add(0, 0, -1.2);	
			}
			else if (getPlayerDirection(e.getPlayer()).equals("west")) {
				l.add(0, 0, 1.2);	
			}
			else {
				l = e.getPlayer().getLocation();
			}
			l.setDirection(e.getPlayer().getLocation().getDirection());
			e.setTo(l);
		}
	}
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:27,代码来源:GhostBlock.java

示例3: onCommand

import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender commandSender, Command command, String cmd, String[] args) {
    if (args.length == 2 && commandSender instanceof Player) {
        Player p = (Player) commandSender;
        int x, z;
        try {
            x = Integer.parseInt(args[0]);
            z = Integer.parseInt(args[1]);
        } catch (Exception e) {
            return false;
        }

        if (x >= 0 && x <= 1000 && z >= 0 && z <= 1000) {
            Location l = new Location(p.getWorld(), x, 120, z);
            l.setDirection(p.getLocation().getDirection());
            p.teleport(l);
            return true;
        } else {
            commandSender.sendMessage("x and y should be between 0 and 1000");
            return false;
        }

    }
    return false;
}
 
开发者ID:PlaceDevs,项目名称:placemc,代码行数:26,代码来源:GotoCommand.java

示例4: stepLocation

import org.bukkit.Location; //导入方法依赖的package包/类
private void stepLocation(Entity ent, Location to, double blocksPerTick) {
    if (!ent.isValid())
        return;

    Location from = ent.getLocation();
    World world = from.getWorld();
    Vector fv = new Vector(from.getX(), from.getY(), from.getZ());
    Vector tv = new Vector(to.getX(), to.getY(), to.getZ());

    double bpt = blocksPerTick;
    Vector dv = new Vector(0d, 0d, 0d);
    dv.add(tv);
    dv.subtract(fv);
    Vector nv = dv.clone();
    nv.multiply(1 / dv.length() * bpt);

    if (nv.length() > dv.length())
        return;

    nv.add(fv);
    Location nl = new Location(world, nv.getX(), nv.getY(), nv.getZ());
    nl.setDirection(dv);
    ent.teleport(nl);
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:25,代码来源:ActionEntityPathfind.java

示例5: getYawBetween

import org.bukkit.Location; //导入方法依赖的package包/类
public static double getYawBetween(Location from, Location to) {
	final Location change = from.clone();

	final Vector start = change.toVector();
	final Vector target = to.toVector();

	// Get the difference between the two locations and set this as the
	// direction (the direct line from location to location).
	change.setDirection(target.subtract(start));

	return change.getYaw();
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:13,代码来源:Helper.java

示例6: run

import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public void run()
{
    Location location = new Location(this.center.getWorld(), this.center.getX() + Math.cos(this.i) * RADIUS, this.center.getY() + 1D, this.center.getZ() + Math.sin(this.i) * RADIUS);
    location.setDirection(this.center.clone().subtract(location).toVector().setY(location.getY()));
    location.setPitch(0.0F);

    this.camera.move(location);

    this.i += 0.025D;

    if (this.i > Math.PI * 2.0D)
        this.i = 0.0D;
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:15,代码来源:ClothPreviewTask.java

示例7: 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;
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:11,代码来源:PlayerMock.java

示例8: event

import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void event(PlayerMoveEvent e) {
    if (!GameArea.isInside(e.getTo())) {
        Location old = e.getFrom().getBlock().getLocation().add(0.5, 0, 0.5);
        old.setDirection(e.getFrom().getDirection());
        e.getPlayer().teleport(old);
        e.getPlayer().sendMessage(ChatColor.RED + "You can't go so far!");
    }
}
 
开发者ID:BurnyDaKath,项目名称:OMGPI,代码行数:10,代码来源:BukkitEventHandler.java

示例9: faceEntity

import org.bukkit.Location; //导入方法依赖的package包/类
public static Location faceEntity(Location location, Entity entity) {
    Vector direction = location.toVector().subtract(entity.getLocation().toVector());
    direction.multiply(-1);
    location.setDirection(direction);
    return location;
}
 
开发者ID:redraskal,项目名称:GhostScavengerHunt,代码行数:7,代码来源:LocationUtils.java


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