当前位置: 首页>>代码示例>>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;未经允许,请勿转载。