Solved (Quick Question) Casting various NMS objects to Bukkit objects

Discussion in 'Plugin Development' started by Dudemister1999, Oct 17, 2014.

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

    Dudemister1999

    Hello! I was wondering if there was a way to cast these objects:

    NMS Entity > Bukkit Entity
    NMS World > Bukkit World (I am currently doing Bukkit.getWorld(entity.world.getWorld().getName()); )
    NMS Block > Bukkit Block

    I've looked at Craft<whatever>, but that only goes from Bukkit to NMS.

    Thanks!
    -Hydroxocobalamin (OCHbl)

    Nevermind, all good!

    Code:java
    1. entity.motY += 1;
    2.  
    3. Location loc = new Location( Bukkit.getWorld(entity.world.getWorld().getName()), entity.locX, entity.locY, entity.locZ );
    4. World w = Bukkit.getWorld(entity.world.getWorld().getName());
    5.  
    6. List<Block> blocks = new ArrayList<>();
    7. int radius = 5;
    8.  
    9. {
    10. for (double x = -entity.locX + radius; x < entity.locX + radius; x++)
    11. for (double z = -entity.locZ + radius; z < entity.locZ + radius; z++)
    12. blocks.add(w.getBlockAt((int)x, (int)entity.locY, (int)z));
    13. }
    14.  
    15. for(Block b : blocks)
    16. {
    17. b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType().getId());
    18. }
    19.  
    20. for(Entity ent : entity.getBukkitEntity().getNearbyEntities(radius, 3, radius))
    21. {
    22. if(ent instanceof LivingEntity)
    23. {
    24. ((LivingEntity)ent).damage(damageToDeal, entity.getBukkitEntity());
    25. }
    26. }


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

Share This Page