Pseudo

Discussion in 'Plugin Development' started by Iervolino, Jun 1, 2013.

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

    Iervolino

    When you throw a snowball in a entity you go to the entity position, and the entity go to your last postion...

    Like a switch position!
     
  2. Offline

    inventorman101

    Is this a request or you want help???
     
  3. Offline

    Iervolino


    Like a request, but not a plugin request and yes a pseudo code for see how it works and learn!
     
  4. Offline

    inventorman101

    All you have to do is get the thrower's coords and the entity you hit's coords and the teleport them to eachother
     
  5. Offline

    Iervolino


    Sorry I'm noob but I did this part:

    Code:
    @EventHandler
    public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
        Entity entity = event.getDamager();
        if (entity instanceof Snowball) {
     
    }
     
  6. Offline

    inventorman101

    Ok now you need to get the coords of the damagee and the damager
     
  7. Offline

    Iervolino


    I don't know how to do this.. At least make me this part please!
     
  8. Offline

    Ultimate_n00b

    Snowball sball = event.getDamager();
    if(sball.getShooter() instanceof Player){
    Player p = (Player) sball.getShooter();
    Location one = p.getLocation();
    Location two = event.getEntity().getLocation();
    p.setLocation(two);
    event.getEntity().setLocation(one);
     
  9. Offline

    Iervolino


    Code:
    public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
        Snowball sball = event.getDamager();
        if(sball.getShooter() instanceof Player){
        Player p = (Player) sball.getShooter();
        Location one = p.getLocation();
        Location two = event.getEntity().getLocation();
        p.setLocation(two);
        event.getEntity().setLocation(one);
        }
    }
    Getting this errors:

    *On event.getDamager(); = Type mismatch: cannot convert from Entity to Snowball
    *On setLocation = The method setLocation(Location) is undefined for the type Player
     
  10. Offline

    Garris0n

    @lervolino Check if the damager is a snowball... and it's player.teleport(location)
     
  11. Offline

    Iervolino


    Sorry I don't understood, can you please rewrite and fix the code?
     
  12. Offline

    Ultimate_n00b

    I was typing my code from a iPod, just debug it and fix whatever's broken.
     
  13. Offline

    Garris0n

    I think you really need to learn java/how to debug code if you can't figure that out...I don't want to just give it to you it's your plugin and you need to learn how anyway.
     
  14. Offline

    afistofirony

    Iervolino

    Code:
    public void onEntityDamageByEntity (EntityDamageByEntityEvent event) {
        if (event.getDamager() instanceof Snowball) {
            Snowball sball = (Snowball) event.getDamager();
            if (sball.getShooter() instanceof Player && event.getEntity() instanceof LivingEntity) {
                Player p = (Player) sball.getShooter();
                Location one = p.getLocation();
                Location two = event.getEntity().getLocation();
                p.teleport(two);
                ((LivingEntity) event.getEntity()).teleport(one);
            }
        }
    }
     
    Iervolino likes this.
  15. Offline

    Iervolino


    Sorry, I don't create this thread for suggestions...
     
  16. Offline

    Iervolino


    Worked, thanks!
     
  17. Offline

    Zach_1919

    Iervolino You can't just come on the forums and tell us your plugin isn't working, then just have someone give you code. I bet you took credit for making this, and you didn't even make it, someone else did. If you need someone to do the code for you, go to plugin requests section.
     
  18. Offline

    Iervolino


    1) I don't request a plugin
    2) I don't have a place to put the credits cause this plugin will not be public
    3) Plugin Request section is a plugin request area and not a code request
     
  19. Offline

    Zach_1919

    Iervolino Either way, you asked him to just rewrite the code for you instead of you fixing it yourself based on people's advice.
     
Thread Status:
Not open for further replies.

Share This Page