Entity.setPassenger() not working properly?

Discussion in 'Plugin Development' started by dibujaron, Dec 6, 2012.

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

    dibujaron

    hello. I'm having an issue when using the setPassenger() method, as shown above. I have a pig entity, I have a zombie pigman entity, I set the passenger of the pig to be the pigman. simple enough, theoretically. And at first glance, it works fine. but then there's a wierd sort of glitch- when the pig moves, the pigman stays where it is. This picture is of when I had just created the pig jockey creature and the pig had walked a little bit:
    [​IMG] it's a sort of awkward angle, but I think you can see my point. The pigman cannot be hit or interacted with. When you logout and log back in, the pigman is on the pig again, wherever the pig happens to be. However, when the pig moves, once again the pigman stays still. I am quite confused; is this happening for anyone else? If not, what am I doing wrong?

    Here's the relevant code:
    Code:
    if (event.getEntityType() == EntityType.PIG_ZOMBIE){
                        Pig pig = (Pig) world.spawnEntity(moblocation, EntityType.PIG);
                        LivingEntity pigZombie = (LivingEntity) event.getEntity();
                        pig.setPassenger(pigZombie);
                }
    Where the above code is inside a CreatureSpawnEvent, and moblocation = the location where the CreatureSpawnEvent took place. I also tried a pig with a saddle, but with no different results.

    Help is much appreciated, I don't know where I would be without this forum. Thanks!
     
  2. Offline

    ImDeJay

    i dont know much about this area, but maybe what i say will help.

    Perhaps you need to update the x/y/z of the pigmen as the x/y/z of the pig changes, or rather, update what the PLAYER sees.

    just like how you have to do "player.updateinventory" before a player can see that you remove/added something to their inventory.

    maybe that makes sense.
     
  3. Offline

    dibujaron

    that's a possibility, but I don't think that's it.... can anyone confirm this/ add to it? The problem with that being that the pigman staying still is just a visual glitch- whenever I relog he's always with the pig again. his coordinates and hitbox are moving, just not his physical body :p
     
  4. Offline

    trebitot

    I don't know if this is the same problem, but this happens with regular spider jockeys in Vanilla. The spiders will move around, but the skeletons will stay sitting in one spot.
     
  5. Offline

    dibujaron

    Is that issue in 1.4.5? I haven't noticed that since 1.2.5. And even then, they sort of teleported every second or so; with my problem, they just sit still :p
     
  6. Offline

    trebitot

    I believe so.
     
  7. Offline

    chasechocolate

    I think that the CreatureSpawnEvent only fires when a creature spawns. You might want to try making an event that fires when a pig moves, and then set the passenger to a PigZombie.
     
Thread Status:
Not open for further replies.

Share This Page