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


Java World.spawnEntity方法代码示例

本文整理汇总了Java中org.bukkit.World.spawnEntity方法的典型用法代码示例。如果您正苦于以下问题:Java World.spawnEntity方法的具体用法?Java World.spawnEntity怎么用?Java World.spawnEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.World的用法示例。


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

示例1: run

import org.bukkit.World; //导入方法依赖的package包/类
@Override
public void run() {
	// do conversion once:
	if (!convertedToGlobal) {
		targetRegion = new CuboidRegion(parent.toGlobal(targetRegion.getPos1()), parent.toGlobal(targetRegion.getPos2()));
		convertedToGlobal = true;
	}
	
	// spawn as many entities as given by count:
	World world = parent.getPlugin().world;
	for (int nr=0; nr<grp.count; nr++) { 
		
		// use an individual random location, defined by the region of this task.
		// try for a given number of times to find a position not blocked. Give warning if not possible
		int tryNr = 1;
		Location spawnL = new Location(world, 0, 0, 0);
		while (tryNr < MAXSPAWNPOSITIONTRIES) {
			spawnL = BukkitUtil.toLocation(world, Helper.getRandVector(targetRegion));
			if (world.getBlockAt(spawnL).isEmpty()) break;
		}
		if (tryNr == MAXSPAWNPOSITIONTRIES) {
			parent.getPlugin().getLogger().warning("Entity could not be spawned: No free blocks within target region!");
			continue;
		}
		
		// Position is free if code reached here, so spawn:
		spawnL = spawnL.add(new org.bukkit.util.Vector(0.5,0,0.5)); // full qualified name again, meh// 0.5 added for world coord!
		Entity thisEnemy = world.spawnEntity(spawnL, grp.type);		// spawn and get pointer to track it
		if (grp.isTarget) parent.addTrackedEntity(thisEnemy); 		// add to List of tracked entities for BattleRooms to monitor
	}
}
 
开发者ID:TheRoot89,项目名称:DungeonGen,代码行数:32,代码来源:EntitySpawnTask.java

示例2: rewardsChest

