1.7/1.8 - Cancel the gravity from an Entity?

Discussion in 'Plugin Development' started by CruzAPI, Jan 22, 2018.

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

    CruzAPI

    I need to cancel the gravity from an Item (Dropped Item).

    Code:
    Item item = p.getWorld().dropItem(p.getLocation(), new ItemStack(Material.PACKED_ICE));
    net.minecraft.server.v1_7_R4.Entity nms_entity = ((CraftEntity)item).getHandle();
    I don't know where gravity is to stop it.

    Using 1.7 / 1.8
     
    Last edited: Jan 23, 2018
  2. Offline

    ipodtouch0218

  3. Offline

    CruzAPI

    really?
     
  4. Offline

    Machine Maker

    Please mark this thread as Solved if your issue has been resolved.
     
  5. Offline

    CruzAPI

    I need help, noone can help me?
     
  6. Offline

    timtower Administrator Administrator Moderator

    You had an answer already:
    Did you try it?
     
  7. Offline

    Machine Maker

    did you try setGravity(false)?

    Thats why I asked to set the thread to Solved. I thought you had your answer
     
  8. Offline

    CruzAPI

    setGravity(false) doesn't exists!
     
  9. Offline

    Machine Maker

    In the PlayerDropItemEvent get the Item with getItem() and use setGravity(false) on the Item.
    Code:
     e.getItem().setGravity(false);
     
  10. Offline

    CruzAPI

    It isn't a PlayerDropItemEvent, it is p.getWorld().dropItem(p.getLocation(), new ItemStack(Material.PACKED_ICE));

    EDIT:
    And this method doesn't exists in PlayerDropItemEvent .getItem();
     
  11. Offline

    timtower Administrator Administrator Moderator

    @CruzAPI Which also returns an Item
     
  12. Offline

    CruzAPI

    Did you read it right? I want to cancel the gravity, the method setGravity(false) doesn't exists in nowhere.
     
  13. Offline

    timtower Administrator Administrator Moderator

    @CruzAPI Which version are you developing for? Because the first link is a generated javadoc file that has the method.
     
  14. Offline

    CruzAPI

    1.7 / 1.8
     
  15. Offline

    timtower Administrator Administrator Moderator

    That is indeed a different story.
    Please put it in the first post when you develop on an older version.
     
  16. Offline

    CruzAPI

    Sorry, i forgot it.
    So I won't get help here if I'm developing in older version or what I do?
     
  17. Offline

    timtower Administrator Administrator Moderator

    That is not it, but most developers moved away from the older version. Newer version have more tricks (like setGravity) and bugfixes.
    You just need to wait for the one who can tell you how to do it.
     
  18. Offline

    CruzAPI

    Just one question, if i set an item.setGravity(false) when i set a Vector it will be constant or it will
    decelerate gradually?

    EDIT:
    I tried in 1.12 and setGravity works nice and the item decelerate gradually, but I want know how to do it in 1.7, I need to use NMS? I need to create a custom Entity that extends Entity class? pls help for 1.7
     
    Last edited: Jan 22, 2018
  19. Offline

    CruzAPI

    *bump*
     
Thread Status:
Not open for further replies.

Share This Page