Solved How Could I Do This...?

Discussion in 'Plugin Development' started by AppleBabies, Jan 18, 2016.

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

    AppleBabies

    I'm very, very stumped on this one. So, for this minigame I am creating I need to spawn sheep. The colors of them are white, yellow, green, and blue. 2 blue can spawn per game, 4 green, 8 yellow, and the white never stop spawning. That is no huge deal for me. MY problem is spawning the sheep. Here are the conditions:
    • I cannot use my arena to get it's world, only the player
    • I could spawn it for each player, but then everything would be too laggy and uncontrollable
    • I've tried spawning it in the arena of one Online Player that is in an arena, but the for loop spawns it for everyone.
    So this is kind of the way I'm hoping to do this:
    Code:
    public class SheepSpawner {
    
        public void spawnWhite(){
           
        }
       
        public void spawnYellow(){
           
        }
       
        public void spawnGreen(){
           
        }
       
        public void spawnBlue(){
           
        }
    }
    And then when the game starts, execute the spawnWhite() method. But, again, how can I spawn the sheep controllably - to say, without spawning a sheep for EVERY player?
     
  2. Offline

    Javlin

    Get the start and end x, y and z of the arena. Generate a random number in between the start and end of each pair of coordinates. Check to make sure there is no block where you are spawning them, and if not, spawn one in. Spawn them on a timer, once every so many seconds.
    EDIT: Spawn them on the ground.
     
  3. Offline

    AppleBabies

    @Javlin Yeah, I just remembered I had a spawn location for the arena. Maybe I'll use that. But I don't understand how I can spawn an entity at just a Location. Remember, I don't have a world.
     
  4. Offline

    Javlin

    Then as you said before, just get the world of the player.
     
  5. Offline

    AppleBabies

    @Javlin But I don't want a sheep spawning for EVERY player that's in an arena.
    EDIT: I actually have an idea. I can use the PlayerData to grab the first entry from the list...let me try that.

    @Javlin EDIT No. 2: Nope. Doesn't work. So there's the dilemma of spawning the sheep for every player, which I don't see how that would work.
     
  6. Offline

    Javlin

    What do you mean? If the players are in a list grab the first one and get their world. Create a location (with the random coordinates), and spawn the entity. As I said before, you only do this when the timer activates every so many seconds.
     
  7. Offline

    ShowbizLocket61

    @AppleBabies
    You can use getWorld() on the location to get its world, no need to access a list of players.
    Code:
    location.getWorld().spawnCreature(location, EntityType.SHEEP);
     
  8. Offline

    AppleBabies

    @ShowbizLocket61 Ah, too late. I already have a good system set up. But thank you!
     
Thread Status:
Not open for further replies.

Share This Page