Cast Player to NMS Entity

Discussion in 'Plugin Development' started by ImAFlo, Feb 27, 2016.

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

    ImAFlo

    Hey,

    I can't cast a player to a NMS Entity.
    Code:
    Code:
    PacketPlayOutCamera packetPlayOutCamera = new PacketPlayOutCamera((net.minecraft.server.v1_8_R3.Entity) e.getPlayer());
    sendPacket(e.getPlayer(), packetPlayOutCamera);
    
    Error:
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer cannot be cast to net.minecraft.server.v1_8_R3.Entity
    
     
  2. Offline

    N00BHUN73R

    @ImAFlo
    A Player cannot be casted to an NMS entity..
    It can be casted to (CraftPlayer) though.
     
  3. Offline

    ImAFlo

  4. Offline

    Xerox262

    @ImAFlo The guy that posted it was wrong (The spigot one), you can't directly cast player to a nms entity, you can however cast it to CraftPlayer then use getHandle() to get the EntityPlayer which is an NMS entity.
     
Thread Status:
Not open for further replies.

Share This Page