NMS unmoveable Villager?

Discussion in 'Plugin Development' started by iAmGuus, Jan 31, 2015.

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

    iAmGuus

    Hi Guys,

    I got a little question for you all, hopefully you guys having a solution.
    So my problem is, I was working on a plugin with unmoveable villagers, I thought everything was fine in code, (there are no errors in eclipse) until I exported it to my server and tested it. So I got this error. (I know it is an error with casting etc. but I dont know how to fix it.): http://pastebin.com/pd0H5a4x
    This is the code of the command: http://pastebin.com/KyuhMTkC
    The code of the NPCsUtil class: http://pastebin.com/UKu6MRz0
    And the code of CustomVillager class: http://pastebin.com/TdCC5DjV
    I got this class of CustomVillager from a resource here on the forums.
    But I'll explain the error. So I want to spawn a custom villager which is stationary.
    Once I try to use the command /npc spawn Quest , it tells me 'An internal error occured' and when i look in the console, the stacktrace shown above pops up.

    Any ideas?

    Regards,
    Guus Huizen - iAmGuus
     
  2. Offline

    WesJD

    @iAmGuus You could set its genericattribute of d to 0?
     
  3. Offline

    iAmGuus

    @WesJD, sorry but I am not a pro at NMS, as I said I used the resource from an guy on the forums here. But can you explain me a bit better?
     
  4. Offline

    WesJD

    @iAmGuus
    Code:
    //villager is an instance of CraftVillager
    villager.getHandle().getAttributeInstance(GenericAttributes.d).setValue(0.0D);
     
  5. Offline

    iAmGuus

    @WesJD, where should I put this, in the NPCsUtil class, or in the CustomVillager class?
     
  6. Offline

    WesJD

    @iAmGuus That's your decision, not mine.
     
  7. Offline

    iAmGuus

    @WesJD, nvm, I think i got it
    Thanks!
     
  8. Offline

    TGRHavoc

    That's not the cause to the OPs problem.


    @iAmGuus
    Are you registering the custom entity?

    The problem is that the spawnEntity method returns a CraftEntity and not your custom entity thus, you get the cast exception.
     
  9. Offline

    WesJD

    @TGRHavoc He's wanting to not make a villager move, and I gave him a simple answer. That should fix his problem?
     
  10. Offline

    iAmGuus

    Guys
    I fixed it already with help from @WesJD, thanks for your time!

    @WesJD, how would I make it so the villager can not be pushed ?
     
    Last edited by a moderator: Jan 31, 2015
  11. Offline

    _Filip

  12. Offline

    iAmGuus

    @_Filip Can you give me an example?
     
  13. Offline

    ChipDev

    GenericAttributes.d (Source)
    How to use it:
    Code:
    CustomEntityClass#getAttributeInstance(GenericAttributes.d).setValue(0.0D);
     
  14. Offline

    iAmGuus

    @ChipDev, u know how to make mobs unpushable ?
     
  15. Offline

    ChipDev

    Hmm.. Let me get that for you :)

    Villagers right?
     
    Last edited by a moderator: Jan 31, 2015
  16. Offline

    iAmGuus

    @ChipDev, I fixed that now, I only need to know how I can despawn them. So I store them with an location in the config, and afterwards when I want to despawn them, I loop through all the entities in the world and check if the coordinates x/y/z are the same (I'm doing it with getBlockX/Y/Z()), now that is not working. Ask for code (if needed)

    @ChipDev nvm, I have already fixed it myself, thanks for your time anyways.
    For the people with same problem; use metadata.
     
    Last edited by a moderator: Jan 31, 2015
  17. Offline

    glasseater

    @iAmGuus
    If you don't mind me asking how did you make it unpushable? I am trying to do the same thing with a Zombie.
     
  18. Offline

    iAmGuus

  19. Offline

    ChipDev

    I don't think so.
    Code:
    @Override
    public void g(double d0, double d1, double d2) {
    }
    Unpushable. Unmoveable.
     
Thread Status:
Not open for further replies.

Share This Page