How to get Iron Golems to follow player?

Discussion in 'Plugin Development' started by MayoDwarf, May 1, 2014.

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

    MayoDwarf

    I am trying to get the Iron Golem to be player controlled. In the ten java contest TeddyTheTeddy did this with his ironman plugin. I tried the same exact thing, but changed up the code abit, however it is still not working. I even tested his method he used specifically and it's not working either. I am doing this in efforts of creating a Titanfall game mode and need to get them to be able to control the golem. Any help is appreciated... Thanks. Right now all that happens is the golem is summoned and the players are turned invisible. All the code runs correctly, but the golems just don't follow the players like they should.
    Code:java
    1. public void summonGolem(Player p, Location tFall, GolemType gt) {
    2. IronGolem ig = (IronGolem) p.getWorld().spawnEntity(new Location(p.getWorld(), tFall.getX(), 255, tFall.getZ(), tFall.getYaw(), tFall.getPitch()), EntityType.IRON_GOLEM);
    3. ig.setCustomName(ChatColor.DARK_RED+""+p.getDisplayName());
    4. ig.setCustomNameVisible(true);
    5. ig.setPlayerCreated(true);
    6. ig.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, Integer.MAX_VALUE));
    7. golem.put(p.getDisplayName(), ig);
    8. gType.put(p.getDisplayName(), gt);
    9. }
    10. public void enterGolem(Player player, Entity e) {
    11. if(e instanceof IronGolem) {
    12. IronGolem ig = (IronGolem) e;
    13. ig.setTarget(player);
    14. ig.removePotionEffect(PotionEffectType.SLOW);
    15. player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, true));
    16. }
    17. }
     
  2. Offline

    Garris0n

    Are you using the latest build? I believe it has fixes for the setTarget() method.
     
  3. Offline

    MayoDwarf

    Garris0n Using beta 1.7.2. is that possibly the problem?
     
  4. Offline

    Garris0n

    setTarget has been bugged for a very long time, try using 1.7.9 and see if it works. It's "the problem" in a sense, yes.
     
    MayoDwarf likes this.
  5. Offline

    kennethbgoodin

    Garris0n is right, the latest build has fixes for setTarget(), courtesy of PaulBGD. Try and update, and see if that fixes any of your issues.
     
  6. Offline

    MayoDwarf

    kennethbgoodin Garris0n Nope still nothing and running a dev 1.7.9

    kennethbgoodin Any ideas why?

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

    Garris0n

    That's odd. Does it work on other mobs and just not the golems?

    Also, if you're going for the effect of the player being inside the golem, why not use a disguise plugin API or some packet manipulation to make the player a golem for other players?
     
  8. Offline

    kennethbgoodin

    If you're going for what he said, you could also try setting the passenger of the golem to the player, and trying to play with where the player's sitting. There are some tutorials on allowing WASD control of mobs the player is riding.
     
  9. Offline

    maxben34

    I don't think this works on golems for some reason.
     
  10. Offline

    MayoDwarf

    maxben34 kennethbgoodin Garris0n None of this is working :(. Also I don't want to use a disguise plugin because you can't have custom display names within their api :( It also limits what you can do with the entity...

    Any ideas?

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

    xTigerRebornx

    MayoDwarf Try using that WASD-Passenger idea, along with hiding the Player to all, see how that works out, and if it doesn't, show what you've done and we'll look at it.
     
  12. Offline

    Garris0n

    Try removing the invis effect.
     
  13. Offline

    MayoDwarf

    Garris0n That worked, but it's buggy and I the player to be the Iron Golem. Would I have to use packets for this? xTigerRebornx
     
  14. Offline

    Garris0n

    Yes, or an API.
     
Thread Status:
Not open for further replies.

Share This Page