Spawn multiple entities at one location

Discussion in 'Plugin Development' started by nrs23, Jan 10, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    nrs23

    How would I spawn 3 horses at the players location.

    so far I've got it so the players in the party all get horses and then set riding their horses, but I want it so for each player 3 donkeys spawn with chests and leads giving each player 3 horses in which he can store stuff.

    The leads aren't important atm just how would I spawn the 3 donkeys per player.


    Code:
                    if (cmd.getName().equalsIgnoreCase("SpawnIn")) {
                        Party party = parties.getParty(player);
                        ArrayList<String> memberNames = party.getMembers();
                        if (!(party == null || party.isEmpty())) {
                            if (party.isLeader(player)) {
                                for(String string : memberNames) {
                                    Player partyMembers = Bukkit.getPlayer(string);
                                    Location playerloc = partyMembers.getLocation();
                                    World world = partyMembers.getWorld();
                                    int packhorse = party.getPartySize() * 3;
                                    Entity horse = world.spawnEntity(playerloc, EntityType.HORSE);
                                    partyMembers.sendMessage("You have spawned in Good luck!");
                                    horse.setPassenger(partyMembers);
                                    //...
                                }
     
  2. Offline

    Wizehh

    Code:java
    1. Entity horse = world.spawnEntity(playerloc, EntityType.HORSE);
    2. Entity horse = world.spawnEntity(playerloc, EntityType.HORSE);
    3. Entity horse = world.spawnEntity(playerloc, EntityType.HORSE);

    Inefficient, but it works.
     
  3. Offline

    xTigerRebornx

    Wizehh Would have to give them different variable names, other then that it "works".
     
  4. Offline

    Wizehh

    xTigerRebornx *Fail*; sorry, didn't even think about that :3
     
  5. Offline

    nrs23

Thread Status:
Not open for further replies.

Share This Page