Zombies moving faster?

Discussion in 'Plugin Development' started by Jakeob22, Jul 10, 2012.

  1. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thanks! Means a lot :3


    edit:
    @gjossep
    heres the source:
    Code:java
    1. package me.Corrie.TestPlugin;
    2.  
    3. import java.util.HashSet;
    4.  
    5. import net.minecraft.server.EntityCreature;
    6. import net.minecraft.server.Navigation;
    7.  
    8. import org.bukkit.Bukkit;
    9. import org.bukkit.Location;
    10. import org.bukkit.command.Command;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.craftbukkit.entity.CraftCreature;
    13. import org.bukkit.entity.EntityType;
    14. import org.bukkit.entity.Player;
    15. import org.bukkit.entity.Zombie;
    16. import org.bukkit.event.EventHandler;
    17. import org.bukkit.event.Listener;
    18. import org.bukkit.event.player.PlayerInteractEvent;
    19. import org.bukkit.plugin.java.JavaPlugin;
    20.  
    21. public class TestPlugin extends JavaPlugin implements Listener{
    22. HashSet<EntityCreature> mobs = new HashSet<EntityCreature>();
    23. public void onDisable(){
    24.  
    25. }
    26. public void onEnable(){
    27. Bukkit.getPluginManager().registerEvents(this,this);
    28. }
    29. @Override
    30. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    31. Player player = (Player)sender;
    32. Location loc = player.getTargetBlock(null, 100).getLocation();
    33. loc.setY(loc.getY()+1);
    34. Zombie z = (Zombie) loc.getWorld().spawnCreature(loc, EntityType.ZOMBIE);
    35. EntityCreature ec = ((CraftCreature)z).getHandle();
    36. mobs.add(ec);
    37. return true;
    38. }
    39. @EventHandler
    40. public void oninteract(PlayerInteractEvent event){
    41. Location loc = event.getPlayer().getTargetBlock(null, 100).getLocation();
    42. loc.setY(loc.getY()+1);
    43. for(EntityCreature ec : mobs){
    44. Navigation nav = ec.al();
    45. nav.a(loc.getX(),loc.getY(),loc.getZ(),1.0f);
    46. }
    47. }
    48.  
    49. }


    also, its not really reflection as it is hacky. I misused the term earlier, apologies.

    This post has been edited 2 times. It was last edited by CorrieKay Jul 10, 2012.
    LucasEmanuel likes this.
  2. Offline

    Rick132500

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    You always make the best mods :3
  3. Offline

    Jakeob22

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hm, the potion effect isn't doing anything. Even if I set it to 20000 power, the zombies stay at their original speed! D:
  4. Offline

    Jakeob22

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Any ideas? ^
  5. Offline

    mollekake

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    slowness or speed potion effects doesn't affect mobs :(
    Her plugin seem to do the trick, with some adjustments though, if i can figure out which libraries she's using :S

    which is the craftbukkit jar :p

    This post has been edited 1 time. It was last edited by mollekake Jul 13, 2012.
  6. Offline

    Jakeob22

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @CorrieKay
    Yeah, I can't really understand what she did there. If she could help me finish this little part, I would be very greatful. :p
  7. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Um, sure, ill explain.. But not right now. its like, 1am and im about to head to bed, and its a little more complicated than im willing to explain right this moment x3 Tomorrow!
  8. Offline

    Jakeob22

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thanks! :D
  9. Offline

    mollekake

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    sounds great! i want mine to move slower though, but i guess that's just a lower float.
  10. Offline

    EnvisionRed

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  11. Offline

    ferrybig

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    somewhere at the resources section is a way how to hook into the movements of entites, mayby yif you call the entity's move functions 2 times instead of 1 time each tick, it ill move faster
  12. Offline

    mollekake

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    so i'm trying this speed thing. but i can't wrap my head around the creation part of a new mob.
    this is how i got, but i don't know how to define the location where the zombies are spawning.

    this is what i got so far:

    HashSet<EntityCreature> mobs = new HashSet<EntityCreature>();
    Location loc = ;
    loc.setY(loc.getY()+1);
    Zombie z = (Zombie) loc.getWorld().spawnCreature(loc, EntityType.ZOMBIE);
    EntityCreature ec = ((CraftCreature)z).getHandle();
    Navigation nav = ec.al();
    nav.a(loc.getX(),loc.getY(),loc.getZ(),0.5f);

    @CorrieKay got any tips? :p
  13. Offline

    EnvisionRed

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Nono, don't store EntityCreatures in collections, I believe it causes memory leaks because if it is in a chunk the server unloads, the server will try to unload it, but can't. Store UUIDs of Entities instead and then create a method that returns an entity when supplied with a UUID. Then define your EntityCreature and do the navigation stuff.
  14. Offline

    mollekake

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    some guidelines? i'm fairly new to this
  15. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    i know there was something in the resources forum about how to inject custom mobs into the server (not really custom, but classes that like, extends Zombie, or something)

    I think thats where you need to go, however im not sure where the thread is exactly.

    This post has been edited 1 time. It was last edited by CorrieKay Jul 14, 2012.
  16. Offline

    mollekake

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    can't seem to find anything. anyone got any pointers?
  17. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    beyond that you need to override the method that contains the method "a()" call, no, not really :\
  18. Offline

    Jakeob22

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I'm beyond confused. XD
  19. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    its not easy stuff, heh, i dont pretend to understand it all.
  20. Offline

    EnvisionRed

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I just wish the minecraft server code wasn't so damn obfuscated so we devs can pick through it easier and actually understand anything it does.
  21. Offline

    Gawdzahh

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @CorrieKay, think you could explain how you would do that using only the standard bukkit API?
    I think it could help alot of other also.
  22. Offline

    blackwolf12333

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    CorrieKay likes this.
  23. Offline

    CorrieKay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I did, but actually making it passive (as in, make the server use it when the mob moves, instead of on a command or something via plugin) isnt something i know how to do off the top of my head

Share This Page