當前位置: 首頁>>代碼示例>>Java>>正文


Java Location.clone方法代碼示例

本文整理匯總了Java中org.bukkit.Location.clone方法的典型用法代碼示例。如果您正苦於以下問題:Java Location.clone方法的具體用法?Java Location.clone怎麽用?Java Location.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.Location的用法示例。


在下文中一共展示了Location.clone方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onChunkLoad

import org.bukkit.Location; //導入方法依賴的package包/類
@EventHandler
public void onChunkLoad(ChunkLoadEvent e) {
	if (!e.isNewChunk())
		return;

	Chunk chunk = e.getChunk();
	int x = chunk.getX() * 16;
	int z = chunk.getZ() * 16;
	int y = chunk.getWorld().getHighestBlockYAt(x + 8, z + 2);

	Location loc = new Location(e.getWorld(), x + 8, y, z + 2);
	Random r = new Random();

	// 0.2% chance of spawning shelter on generating new chunks
	if (r.nextInt(1000) < 2) {
		FalloutShelter s = new FalloutShelter(loc.clone());
		s.generateFalloutShelter();
	}
}
 
開發者ID:kadeska,項目名稱:MT_Core,代碼行數:20,代碼來源:WorldListener.java

示例2: getDirection

import org.bukkit.Location; //導入方法依賴的package包/類
/**
 * Get the arrow corresponding to the location between two given players
 *
 * @param p First player
 * @param mate Second player
 *
 * @return A arrow
 */
