Enderdragons Unbound - Keep Enderdragons from Flying to Spawn

Discussion in 'Archived: Plugin Requests' started by NazzyDragon, Apr 16, 2012.

  1. Offline

    NazzyDragon

    Like the title says. Enderdragons are bound to spawn (at least in my experience of all of the worlds.. except nether. IDK why nether), and they will fly straight to it of spawned away from it.

    One of my server's new pvp worlds is a skyworld. With dragons. I have the portal spawning issue fixed, but now I need to fix the issues of dragons all flying to the spawn location... it's a bit... err, annoying. Especially when spawn is safezoned, and they take no damage there.



    Thanks in advance! I'm not 100% sure this is possible, but I'm fairly certain. I'll donate $5 if it works and you keep it updated :] err, the "monetary offers" rule is new from since I last came here... uhhhm.. Don't delete my thead please? I just want to tip this poor man ;_; he has done some awesome stuff so far!
     
    tobiyas likes this.
  2. Offline

    tobiyas

    Yeah. It is possible. Just looked in the API.
    What should the target be instead?

    (I hate bad gateway error -_-)

    Hm.. harder than I tought.. -_-
    This could be over my current skills, because I haven't really worked with reflections till now.
    If you find someone else knowing more about it, hooking point would be: net.minecraft.server.EntityEnderDragon.e()
    It uses the function E(). There if the actual target is dead it flies to the spawn.
    I don't know how to hook into this function without several difficult changes...

    If someone knows, please tell me or post a snippet. Maybe someone knows and can help.

    Okay. I think I got it working...
    Where do you want the dragon to go, when he has no targets left?
    Just go back, where he was spawned?

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

    NazzyDragon

    Aye :] You pinned it.


    Shut up and show me your donation button. <3


    Edit: Sorry for not being around when you were asking questions. I had a long day at work today. Thanks so much for whipping something up like this. Combine the two and make it an official plugin. It will be used FREQUENTLY, trust me. If you were to make a config file for it too and allow enabling/disabling of the leashed to spawn/spawning portals, you would have yourself a fantastic plugin. I wouldn't be the only one saying "Shut up and take my money"


    Hm.. for a name.. Enderdragons+ or EnderBoss?
     
  4. Offline

    tobiyas

    Still having some trouble with some functions... But it's getting in the right direction.
    I had to copy 400 lines of code from Notch to actual change 2 vars... not very funny.
    I also noticed Enderdragons always go to a player if he is on the map.
    I'm thinking of a min sight range before attacking.
    So that he will only attack Players in range of 100 blocks or so.
     
    NazzyDragon likes this.
  5. Offline

    NazzyDragon

    This is a good idea. You can merge this with the first one you made to make a nice plugin, correct? I think I might throw money at my screen if ya do. :]
     
  6. Offline

    tobiyas

    Sure. This would be no Problem.
    I actually did this already.
    You can throw your Money wenn it's done, if you like it. ;)

    (Getting off to work)
     
  7. Offline

    NazzyDragon

    Oh, I know I'll like it. My server owner seems pretty ecstatic on the other hand about a plugin to do this though. The portal mess in the end makes a lot of work for admins on our server.. and we had to remove enderdragon bosses from our sky pvp map because of portals cutting holes in our builds. >_<

    Keep this up to date, and people will definitely throw money at the screen. Good luck!


    edit: loltypos
     
  8. Offline

    tobiyas

    Oh yeah... I hope you are using Craftbukkit. :/
    And what Permissions System do you use?
     
  9. Offline

    NazzyDragon

    Of COURSE I'm using cbukkit.

    We use PEX (PermissionsEX)

    You can log into our server and poke around /pl if you want to check for possible conflicts or things to add/tweak. We're up all the time, and I'll be sure to say hi. ;P
     
  10. Offline

    tobiyas

    Sitting in University and listending to maths...
    Not the best time.. But later for sure.
     
  11. Offline

    NazzyDragon

    Haha. You're terrible. You must be in a far different timezone than me, considering it is 2am here. Contacting you will be fun *sarcasm*.

    (Try to) have fun in class. :p
     
  12. Offline

    tobiyas

    Germany. It's 8:30 am ;)

    Back to the plugin, are there othe config options I should add?
    I thought about the amount of exp a dragon drops.
    Also I will add is: if a dragon flies to far away from his "home" location he will just turn around and fly to it.
    To prevent players kiting it to... well somewhere where he doesn't want to be ;)
     
  13. Offline

    NazzyDragon

    If you'd like to add the EXP as a config, but I think it drops enough as is. That's optional. I personally just want to see this asap, as my server owner is waiting on the condensed plugin here rather than using the first you whipped up.

    I don't think the home location is too applicable to my server, but definitely to others. Make the distance from home (in blocks) configurable, and that would be a solid start.
     
  14. Offline

    tobiyas

    I guess I might have finished...
    It works on my private Server. (Without spaming logs anymore... :confused:)
    link

    commands:
    /spawnenderdragon (alias: sedp) Spawns an Enderdragon taged by the plugin.
    /killenderdragons [range] (alias: kedp) Kills all Enderdragons (created by the plugin) in the given range.
    /edpreload reloads config
    /edpgohome (alias: edpgh) sends all Enderdragons to their homes (If they don't want to by nature ;) )

    PermissionNodes:
    /spawnenderdragon = "edplus.create"
    /killenderdragons = "edplus.kill"
    /edpgohome = "edplus.commandback"
    /edpreload = "edplus.reloadconfig"
     
  15. Offline

    NazzyDragon

    Tested this with a naturally spawned enderdragon, or dragons from spawners?
     
  16. Offline

    tobiyas

    They are not effected.
    It only effects dragons spawned over the command.

    Found an big unhealthy error.
    Gonna fix it tomorrow.
    Unique IDs are not as unique as I thought... lol. (sense?)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  17. Offline

    NazzyDragon

    Awesome! Hope to see a finished plugin soon.
     
  18. Offline

    tobiyas

    Got it to work with DragonTravel.
    Same link.
    Added config option for : life of dragon and if the plugin should replace all other spawned dragons.
    Added conpability to DragonTravel. (these dragons will never be replaced)!
    Included config for debug outputs (do not activate it, if you don't want your log spammed HARD!)
     
    NazzyDragon likes this.
  19. Offline

    NazzyDragon

    I will test this out personally tonight, then send it to my server owner to test. Let you know if we find any bugs! (It will probably be installed tomorrow afternoon/evening EST)

    Thanks!

    Actually, if you can configure the health, would it be possible to configure the damage it does?


    Just curious.



    EDIT: Just tested. I LOVE this plugin, fantastic work! Make it official, and I'm sure it'll catch on! ^_^

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  20. Offline

    tobiyas

    Added it.
    It now can be edited in the config. (10 is normal)
    Same download link
     
  21. Offline

    HappyPikachu

    tobiyas

    How did you go about preventing the dragons from targeting the player when necessary? Last time I checked, setCancelled(true) doesn't work properly for Enderdragons through EntityTargetEvent.
     
  22. Offline

    tobiyas

    Created a new Class inherited from EntityEnderdragon in the Minecraft code. (net.minecraft.sever.EntityEnderdragon)
    Then just override the Methode: e(). This is the logic controller of the Enderdragon.
    At least inject the class into net.minecraft.server.EntityType by making the methode a() visable and registering through this methode your new Enderdragon class.

    Guess that was all :) (There is no way at the moment using bukkit code.)
     
  23. Offline

    NazzyDragon

    Apparently there is an issue with this plugin, according to my server owner. I'll get back to you when he tells me what it is. He had to remove the plugin temporarily, apparently.

    @tobiyas - Your plugin caused all of the DragonTravel signs to spawn a dragon instead of mount one, according to our players... (d'oh!)


    Edit: I cannot seem to replicate the error on my server. Not sure what's up. We'll see.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  24. Offline

    HappyPikachu

    Oh, wow - that wasn't the answer I was expecting. Very nice work!

    Would you mind if I took a peek at the source code for this? I'm in the process of helping out on the same server as the OP here and I've got some suspicions as to what might be going wrong.
     
  25. Offline

    NazzyDragon

    @HappyPikachu He's in germany, so he's likely asleep for now.


    Any help with what the hell is going wrong would be appreciated. I failed to re-create the error on my personal server... and djurg is MIA, even though it says he's on steam.
     
  26. Offline

    tobiyas

    HappyPikachu
    Sure. Take a look I think jdGui gives the write code.
    I'm not happy with the datacontainer as it is, but it gets better.
    Just hating the state to control

    NazzyDragon
    hm. I have no Idea where to start searching :D
    (yeah I was sleeping ^^)
     
  27. Well, either he's just killing a spawning dragon and replacing it with the modified one, so the DragonTravel dragon (which is a modified EnderDragon overwriting e(), too) gets replaced, too, or he did a mistake registering the modified dragon at the servers entity list. Here's how RideThaDragon does it: method.invoke(EntityTypes.class, V10Dragon.class, "V10Dragon", 63); - DragonTravel does something similar (method.invoke(EntityTypes.class, DTDragon.class, "DTDragon", 63); or something like that). As the devs of DragonTravel and me exchange many tips and tricks for the modified dragons we know that it's important to not have "EnderDragon" at the 3rd argument cause it may overwrite normal dragon spawning. Also the classes have to be called differently. So if he just copy&pasted from DTDragon he has to rename the class and the string argument to avoid conflicts.

    BTW, tobiyas if you use RTD or DT codes, make sure to not violate the GPL. ;)
     
  28. Offline

    tobiyas

    I found it myself.
    But actualy this is the way i use it.
    Yes. I cast the dragon to an XemDragon (Dragon Travel) If it works, well it is from DragonTravel.
    It works for me localy, so it must conflict with some other plugin.
    I just have to get wich one to build a workaround.

    (I'll use GPL, too, so it should be no Problem)
     
  29. tobiyas Why do you cast it to a XemDragon? Just use your own class which extends net.minecraft.server.EntityEnderDragon directly. For example let's call it TobyDragon.class. Then you'll have to add it to minecrafts entity map: method.invoke(EntityTypes.class, TobyDragon.class, "TobyDragon", 63);
    Meaning that it works locally doesn't mean that much. The map type of the entities is a HashMap: "This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time." (source: http://docs.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html).

    If you need some help feel free to PM me your skype name,. but right now I'm a bit busy writing a new core for BukkitHTTPD. ;)
     
  30. Offline

    tobiyas

    I've done this already. What I meant was Identifiing dragons from DragonTavel.
    My injection method works perfectly.
    Code:
    Method method = EntityTypes.class.getDeclaredMethod("a", new Class[] { Class.class, String.class, Integer.TYPE });
              method.setAccessible(true);
              method.invoke(
                      EntityTypes.class, new Object[] {
                          LimitedEnderDragon.class,
                          "LimitedEnderDragon",
                          Integer.valueOf(63)
                      });
    The plugin itself totally works.
    It works with DragonTravel itself.
    There is just some other plugin wich makes my replace methode not work.
    I don't get how.

    Code:
    @EventHandler(priority = EventPriority.LOWEST)
        public void replaceDragon(CreatureSpawnEvent event){
            if(event.isCancelled()) return;
            if(!event.getEntityType().equals(EntityType.ENDER_DRAGON)) return;
            if(!plugin.interactConfig().getconfig_replaceAllDragons()) return;
           
            if(plugin.interactConfig().getconfig_debugOutput())
                plugin.log("enderdragon id: " + event.getEntity().getEntityId());
           
            int id = event.getEntity().getEntityId();
            if(plugin.getContainer().containsID(id)) return;
           
            if(plugin.interactConfig().getconfig_debugOutput())
                plugin.log("id detection failed.");
           
            try{
                if(plugin.useDTBridge()){
                    DragonTravelMain otherPlugin = (DragonTravelMain) plugin.getServer().getPluginManager().getPlugin("DragonTravel");
                    if(otherPlugin != null){
                        EntityEnderDragon dragon = ((CraftEnderDragon) event.getEntity()).getHandle();
                        if(dragon instanceof XemDragon) return;
                    }
                }
            }catch(Exception e){}
           
            spawnLimitedDragon(event.getLocation());
            event.setCancelled(true);
        }
    Maybe I just have an error in Mind.
     

Share This Page