Get a net.minecraft.server.v1_7_R4.World from a player

Discussion in 'Plugin Development' started by DoppelRR, Aug 5, 2014.

Thread Status:
Not open for further replies.
  1. Hi Guys,
    I am trying to spawn an custom entity and need to know for this how to get a nms world from an Player.
    The only thing I found after two hours of Research was this:
    Code:java
    1. ((CraftWorld) world).getHandle();

    This is not working anymore and is even already reportet as bug to bukkit.
    Is there any other way to do this??
    Thx DoppelRR
     
  2. Offline

    fireblast709

  3. Offline

    NathanWolf

    I seriously doubt Bukkit is going to take any "bug reports" seriously that involve reaching into CB internals....

    But yeah, the method is there, and it's still public- so I'm not sure why that's not working for you (assuming you're doing all that normal shading junk you have to do to reach into CB/NMS):

    https://github.com/Bukkit/CraftBukk...a/org/bukkit/craftbukkit/CraftWorld.java#L292

    WorldServer extends World.
     
    AdamQpzm likes this.
  4. NathanWolf
    fireblast709
    When i use:
    World world = ((CraftWorld) p.getWorld()).getHandle();
    Eclipse already gives me the Syntax error "CraftWorld cannot be resolved as a Type."
     
  5. Offline

    NathanWolf

    You need to build against CraftBukkit to access CB classes.
     
  6. If it can't be resolved as a Type, it means you haven't imported it OR you're using the wrong library. Use CraftBukkit and not Bukkit if you want to use NMS.

    Edit: Ninja'd by NathanWolf :S
     
  7. Offline

    mythbusterma

    KingFaris11

    I don't think you understand what the method "getHandle()" does.
     
  8. I do, I just had a mind blank.
     
  9. KingFaris11
    1. It is a NMS World
    2. I am using CraftBukkit

    this Code snippet is what i found on my own Research but as I already said this were older ones and this snippet is not working anymore.

    But maybe you can help me in another way by just telling me how i can spawn a Custom Entity manually because in all the tutorials they replace for example the old Zombie but i want to just spawn it by rightclicking with, lets say a stick.

    Ok i just solved it KingFaris11 was right i had not imported CraftWorld but normally eclipse gives me the Option then to Import it , not so this time.

    Thx for your help anyway,
    DoppelRR

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page