import org.bukkit.World; //导入方法依赖的package包/类
public static void rewardsChest(Dungeon dungeon) {
    DungeonBoss db = dungeon.boss;
    World w = db.getLoc().getWorld();
    ArmorStand as = (ArmorStand) w.spawnEntity(db.getLoc().add(0, -1.00, 0), EntityType.ARMOR_STAND);
    as.setGravity(false);
    as.setAI(false);
    as.setVisible(false);
    as.setCustomName(ChatColor.GOLD + "Dungeon Rewards");
    as.setCustomNameVisible(true);
    as.setHelmet(new ItemStack(Material.CHEST));

    ArmorStand as2 = (ArmorStand) w.spawnEntity(db.getLoc().add(0, -0.25, 0), EntityType.ARMOR_STAND);
    as2.setGravity(false);
    as2.setAI(false);
    as2.setVisible(false);
    as2.setCustomName(ChatColor.GREEN + "Disappearing in " + ChatColor.YELLOW + ChatColor.BOLD + "60" + ChatColor.GREEN + "...");
    as2.setCustomNameVisible(true);

    ArmorStand as3 = (ArmorStand) w.spawnEntity(db.getLoc().add(0, -0.50, 0), EntityType.ARMOR_STAND);
    as3.setGravity(false);
    as3.setAI(false);
    as3.setVisible(false);
    as3.setCustomName(ChatColor.GRAY + "[Click to Open]");
    as3.setCustomNameVisible(true);

    db.rewardsStage = true;
    Chunk chunk = as.getLocation().getChunk();
    Chunk chunk2 = as2.getLocation().getChunk();
    Chunk chunk3 = as3.getLocation().getChunk();

    rewardsToBosses.put(as.getUniqueId(), db);
    rewardsToBosses.put(as2.getUniqueId(), db);
    rewardsToBosses.put(as3.getUniqueId(), db);

    RScheduler.schedule(plugin, new Runnable() {
        int counter = 0;
        int sec = 60;

        public void run() {
            if (!chunk.isLoaded() || !chunk2.isLoaded() || !chunk3.isLoaded() || !as.isValid() || !as2.isValid() || !as3.isValid()) {
                db.rewardsStage = false;
                try {
                    as.remove();
                    as2.remove();
                    as3.remove();
                    rewardsToBosses.remove(as.getUniqueId());
                    rewardsToBosses.remove(as2.getUniqueId());
                    rewardsToBosses.remove(as3.getUniqueId());
                    dungeon.boss.spawnSpawner();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return;
            }
            ((CraftArmorStand) as).getHandle().yaw += 10;
            if (counter++ < RTicks.seconds(60)) {
                RScheduler.schedule(plugin, this, 1);
                if (this.counter % 20 == 0)
                    as2.setCustomName(ChatColor.GREEN + "Disappearing in " + ChatColor.YELLOW + ChatColor.BOLD + (--sec) + ChatColor.GREEN + "...");
            } else {
                db.rewardsStage = false;
                as.remove();
                as2.remove();
                as3.remove();
                rewardsToBosses.remove(as.getUniqueId());
                rewardsToBosses.remove(as2.getUniqueId());
                rewardsToBosses.remove(as3.getUniqueId());
                dungeon.boss.spawnSpawner();
            }
        }
    }, 1);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:73,代码来源:DungeonManager.java

示例3: spawnZombie

import org.bukkit.World; //导入方法依赖的package包/类
private void spawnZombie(Location location, World world, MobType mobType){
    Zombie zombie = (Zombie) world.spawnEntity(location, EntityType.ZOMBIE);
    boolean baby = new Random().nextBoolean();

    if (mobType == MobType.NORMAL && baby) zombie.setBaby(true);

    zombie.setMaxHealth(mobType.getHealth());
    zombie.setHealth(zombie.getMaxHealth());

    zombie.setCustomNameVisible(false);
    zombie.setCustomName("Zombie");

    zombie.setFireTicks(0);

    zombie.teleport(location);
}
 
开发者ID:cadox8,项目名称:WC,代码行数:17,代码来源:Mobs.java

示例4: spawnZombieSpecial

import org.bukkit.World; //导入方法依赖的package包/类
public void spawnZombieSpecial(Location location, World world, MobType mobType){
    ZombieVillager zombie = (ZombieVillager) world.spawnEntity(location, EntityType.ZOMBIE_VILLAGER);

    zombie.setMaxHealth(mobType.getHealth());
    zombie.setHealth(zombie.getMaxHealth());

    zombie.setCustomNameVisible(false);
    zombie.setCustomName("Zombie");

    zombie.setFireTicks(0);

    zombie.teleport(location);
}
 
开发者ID:cadox8,项目名称:WC,代码行数:14,代码来源:Mobs.java

示例5: spawnGiant

import org.bukkit.World; //导入方法依赖的package包/类
private void spawnGiant(Location location, World world){
    Giant giant = (Giant) world.spawnEntity(location, EntityType.GIANT);

    giant.setMaxHealth(BossType.GIANT.getHealth());
    giant.setHealth(giant.getMaxHealth());

    giant.setCustomName("Zombie Gigante");

    giant.teleport(location);
}
 
开发者ID:cadox8,项目名称:WC,代码行数:11,代码来源:Mobs.java

示例6: spawnSkeleton

import org.bukkit.World; //导入方法依赖的package包/类
private void spawnSkeleton(Location location, World world){
    Skeleton skeleton = (Skeleton) world.spawnEntity(location, EntityType.SKELETON);

    skeleton.setMaxHealth(BossType.SKELETON.getHealth());
    skeleton.setHealth(skeleton.getMaxHealth());

    double speed = skeleton.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue();
    skeleton.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(speed + 0.2);

    skeleton.setCustomName("QuebrantaHuesos");

    skeleton.getEquipment().setItemInMainHand(new ItemMaker(Material.GOLD_AXE).build());

    skeleton.teleport(location);
}
 
开发者ID:cadox8,项目名称:WC,代码行数:16,代码来源:Mobs.java


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