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