protected static String getDirection(Location p, Location mate)
{
    Location ploc = p.clone();
    Location point = mate.clone();

    if (ploc.getWorld().getEnvironment() != point.getWorld().getEnvironment())
        return "•";

    ploc.setY(0);
    point.setY(0);

    Vector d = ploc.getDirection();
    Vector v = point.subtract(ploc).toVector().normalize();

    double a = Math.toDegrees(Math.atan2(d.getX(), d.getZ()));
    a -= Math.toDegrees(Math.atan2(v.getX(), v.getZ()));
    a = (int) (a + 22.5) % 360;

    if (a < 0)
        a += 360;

    return Character.toString("⬆⬈➡⬊⬇⬋⬅⬉".charAt((int) a / 45));
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:32,代碼來源:SurvivalGameLoop.java

示例3: 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

示例4: isSafe

import org.bukkit.Location; //導入方法依賴的package包/類
static boolean isSafe(Location location) {
    Location scratch = location.clone();

    for(int level = 0; level <= 2; level++) {
        scratch.add(-STEVE_WIDTH/2, level, -STEVE_WIDTH/2); // set bottom left corner
        if(!isValidBlock(scratch)) return false;

        scratch.add(0, 0, STEVE_WIDTH); // set top left corner
        if(!isValidBlock(scratch)) return false;

        scratch.add(STEVE_WIDTH, 0, 0); // set top right corner
        if(!isValidBlock(scratch)) return false;

        scratch.add(0, 0, -STEVE_WIDTH); // set bottom right corner
        if(!isValidBlock(scratch)) return false;

        scratch = location.clone(); // reset
    }

    return true;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:22,代碼來源:TutorialStage.java

示例5: teleport

import org.bukkit.Location; //導入方法依賴的package包/類
/**
 * Teleports the object
 *
 * @param location location
 */
void teleport(Location location) {
    final float yaw = this.lastLocation.getYaw();
    this.lastLocation = location.clone();
    this.lastLocation.setYaw(yaw);
    for (int i = 0; i < this.getXWidth(); i++) {
        for (int j = 0; j < this.getYWidth(); j++) {
            for (int k = 0; k < this.getZWidth(); k++) {
                if (this.stands[i][j][k] != null) {
                    final Location loc = new Location(location.getWorld(), location.getX() + i + 0.5, location.getY() + j - 1.2, location.getBlockZ() + k + 0.5);
                    this.stands[i][j][k].teleport(loc);
                }
            }
        }
    }
    this.rotate(0);
}
 
開發者ID:Shynixn,項目名稱:AstralEdit,代碼行數:22,代碼來源:SelectionHolder.java

示例6: 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

示例7: EntityDamageEvent

import org.bukkit.Location; //導入方法依賴的package包/類
public EntityDamageEvent(@Nonnull T entity, @Nonnull Lifetime lifetime, int damage, @Nonnull Location location, @Nonnull Instant time, @Nonnull DamageInfo info) {
    Preconditions.checkNotNull(entity, "entity");
    Preconditions.checkNotNull(lifetime, "lifetime");
    Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero");
    Preconditions.checkNotNull(location, "location");
    Preconditions.checkNotNull(time, "time");
    Preconditions.checkNotNull(info, "damage info");

    this.entity = entity;
    this.lifetime = lifetime;
    this.damage = damage;
    this.location = location.clone();
    this.time = time;
    this.info = info;
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:16,代碼來源:EntityDamageEvent.java

示例8: 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);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:11,代碼來源:CraftWorld.java

示例9: cast

import org.bukkit.Location; //導入方法依賴的package包/類
@Override
public boolean cast(final Player p, PlayerDataRPG pd, int level) {
    if(!pd.isStealthed()) {
        p.sendMessage(ChatColor.RED + "Shadow Warp can only be used while in stealth.");
        return false;
    }
    Vector dir = p.getLocation().getDirection().normalize().multiply(0.3);
    Location start = p.getLocation().add(0, p.getEyeHeight() * 0.75, 0).clone();
    Location curr = start.clone();
    Entity target = null;
    for (int k = 0; k < 30; k++) {
        for (Entity e : RMath.getNearbyEntities(curr, 1.5)) {
            if (e != p) {
                if (Spell.canDamage(e, true)) {
                    target = e;
                    break;
                }
            }
        }
        if(target != null)
            break;
        curr.add(dir);
        if(!RParticles.isAirlike(curr.getBlock()))
            break;
    }
    if (target == null) {
        p.sendMessage(ChatColor.RED + "Failed to find a Shadow Warp target.");
        return false;
    }
    Location loc = target.getLocation();
    loc = loc.add(0, 0.3, 0);
    loc.add(target.getLocation().getDirection().normalize().multiply(-2));
    p.teleport(loc);
    Spell.notify(p, "You teleport behind your target.");
    return true;
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:37,代碼來源:ShadowWarp.java

示例10: cast

import org.bukkit.Location; //導入方法依賴的package包/類
@Override
public boolean cast(final Player p, final PlayerDataRPG pd, final int level) {
    final Location start = p.getLocation().add(0, p.getEyeHeight() * 0.1, 0);
    Location permStart = p.getLocation().add(0, p.getEyeHeight() * 0.1, 0).clone();
    Location loc = start;
    Vector direction = p.getLocation().getDirection().normalize();
    direction.setY(0);
    int length = 5;
    Location prev = null;
    for (int k = 0; k < length; k++) {
        Location temp = loc.clone();
        loc = loc.add(direction);
        if (loc.getBlock().getType().isSolid())
            break;
        prev = temp.clone();
    }
    if (prev != null) {
        RParticles.show(ParticleEffect.EXPLOSION_NORMAL, permStart, 10);
        RParticles.show(ParticleEffect.EXPLOSION_NORMAL, prev, 10);
        p.teleport(prev);
    } else {
        p.sendMessage(ChatColor.RED + "You can't flash through walls!");
        return false;
    }
    Spell.notify(p, "You instantly teleport a short distance.");
    return true;
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:28,代碼來源:FlashI.java

示例11: cast

import org.bukkit.Location; //導入方法依賴的package包/類
@Override
public boolean cast(final Player p, final PlayerDataRPG pd, final int level) {
    final Location start = p.getLocation().add(0, p.getEyeHeight() * 0.1, 0);
    Location permStart = p.getLocation().add(0, p.getEyeHeight() * 0.1, 0).clone();
    Location loc = start;
    Vector direction = p.getLocation().getDirection().normalize();
    direction.setY(0);
    int length = 10;
    Location prev = null;
    for (int k = 0; k < length; k++) {
        Location temp = loc.clone();
        loc = loc.add(direction);
        if (!RParticles.isAirlike(loc.getBlock()))
            break;
        prev = temp.clone();
    }
    if(prev != null) {
        RParticles.show(ParticleEffect.EXPLOSION_NORMAL, permStart, 15);
        RParticles.show(ParticleEffect.EXPLOSION_NORMAL, prev, 15);
        p.teleport(prev);
    } else {
        p.sendMessage(ChatColor.RED + "You can't flash through walls!");
        return false;
    }
    Spell.notify(p, "You instantly teleport a medium distance.");
    return true;
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:28,代碼來源:FlashII.java

示例12: getOpenSpaceAbove

import org.bukkit.Location; //導入方法依賴的package包/類
public static @Nonnull Location getOpenSpaceAbove(@Nonnull Location location) {
    Preconditions.checkNotNull(location, "location");

    Location result = location.clone();
    while(true) {
        Block block = result.getBlock();
        if(block == null || block.getType() == Material.AIR) break;

        result.setY(result.getY() + 1);
    }

    return result;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:14,代碼來源:FireworkUtil.java

示例13: 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;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:10,代碼來源:Post.java

示例14: distanceFrom

import org.bukkit.Location; //導入方法依賴的package包/類
default double distanceFrom(@Nullable Location deathLocation) {
    if(getOrigin() == null || deathLocation == null) return Double.NaN;

    // When players fall in the void, use y=0 as their death location
    if(deathLocation.getY() < 0) {
        deathLocation = deathLocation.clone();
        deathLocation.setY(0);
    }
    return deathLocation.distance(getOrigin());
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:11,代碼來源:RangedInfo.java

示例15: MovingTwinkle

import org.bukkit.Location; //導入方法依賴的package包/類
/**
 * Make a new twinkle with specific color which will move from a to b.
 *
 * @param a First point
 * @param b Second point
 * @param c Color of line
 */
public MovingTwinkle(Location a, Location b, Color c) {
    this.a = a;
    this.b = b;
    this.c = c;
    drawloc = a.clone();
    dist = a.distance(b);
    move = b.toVector().subtract(a.toVector()).multiply(0.5 / dist);
    twinkles.add(this);
}
 
開發者ID:BurnyDaKath,項目名稱:OMGPI,代碼行數:17,代碼來源:MovingTwinkle.java


注:本文中的org.bukkit.Location.clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。