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


Java Entity.getLocation方法代碼示例

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


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

示例1: isInLineOfSight

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
/**
 * @param check
 *            The entity to check whether
 * @param distance
 *            The difference in distance to allow for.
 * @return
 */
private boolean isInLineOfSight(Entity check, double distance) {
	final Location entityLocation = check.getLocation();
	final BlockIterator iterator = new BlockIterator(profile.getPlayer().getEyeLocation(), 0.0, 7);

	while (iterator.hasNext()) {
		final Location current = iterator.next().getLocation();

		if (getLocationDifference(current, entityLocation, "X") < distance
				&& getLocationDifference(current, entityLocation, "Y") < distance
				&& getLocationDifference(current, entityLocation, "Z") < distance) {
			return true;
		}
	}

	// The entity has not been found in the player's line of sight.
	return false;
}
 
開發者ID:davidm98,項目名稱:Crescent,代碼行數:25,代碼來源:KillauraB.java

示例2: pullEntityToLocation

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public void pullEntityToLocation(Entity e, Location loc) {
    Location entityLoc = e.getLocation();
    entityLoc.setY(entityLoc.getY() + 0.5D);
    e.teleport(entityLoc);
    double g = -0.08D;
    if (loc.getWorld() != entityLoc.getWorld())
        return;
    double d = loc.distance(entityLoc);
    double t = d;
    double v_x = (1.0D + 0.07000000000000001D * t) * (loc.getX() - entityLoc.getX()) / t;
    double v_y = (1.0D + 0.03D * t) * (loc.getY() - entityLoc.getY()) / t - 0.5D * g * t;
    double v_z = (1.0D + 0.07000000000000001D * t) * (loc.getZ() - entityLoc.getZ()) / t;
    Vector v = e.getVelocity();
    v.setX(v_x);
    v.setY(v_y);
    v.setZ(v_z);
    e.setVelocity(v);
    e.setFallDistance(0f);
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:20,代碼來源:GrappleManager.java

示例3: handleBuff

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public static void handleBuff(Entity player, Entity e) {
    if (!(player instanceof Player))
        return;
    Player p = (Player) player;
    PlayerDataRPG pd = plugin.getPD(p);
    if (pd != null && buffMap.containsKey(e.getUniqueId())) {
        try {
            Buff buff = buffMap.remove(e.getUniqueId());
            buff.apply(p, pd);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        Location loc = e.getLocation();
        RParticles.showWithOffsetPositiveY(ParticleEffect.EXPLOSION_LARGE, loc, 1.0, 10);
        e.remove();
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:18,代碼來源:BuffManager.java

示例4: onPlayerMoveEvent

import org.bukkit.entity.Entity; //導入方法依賴的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

示例5: execute

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@Override
protected void execute(Event e) {
	Entity ent = entity.getSingle(e);
	Location to = towards.getSingle(e);
	if (ent == null || to == null) {
		return;
	}
	Vector velocity = ent.getVelocity();
	float fallDistance = ent.getFallDistance();
	Location from = ent.getLocation();
	Vector direction = isToward ? MathUtils.vectorFromLocations(from, to) : MathUtils.vectorFromLocations(to, from);
	ent.teleport(new Location(
		ent.getWorld(),
		from.getX(),
		from.getY(),
		from.getZ(),
		MathUtils.notchYaw(MathUtils.getYaw(direction)),
		MathUtils.notchPitch(MathUtils.getPitch(direction))
	));
	ent.setVelocity(velocity);
	ent.setFallDistance(fallDistance);
}
 
開發者ID:Syst3ms,項目名稱:QuarSK,代碼行數:23,代碼來源:EffOrientTowards.java

示例6: teleportPlayer

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public void teleportPlayer(Entity p, int dx, int dy, int dz) {

		NavyCraft.instance.DebugMessage("Teleporting entity " + p.getEntityId(), 4);
		Location pLoc = p.getLocation();
		pLoc.setWorld(craft.world);
		pLoc.setX(pLoc.getX() + dx);
		pLoc.setY(pLoc.getY() + dy + .05);
		pLoc.setZ(pLoc.getZ() + dz);

		if (p instanceof Player) {
			playerTeleports.put((Player) p, pLoc);
		} else {
			p.teleport(pLoc);
		}

	}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:17,代碼來源:CraftMover.java

示例7: onHit

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler
public void onHit(ProjectileHitEvent evt) {
    Projectile projectile = evt.getEntity();
    String customId = projectile.getCustomName();
    if (customId == null || !customId.equals("recreator.structure.turret.tnt")) return;
    
    Location loc;
    Block block = evt.getHitBlock();
    if (block != null) {
        loc = block.getLocation();
        block.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1.8F, true, true);
        return;
    }
    
    Entity entity = evt.getEntity();
    if (entity != null) {
        loc = entity.getLocation();
        entity.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1.8F, true, true);
    }
}
 
開發者ID:Recraft,項目名稱:Recreator,代碼行數:21,代碼來源:StructureTurret.java

示例8: onHit

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@EventHandler
public void onHit(ProjectileHitEvent evt) {
    Projectile projectile = evt.getEntity();
    String customId = projectile.getCustomName();
    if (customId == null || !customId.equals("recreator.item.fatman")) return;
    
    Location loc;
    Block block = evt.getHitBlock();
    if (block != null) {
        loc = block.getLocation();
        block.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 50F, true, true);
        return;
    }
    
    Entity entity = evt.getEntity();
    if (entity != null) {
        loc = entity.getLocation();
        entity.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 50F, true, true);
    }
}
 
