Solved EnityCreature? Api? Questions to those with answers.

Discussion in 'Plugin Development' started by Ultracrepadarian, Jan 10, 2016.

Thread Status:
Not open for further replies.
  1. So as i've been working more and more with entities, I've come across quite a few code snippits that use the 'EntityCreature' class, and a few others that aren't in the bukkit API. I need answers. Is this an Api? Why do we live? Why do we die? Why do we spend so much of the intervening time wearing digital watches? Ignore the last few, its a 'Hitchhikers guide to the galaxy' quote :p Thanks in advance!
     
  2. Offline

    mcdorli

    nms, try to use the craftbukkit.jar, and not the spigot one.
     
  3. Of course! Craftbukkit! I was using bukkit :p But isn't craftbukkit made for running servers? And bukkit is the API for it? Or did I get the whole think wrong?

    P.S Aperently I'm really out of it. What does Nms mean? The only thing I can think of is neuroleptic malignant syndrome, but I don't think thats it :p
     
  4. Offline

    mcdorli

    net minecraft server. You need the craftbukkit.jar, because only that contains the nms library.
     
  5. Another question. After looking at the nms and the bukkitAPI, I've realized that quite a few things are different about them. Which one should I use more? For example: When I tried to create a new instance of EntityZombie, I entered the parameters as the world, but it stated that the org.bukkit.World could not be converted to net.minecraft.server.World

    More info would be much appriciated. :)
     
  6. Offline

    ski23

    Only use nms when you have to. nms breaks every update. When there is a choice, use bukkit.
     
  7. @Ultracrepadarian Look for some nms tutorials, they are mostly protected and encrypted, which makes them hard to use and read. nms World is one of the craftBukkit basic classes, when bukkit World is just an interface, you should cast the bukkit World to CraftWorld (The real world class, where all the methods are stored), and then invoke the '.getHandle()' method, which will point you to the nms equivalent of that craftBukkit class.
     
  8. Offline

    mcdorli

    Or simply cast player to craftPlayer, and get the world trough him.

    @Ultracrepadarian between 1.7 and 1.8, a lot has changed. Foe example integer x y and z positions changed to blockPositiom. You need to find out every parameter yourself
     
  9. @mcdorli CraftPlayer#getWorld is the same as Player#getWorld, both of them are returning the same bukkit World, and they are the same method. He is looking for the nms World, which can only be obtained at the EntityPlayer.
     
  10. Offline

    mcdorli

    You misunderstood me. I meant CraftPlayer#getHandle().getWorld()
     
  11. Thank you for explaining it a bit more :) I'll notify when I figure it out (after I run a couple tests.)

    @Juancomaster1998 So, to get this straight, I need to create a new instance of World, cast it to CraftWorld, then invoke .getHandle()?

    I think the code would look something like this?:
    Code:
    World craftWorld = (CraftWorld) -Not sure what would go here-
    Please correct me :)
     
    Last edited: Jan 11, 2016
  12. Offline

    mcdorli

    Simple casting, basic java. Again, you can do ((CraftPlayer) player).getHandle().getWorld()
     
  13. Still, after I tried this:
    Code:
    World craftWorld = ((CraftPlayer) player).getHandle().getWorld();
    It still said the nms world cannot be converted to the bukkit world. Is there no way to convert one to the other?

    P.S I apologize for any inconvenience I'm causing you. I hope you know that If you get too 'Worn out' dealing with me, please do not hesitate to let someone else answer the question. Again, thank you for helping me so far :)
     
  14. Offline

    Zombie_Striker

    @Ultracrepadarian
    Look at what .getWorld returns.
     
  15. I see that it returns World. Thats all that I can find... I need to somehow convert it to the bukkit World...
     
  16. Offline

    Zombie_Striker

    @Ultracrepadarian
    No. .getWorld() returns a CraftWorld. What you have is the same as "World = CraftWorld", which world is not the same as the CraftWorld.
     
  17. Ah I see, let me test a couple things, then I'll get back to you

    EDIT: @Zombie_Striker it still says World cannot be converted to craftworld...

    Code:
    CraftWorld craftWorld = ((CraftPlayer) player).getHandle().getWorld();
    
     
  18. Offline

    Zombie_Striker

    @Ultracrepadarian
    I messed up. .getWorld() returns a "World". What you need to do is use getWorld().getHandle(). (Another link said you can just cast the world to a CraftWorld, but I do not know how accurate that is.)
     
  19. Offline

    mcdorli

  20. Offline

    87pen

  21. Thank you @87pen, this helped quite a bit :)

    Solved.
     
Thread Status:
Not open for further replies.

Share This Page