當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。