開發者ID:Recraft,項目名稱:Recreator,代碼行數:21,代碼來源:ItemFatMan.java

示例9: cast

import org.bukkit.entity.Entity; //導入方法依賴的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: moveToward

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
private void moveToward(Entity entity, Location to, double speed) {
    Location loc = entity.getLocation();
    double x = loc.getX() - to.getX();
    double y = loc.getY() - to.getY();
    double z = loc.getZ() - to.getZ();
    Vector velocity = new Vector(x, y, z).normalize().multiply(-speed);
    entity.setVelocity(velocity);
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:9,代碼來源:BombardmentGame.java

示例11: resolveDamage

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
@Override
public @Nullable FallInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim, @Nullable PhysicalInfo damager) {
    FallState fall = getFall(victim);

    if(fall != null) {
        switch(damageType) {
            case VOID: fall.to = FallInfo.To.VOID; break;
            case FALL: fall.to = FallInfo.To.GROUND; break;
            case LAVA: fall.to = FallInfo.To.LAVA; break;

            case FIRE_TICK:
                if(fall.isInLava) {
                    fall.to = FallInfo.To.LAVA;
                } else {
                    return null;
                }
                break;

            default: return null;
        }

        return fall;
    } else {
        switch(damageType) {
            case FALL:
                return new GenericFallInfo(FallInfo.To.GROUND, victim.getLocation(), victim.getFallDistance());
            case VOID:
                return new GenericFallInfo(FallInfo.To.VOID, victim.getLocation(), victim.getFallDistance());
        }

        return null;
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:34,代碼來源:FallTracker.java

示例12: movePlayer

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public void movePlayer(Entity p, int dx, int dy, int dz) {
	NavyCraft.instance.DebugMessage("Moving player", 4);
	int mccraftspeed = craft.speed;
	if (mccraftspeed > 2) {
		mccraftspeed = 2;
	}

	Vector pVel = p.getVelocity();

	if (dx > 0) {
		dx = craft.speed;
	} else {
		dx = craft.speed * -1;
	}
	if (dy > 0) {
		dy = craft.speed;
	} else {
		dy = craft.speed * -1;
	}
	if (dz > 0) {
		dz = craft.speed;
	} else {
		dz = craft.speed * -1;
	}
	pVel = pVel.add(new Vector(dx, dy, dz));


	if ((pVel.getX() > 10) || (pVel.getZ() > 10) || (pVel.getY() > 10)) {

		System.out.println("Velocity is too high, have to teleport " + p.getEntityId());
		Location pLoc = p.getLocation();
		pLoc.setX(pLoc.getX() + pVel.getX());
		pLoc.setY(pLoc.getY() + pVel.getY() + .05);
		pLoc.setZ(pLoc.getZ() + pVel.getZ());
		p.teleport(pLoc);
	} else {
		p.setVelocity(pVel);
	}
}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:40,代碼來源:CraftMover.java

示例13: getNearbyEntities

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public static ArrayList<Entity> getNearbyEntities(Location loc, double radius) {
    ArrayList<Entity> list = new ArrayList<Entity>();
    ArrayList<Chunk> chunkList = new ArrayList<Chunk>();
    int baseX, baseZ;
    baseX = loc.getChunk().getX();
    baseZ = loc.getChunk().getZ();
    for (int dx = -1; dx <= 1; dx++)
        for (int dz = -1; dz <= 1; dz++)
            chunkList.add(loc.getWorld().getChunkAt(baseX + dx, baseZ + dz));
    for (Chunk chunk : chunkList) {
        for (Entity e : chunk.getEntities()) {
            Location eLoc = e.getLocation();
            if (e instanceof LivingEntity)
                eLoc = eLoc.add(0, ((LivingEntity) e).getEyeHeight() * 0.75, 0);
            double x1 = eLoc.getX();
            double y1 = eLoc.getY();
            double z1 = eLoc.getZ();
            double x2 = loc.getX();
            double y2 = loc.getY();
            double z2 = loc.getZ();
            double xdiff = x1 - x2;
            double ydiff = Math.abs(y1 - y2) - 0.7;
            if (ydiff < 0)
                ydiff = 0;
            double zdiff = z1 - z2;
            double sq = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
            if (sq <= radius * radius)
                list.add(e);
        }
    }
    return list;
}
 
開發者ID:edasaki,項目名稱:ZentrelaCore,代碼行數:33,代碼來源:RMath.java

示例14: getNearbyEntitiesCylinder

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public static ArrayList<Entity> getNearbyEntitiesCylinder(Location loc, double radius, double vertical) {
    ArrayList<Entity> list = new ArrayList<Entity>();
    ArrayList<Chunk> chunkList = new ArrayList<Chunk>();
    int baseX, baseZ;
    baseX = loc.getChunk().getX();
    baseZ = loc.getChunk().getZ();
    for (int dx = -1; dx <= 1; dx++)
        for (int dz = -1; dz <= 1; dz++)
            chunkList.add(loc.getWorld().getChunkAt(baseX + dx, baseZ + dz));
    for (Chunk chunk : chunkList) {
        for (Entity e : chunk.getEntities()) {
            Location eLoc = e.getLocation();
            if (e instanceof LivingEntity)
                eLoc = eLoc.add(0, ((LivingEntity) e).getEyeHeight() * 0.75, 0);
            double x1 = eLoc.getX();
            double y1 = eLoc.getY();
            double z1 = eLoc.getZ();
            double x2 = loc.getX();
            double y2 = loc.getY();
            double z2 = loc.getZ();
            double xdiff = x1 - x2;
            double ydiff = Math.abs(y1 - y2);
            if (ydiff > vertical)
                continue;
            double zdiff = z1 - z2;
            double sq = xdiff * xdiff + zdiff * zdiff;
            if (sq <= radius * radius)
                list.add(e);
        }
    }
    return list;
}
 
開發者ID:edasaki,項目名稱:ZentrelaCore,代碼行數:33,代碼來源:RMath.java

示例15: isInside

import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public boolean isInside(Entity entity) {
    Location loc = entity.getLocation();
    return isInside(loc.getBlockX() >> 4, loc.getBlockZ() >> 4);
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:5,代碼來源:ChunkBoundingBox.java


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