Beispiel #1
0
  public static Entity spawn(Location loc, String name) {
    CraftWorld world = (CraftWorld) loc.getWorld();
    World mcWorld = world.getHandle();
    MobBaseVillager zombie = new MobBaseVillager(mcWorld);

    //		if (name != null) {
    //			zombie.setCustomName(name);
    //			zombie.setCustomNameVisible(true);
    //		}

    zombie.setPosition(loc.getX(), loc.getY(), loc.getZ());
    mcWorld.addEntity(zombie, SpawnReason.CUSTOM);

    return zombie;
  }
Beispiel #2
0
  @Override
  public void run() {
    long worldTime = world.getTime();

    if (worldTime < 13000 || worldTime > 23000) {
      return;
    }

    spawn:
    for (Chunk chunk : world.getLoadedChunks()) {
      if (this.random.nextInt(100) == 1) {
        int x = (chunk.getX() * 16) + this.random.nextInt(12) + 2;
        int z = (chunk.getZ() * 16) + this.random.nextInt(12) + 2;
        int y = world.getHighestBlockYAt(x, z);

        Location spawnLocation = new Location(world, x, y, z);

        for (Entity entity : this.world.getLivingEntities()) {
          if (!entity.isDead() && entity.getLocation().distanceSquared(spawnLocation) < 1024) {
            continue spawn;
          }
        }

        EntityGiantZombie entity = new EntityGiantZombie(world);

        entity.setPositionRotation(x, y, z, 0, 90);
        ((CraftWorld) world).getHandle().addEntity(entity, SpawnReason.CUSTOM);
        entity.p(null);
      }
    }
  }