Custom NMS Entity is Invisible?

Discussion in 'Plugin Development' started by StaticJava, Dec 18, 2014.

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

    StaticJava

    Hello All,

    I am having some trouble with custom NMS entities using this tutorial (http://bukkit.org/threads/nms-tutorial-how-to-override-default-minecraft-mobs.216788/).

    Here is my CustomEntityVillager class: http://pastebin.com/amV4WUJp
    Here is my CustomEntityType class: http://pastebin.com/sn0EaS0z

    I know the villager is spawning, as I can hear it's sounds and it has a hitbox. I am registering the events in my onEnable using the register event in my CustomEntityType class, and I can't really find a different problem.

    I appreciate any help,
    ~StaticJava
     
  2. @Funergy
    Did you even read his post?
     
  3. Offline

    Funergy

    @Assist Not fully

    @StaticJava Your path finder goals are wrong
    this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
    First of all the villager needs the PathfinderGoalFloat
    You will add it to the villager with this
    this.goalSelector.a(0, new PathfinderGoalFloat(this);
    And secondly if you want to add a pathfindergoal it needs to start from 0 not 10.

    Do it like this

    this.goalSelector.a(0, new PathfinderGoalFloat(this));
    this.goalSelector.a(1, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
     
  4. Offline

    StaticJava

    @Funergy I did that, and this is my new class: http://pastebin.com/edmfmePb

    What happens: The villager CAN be pushed, but then randomly teleports back to it's original spot. Can't be attacked. Any way to fix? (I DON'T want to be able to push it nor attack it, so the attack part is good so far).

    Additionally, I'm using a PlayerInteractEntityEvent so that when a user right clicks a customentityvillager an inventory opens up and the event is cancelled. However, this never happens - does this mean the server is not recognizing my entity as a CustomEntityVillager?

    Never mind, I fixed all of these problems, but the event thing.

    This is the event I'm using: http://pastebin.com/7jwAXeCf

    It's not being called, however, because the server is most likely recognizing the entity as a Villager, not a CustomEntityVillager. Any way to fix this?

    Added debug messages to prove event is being called: http://gyazo.com/45650640ec66c060820330fe719102e5

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

    TGRHavoc

    @StaticJava
    There are two ways of doing what you want:
    1) The NMS way - Try overriding the entities' "move(double, double, double)" method and put nothing in it.
    2) The bukkit way - You need to call the getHandle() method of the CraftEntity to get the NMS Entity. Then you can check the instance
     
  6. Offline

    Funergy

    @TGRHavoc Have you even read the post he posted before you
    He says its fixed now he is asking that a thing in his event is not working
     
  7. Offline

    TGRHavoc

    @Funergy
    He can still use point 2....
     
  8. Offline

    Funergy

    @TGRHavoc I didnt say point 2 was bad too
     
  9. Offline

    StaticJava

    @TGRHavoc so I do (if e instanceof CustomEntityVillager.getHandle())?
     
  10. Offline

    Europia79

    Nope.

    Btw, you never said how you fixed the invisible entities ? What was the problem ?

    Also, why not just upload the code to your github page ? instead of pastebin ?
     
Thread Status:
Not open for further replies.

Share This Page