Quick Question

Discussion in 'Plugin Development' started by GamerzKing, Dec 20, 2015.

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

    GamerzKing

    Hey guys!

    So I am making a game that requires me to make a geyser, however I am having troubles deciding how I should make it, and I was wondering what the best possible method would be.

    So currently, when a player right clicks with a hoe, and they have the water kit, it will spawn an invisible armor stand on the ground. What I want to do, is check when the player is around the armor stand, and set their velocity.

    So I have the armor stand spawned, and I have:

    Code:
                            for(Entity nearbyEntities : armorStand.getNearbyEntities(3, 2, 3)) {
    
                                nearbyEntities.setVelocity(new Vector(0, 0.05, 0));
                            }
    I am just trying to think whether to use a runnable to check the distance, that is repeating, use PlayerMoveEvent, or whatever else. I am not sure what the most efficient way would be.
     
  2. Offline

    Zombie_Striker

    @GamerzKing
    PlayerMoveEvent can get triggered multiple times each second. With a repeating task, it will only run once every specified amount of time (it can be every tick, or every second).
     
  3. Offline

    GamerzKing

    Yes, I understand this, but are there any other solutions that would work better for performance?
     
  4. Offline

    Zombie_Striker

    @GamerzKing
     
  5. Offline

    Xerox262

    PlayerMoveEvent would be the better choice, then check if there are any armor stands within the distance.
     
  6. Offline

    Zombie_Striker

    @Xerox262
    Actually, no. Repeating tasks would be better. If a player stays absolutely still, the event won't fire. If the player moves too fast, then it triggers multiple times a second. Repeating tasks are the best way in terms of performance and memory usage.
     
    BreezerFly likes this.
Thread Status:
Not open for further replies.

Share This Page