A Couple Noob Questions

Discussion in 'Plugin Development' started by mkezar, Oct 23, 2014.

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

    mkezar

    Hello. I Am having several brainfarts. First, when you do player.setHealth(whatever) it sets the health to that amount set. Is there a way to subtract 1 from your current health without "setting the health"?

    Second, Is there a event to test what bioime you are in?

    Thank you for your help. I don't know why I'm having these massive brainfarts...
     
  2. Offline

    fireblast709

    mkezar
    1. damage(double)
    2. event, no. Method, yes.
     
  3. Offline

    mkezar

    fireblast709 wow thank you very much. 1 more question. Is is possible to have a dropped item entity ride on a projectile?
     
  4. Offline

    teej107

    damaging the entity is a solution but it triggers damage events. If you want to set the health, set the health to getHealth() - 1.0
     
  5. Offline

    mkezar

    oh, so when you gethealth -1.0, it gets the health minus 1.0?

    ive been doing some research on the api docs. is there an event that triggers every time a player walks on a block? because i want to have the event every time a player walks that gets triggered, to run the getBiome method and if hes in the desert, to -1 health every X amount of seconds.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  6. Offline

    FabeGabeMC

    mkezar
    if(e.getFrom().getBiome() != e.getTo().getBiome()) should check if the biome the player's in has changed.
    EDIT: Brainfarted.
     
  7. Offline

    mkezar

    FabeGabeMC that must be a bad brainfart.... i can smell it from here.... xD
     
  8. Offline

    fireblast709

    mkezar in the PlayerMoveEvent, check if either the x or z is different (between from and to). If so, they might be standing in a different biome.
     
  9. Offline

    teej107

    someDamageable.setHealth(someDamageable.getHealth() - 1.0);
     
  10. Offline

    mkezar

    teej107 is that the correct code? because someDamageable sounds incorrect in my mind for some reason... :p

    sorry, noob question but how would i test if the x and z changes? im trying double x and double z and if(double x ==) but im having troubles. could you help me a little? (not spoonfeed)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  11. mkezar PlayerMoveEvent has two locations - one which represents the location the player is moving from, and one for the one they're moving to. Compare the values of these locations.
     
  12. Offline

    mkezar

    so what would i do code wise? would i use double? what would i use? :/
     
  13. mkezar I would use getBlockX() and getBlockZ()... if these change between locations, you know they've changed blocks
     
  14. Offline

    mkezar

    so how would i test if it changed? would i do an if statement? or would i just do player.getBlockX()?
     
  15. Offline

    teej107

    someDamageable is the variable that implements the Damageable interface.
     
  16. Yes, an if statement.
     
  17. Offline

    mkezar

    C
    So would it look like,

    If (player.getBlockX()) {

    To see if it got changed?
     
  18. mkezar No... I really recommend you learn the basics of Java from either the Oracle tutorials or a Java book before making plugins :)
     
  19. Offline

    mkezar

    ok. its funny cuz im studying a book atm
     
Thread Status:
Not open for further replies.

Share This Page