当前位置: 首页>>代码示例>>Java>>正文


Java LivingEntity类代码示例

本文整理汇总了Java中org.bukkit.entity.LivingEntity的典型用法代码示例。如果您正苦于以下问题:Java LivingEntity类的具体用法?Java LivingEntity怎么用?Java LivingEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LivingEntity类属于org.bukkit.entity包,在下文中一共展示了LivingEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: damageNearbyEnemies

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
private void damageNearbyEnemies(Player player, int dmg)
{
	Collection<Entity> enemies = player.getLocation().getWorld().getNearbyEntities(player.getLocation().add(0, 0.5, 0), 3.5f, 1.5f, 3.5f);
    for(Entity e : enemies)
    {
    	if(e instanceof LivingEntity && e != (Entity)player)
    	{
    		LivingEntity enemy = (LivingEntity)e;
    		enemy.damage(dmg, (Entity)player);
    	}
    }
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:13,代码来源:Valkyrie.java

示例2: call

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
@Override
public void call(Event event) {
	if (event instanceof EntityDamageByEntityEvent) {
		final EntityDamageByEntityEvent edbe = (EntityDamageByEntityEvent) event;

		if (edbe.getEntity() instanceof LivingEntity) {
			final LivingEntity le = (LivingEntity) edbe.getEntity();

			final Location eye = profile.getPlayer().getEyeLocation();

			final double yawBetween = Helper.getYawBetween(eye, le.getLocation());
			final double playerYaw = profile.getPlayer().getEyeLocation().getYaw();

			final double angleBetween = Math.abs(180 - Math.abs(Math.abs(yawBetween - playerYaw) - 180));

			callback(angleBetween >= DISALLOWED_ANGLE && previousAngles.size() >= NEEDED_SAMPLES
					&& getAverageAngle() >= DISALLOWED_ANGLE);

			previousAngles.put(angleBetween, System.currentTimeMillis());
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:23,代码来源:KillauraC.java

示例3: spawnCompanion

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
/**
 * Spawns a random companion for the player with a random name at the location given
 * @param player
 * @param location
 */
protected void spawnCompanion(Player player, Location location) {
    // Older versions of the server require custom names to only apply to Living Entities
    //Bukkit.getLogger().info("DEBUG: spawning compantion at " + location);
    if (!islandCompanion.isEmpty() && location != null) {
        Random rand = new Random();
        int randomNum = rand.nextInt(islandCompanion.size());
        EntityType type = islandCompanion.get(randomNum);
        if (type != null) {
            LivingEntity companion = (LivingEntity) location.getWorld().spawnEntity(location, type);
            if (!companionNames.isEmpty()) {
                randomNum = rand.nextInt(companionNames.size());
                String name = companionNames.get(randomNum).replace("[player]", player.getName());
                //plugin.getLogger().info("DEBUG: name is " + name);
                companion.setCustomName(name);
                companion.setCustomNameVisible(true);
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:25,代码来源:Schematic.java

示例4: castSpell

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
public void castSpell(final LivingEntity caster, final MobData md, Player target) {
    final Location loc = target.getLocation();
    if (RMath.flatDistance(caster.getLocation(), loc) < 50) {
        RScheduler.schedule(SakiRPG.plugin, new Runnable() {
            public void run() {
                if (target != null && target.isOnline()) {
                    for (Entity e : RMath.getNearbyEntities(loc, 2))
                        if (e instanceof Player)
                            return;
                    md.entity.teleport(loc);
                    md.invuln = System.currentTimeMillis() + 1000;
                }
            }
        });
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:17,代码来源:TeleportSpell.java

示例5: inflictDamage

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
/**
 * Inflicts the given damage on an entity.
 *
 * This method will call the appropriate damage method and fire an {@link EntityDamageEvent}.
 *
 * @param entity Entity to inflict damage upon
 * @param damage Amount of half-hearts of damage to inflict
 * @param info {@link DamageInfo} object that details the type of damage
 * @return the final {@link Damage} object (never null)
 *
 * @throws NullPointerException if entity or info is null
 * throws IllegalArgumentExcpetion if hearts is less than zero
 */
public static @Nonnull
Damage inflictDamage(@Nonnull LivingEntity entity, int damage, @Nonnull DamageInfo info) {
    Preconditions.checkNotNull(entity, "living entity");
    Preconditions.checkArgument(damage >= 0, "damage must be greater than or equal to zero");
    Preconditions.checkNotNull(info, "damage info");

    DamageAPIHelper helper = DamageAPIHelper.get();

    EntityDamageEvent event = new EntityDamageEvent(entity, DamageCause.CUSTOM, damage);
    helper.setEventDamageInfo(event, info);

    Bukkit.getPluginManager().callEvent(event);

    if(event.isCancelled()) {
        return null;
    }

    entity.damage(event.getDamage());

    helper.setEventDamageInfo(event, null);

    return helper.getOurEvent(event).toDamageObject();
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:37,代码来源:DamageAPI.java

示例6: getAmmo

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
/**
 * This figures out if the gun's ammo is in the entity's inventory. 
 * 
 * @param entity the entity to check
 * @return the Bullet type found that is valid for this gun, or null.
 */
public Bullet getAmmo(LivingEntity entity) {
	if (entity == null || !enabled)
		return null;

	ItemStack[] inv;
	if (entity instanceof InventoryHolder) {
		// complex inventory
		InventoryHolder holder = (InventoryHolder) entity;
		inv = holder.getInventory().getContents();
	} else {
		// simple inventory
		inv = entity.getEquipment().getArmorContents();
	}

	if (inv != null) {
		for (ItemStack item : inv) {
			Bullet bullet = AddGun.getPlugin().getAmmo().findBullet(item);
			if (bullet != null && this.allBullets.contains(bullet.getName())) {
				return bullet;
			}
		}
	}
	return null;
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:31,代码来源:StandardGun.java

示例7: getVectorsNormal

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
private ArrayList<Vector> getVectorsNormal(LivingEntity e) {
    ArrayList<Vector> vectors = new ArrayList<Vector>();
    Vector v = e.getEyeLocation().getDirection().normalize();
    v.setY(0);
    vectors.add(v);
    double z = v.getZ();
    double x = v.getX();
    double radians = Math.atan(z / x);
    if (x < 0)
        radians += Math.PI;
    for (int k = 1; k < 4; k++) {
        Vector v2 = new Vector();
        v2.setY(v.getY());
        v2.setX(Math.cos(radians + k * Math.PI / 2));
        v2.setZ(Math.sin(radians + k * Math.PI / 2));
        vectors.add(v2.normalize());
    }
    return vectors;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:QuadBeamSpell.java

示例8: hasGun

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
/**
 * Check if this living entity has a gun of this type already in possession
 * @param entity the entity to check
 * @return true if already in inventory, false otherwise.
 */
public boolean hasGun(LivingEntity entity) {
	if (entity == null || !enabled)
		return false;

	ItemStack[] inv;
	if (entity instanceof InventoryHolder) {
		// complex inventory
		InventoryHolder holder = (InventoryHolder) entity;
		inv = holder.getInventory().getContents();
	} else {
		// simple inventory
		inv = entity.getEquipment().getArmorContents();
	}

	if (inv != null) {
		for (ItemStack item : inv) {
			if (isGun(item)) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:29,代码来源:StandardGun.java

示例9: onPlayerMove

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event)
{
    if (event.getPlayer().getGameMode() != GameMode.ADVENTURE)
        return;

    if (event.getPlayer().getAllowFlight())
        return;

    if (this.hub.getPlayerManager().isBusy(event.getPlayer()))
        return;

    if (((LivingEntity) event.getPlayer()).isOnGround())
    {
        event.getPlayer().setAllowFlight(true);
        this.allowed.add(event.getPlayer().getUniqueId());
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:19,代码来源:DoubleJumpListener.java

示例10: onPlayerMove

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event) {
    Player player = event.getPlayer();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    PlayerWrapper playerWrapper = InventoryManager.get(player);
    if (playerWrapper.hasPet() && playerWrapper.getPet().getPassenger() != player) {
        LivingEntity petEntity = playerWrapper.getPet();
        PetType pet = PetManager.getPetFromEntity(petEntity, player);
        if (pet != null && pet.getRole() != PetType.Role.COMPANION) {
            EntityUtils.goPetToPlayer(player, petEntity);
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:17,代码来源:PetListener.java

示例11: resolve

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent && damageEvent.getCause() == DamageCause.ENTITY_ATTACK) {
        EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) damageEvent;

        if(entityEvent.getDamager() instanceof LivingEntity) {
            LivingEntity attacker = (LivingEntity) entityEvent.getDamager();

            Material weaponMaterial;
            ItemStack held = attacker.getEquipment().getItemInMainHand();
            if(held != null) {
                weaponMaterial = held.getType();
            } else {
                weaponMaterial = Material.AIR;
            }

            return new SimpleMeleeDamageInfo(attacker, weaponMaterial);
        }
    }

    return null;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:23,代码来源:MeleeDamageResolver.java

示例12: disableAI

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
public void disableAI() {
    for (World world : getServer().getWorlds()) {
        if (config.ignored_world.contains(world.getName())) {
            continue;
        }
        if (world.getLivingEntities().size() >= this.config.world_entity) {
            if (!disableAIWorlds.contains(world.getName())) {
                disableAIWorlds.add(world.getName());
                getLogger().info("disable entity ai in " + world.getName());
            }
            for (Chunk chunk : world.getLoadedChunks()) {
                int entityCount = getLivingEntityCount(chunk);
                if (entityCount >= this.config.chunk_entity) {
                    for (Entity entity : chunk.getEntities()) {
                        if (entity instanceof LivingEntity) {
                            setFromMobSpawner((LivingEntity) entity, true);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:NyaaCat,项目名称:Yasui,代码行数:24,代码来源:Main.java

示例13: getLivingEntities

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
public List<LivingEntity> getLivingEntities() {
    List<LivingEntity> list = new ArrayList<LivingEntity>();

    for (Object o : world.loadedEntityList) {
        if (o instanceof net.minecraft.entity.Entity) {
            net.minecraft.entity.Entity mcEnt = (net.minecraft.entity.Entity) o;
            Entity bukkitEntity = mcEnt.getBukkitEntity();

            // Assuming that bukkitEntity isn't null
            if (bukkitEntity != null && bukkitEntity instanceof LivingEntity) {
                list.add((LivingEntity) bukkitEntity);
            }
        }
    }

    return list;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:18,代码来源:CraftWorld.java

示例14: execute

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
@Override
public void execute(KingdomFactionsPlayer player) {

	setLocation(player.getPlayer().getTargetBlock((Set<Material>) null, 80).getLocation());

	SpellExecuteEvent event = new SpellExecuteEvent(executeLocation, this, player);
	if (event.isCancelled())
		return;
	playEffect(executeLocation);
	for (Entity e : Utils.getInstance().getNearbyEntities(executeLocation, 3)) {
		if (e instanceof LivingEntity) {
			LivingEntity en = (LivingEntity) e;

			if (e instanceof Player) {
				Player p = (Player) e;
				if (PlayerModule.getInstance().getPlayer(p).isVanished()) continue;
			    en.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 5 * 20, 1));
			    en.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 5 * 20, 1));
			    en.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5 * 20, 1));
			}
		}
	}

}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:25,代码来源:Confuse.java

示例15: getVectorsFlameWave

import org.bukkit.entity.LivingEntity; //导入依赖的package包/类
private ArrayList<Vector> getVectorsFlameWave(LivingEntity e) {
    ArrayList<Vector> vectors = new ArrayList<Vector>();
    Vector v = e.getEyeLocation().getDirection().normalize();
    v.setY(0);
    vectors.add(v);
    double z = v.getZ();
    double x = v.getX();
    double radians = Math.atan(z / x);
    if (x < 0)
        radians += Math.PI;
    for (int k = 1; k < 24; k++) {
        Vector v2 = new Vector();
        v2.setY(v.getY());
        v2.setX(Math.cos(radians + k * Math.PI / 12));
        v2.setZ(Math.sin(radians + k * Math.PI / 12));
        vectors.add(v2.normalize());
    }
    return vectors;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:SentinelBossGenerator.java


注:本文中的org.bukkit.entity.LivingEntity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。