BattleWolves

Discussion in 'Plugin Development' started by historio, Jul 5, 2013.

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

    historio

  2. Offline

    GodzOfMadness

    historio If you don't have any experience in making plugins, here is a tutorial. If you don't know java, then I suggest you learn it before making any plugins in general(at least the basics). If you don't know any good sources, pick up a book or watch this list of videos for beginners(This is also suggested on the plugin tutorial page).
     
  3. Offline

    ThunderWaffeMC

    historio Not sure if some of this is possible but otherwise it will be complicated. You should learn simpler plugins before doing something like this (since it looks like it would be your first plugin).
     
  4. Offline

    historio

  5. Offline

    GodzOfMadness

    historio Well in that case, I suggest you to work on the project. If you can't fix a problem that may arise, come back on the forums and we'll try our best to assist you.
     
  6. Offline

    historio

    I don't know anything about Wolves so I need help on that.
     
  7. Offline

    xTrollxDudex

    historio
    Can you be more specific with "on wolves"?
     
  8. Offline

    GodzOfMadness

    historio This is a link to the wolf class from the javadocs. The javadocs will help you alot if you need some answers, go there first.
     
  9. Offline

    historio

  10. Offline

    GodzOfMadness

    historio We gave you what you asked, there is no 'tips' to give other than code for it(unless your more specific on tips like, how should I handle this function).
     
  11. Offline

    historio

  12. Offline

    GodzOfMadness

    historio The purpose of this forum is to 'help' developers with problems that they can't tackle, not a code generator.
     
  13. Offline

    xTrollxDudex

    DAFUUUU!
    historio look here, we can give you advice, we can give you examples, but the forums NEVER show complete code.

    BE SPECIFIC. What specific code section do you need help on?
     
  14. Offline

    historio

    xTrollxDudex When did I ask for a complete code and all I want to know is how to do things with a wolf.

    GodzOfMadness Yeah i know and all I want to know is how to do things with a wolf.

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

    GodzOfMadness

    historio
    Wolf wolf = (Wolf)entity;
    The entity variable would be the wolf(you get it in any way shape or form you want to get it in. For example, when it spawns(CreatureSpawnEvent) just get the entity). Also, read the javadocs post I gave you for the methods it has and what they do.
     
  16. Offline

    xTrollxDudex

    historio
    Look at the java docs. They tell you what you can do with a wolf and how.
     
  17. Offline

    historio

    GodzOfMadness Thank you... just one thing. How do you get a wolf to attack a player automatically? The javadocs don't say anything on that. The wolf has got to be tamed before it can go off to attack. The website doesn't say that.
     
  18. Offline

    xTrollxDudex

    historio
    C'mon look at the java docs...AGAIN. This time very closely. Look at the interfaces section.
    From interface Creature(and from GodzOfMadness)
    Code:java
    1. //loop to find close players, save as "closePlayer"
    2.  
    3. //the wolf, what to work with
    4. Wolf wolf = (Wolf) entity;
    5. //the wolf must be angry at an entity, cast entity on closePlayer
    6. Entity player = (Entity) closePlayer;
    7.  
    8. //the wolf must be angry to attack
    9. wolf.setAngry(true);
    10. //the wolf sets his sights on entity the closest player
    11. wolf.setTarget(player);
     
    GodzOfMadness likes this.
  19. Offline

    GodzOfMadness

    historio No offense, but you should try a bit more. setTarget(..) is a method within the Creature class and here is where it's at.
     
  20. Offline

    historio

    Code:java
    1. }
    2. @EventHandler
    3. public void Stick(CreatureSpawnEvent e) {
    4. Wolf wolf = (Wolf)entity //I get a error here saying "entity cannot be a resolved to a variable";
    5. Entity player = (Entity) closePlayer //I get a error here saying "closePlayer cannot be a resolved to a variable;
    6.  
    7. wolf.setTarget(player);
    8.  
    9. }
    10. }
     
  21. Offline

    GodzOfMadness

    historio Are you sure you don't know the basics of java? Your referencing a variable that doesn't exist.
     
  22. Offline

    historio

  23. Offline

    CreeperShift

    How do you even breathe? :O

    It's giving you an error cuz the variable doesn't exist yet, initialize it. The event spawns more than wolves y'know.
     
  24. Offline

    GodzOfMadness

    historio The variable you are trying to use does not exist.
     
  25. Offline

    xTrollxDudex

    You need to create the entity variable.
    Code:java
    1. //make the wolf tame
    2. @EventHandler
    3. public void onWolfTame(EntityDamageByEntityEvent e){
    4. //check the damaged is player and the damaged entity is a wolf
    5. if(e.getDamager() instanceof Player && e.getEntity() == EntityType.WOLF){
    6. //set it cancelled so the wolf is not hurt
    7. e.setCancelled(true);
    8. //the wolf will be our entity variable
    9. Entity entity = e.getEntity();
    10. //set its owner to the damaged :) to make it follow it
    11. entity.setOwner(e.getDamager());
    12. }
    13. }
    14.  
    15. //define wolf
    16. Wolf wolf = (Wolf) entity
    17.  
    18. //loop to find close players, save as "closePlayer"
    19. for(Entity ents : ((Player) wolf.getOwner()).getNearbyEntities(((Player) wolf.getOwner).getLocation().add(0, 16, 0)){
    20. if(ents instanceof Player){
    21. //this line is wrong I think
    22. Player closePlayer = ents;
    23. }
    24. }
    25.  
    26. //the wolf must be angry at an entity, cast entity on closePlayer
    27. Entity player = (Entity) closePlayer;
    28.  
    29. //the wolf must be angry to attack
    30. wolf.setAngry(true);
    31. //the wolf sets his sights on entity the closest player
    32. wolf.setTarget(player);


    EDIT:
    historio? GodzOfMadness? CreeperShift?
     
  26. Offline

    CreeperShift

    xTrollxDudex and GodzOfMadness like this.
  27. Offline

    GodzOfMadness

  28. Offline

    historio

    GodzOfMadness , xTrollxDudex Sorry for wasting your time but i think i might just keep asking other people to make this plugin.

    p.s if you guys want to make this plugin pm me.

    xTrollxDudex Tried to help me and that's a kind thing to do.

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

    GodzOfMadness

    historio [sheep]
    Think it through before you do something, you might change your mind(like you did right now).
     
  30. Offline

    xTrollxDudex

    Getting a bit annoyed. "Experienced" plugin coder doesn't know about variables >:-(

    GodzOfMadness
    Not sure about line 22 of my recent post. You?
     
Thread Status:
Not open for further replies.

Share This Page