Solved Imitating the DataValue "NoGravity"? NBT?

Discussion in 'Plugin Help/Development/Requests' started by ColonelHedgehog, Jun 5, 2015.

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



    I was wondering if there was a way to imitate the NoGravity data tag for entities. Example: you can make a floating hologram by doing this: /summon ArmorStand ~ ~ ~ {Invulnerable:1b,NoGravity:1b,Invisible:1b,CustomNameVisible:1b,CustomName:Test}
    But I'd like to do this programmatically. I can do everything except the NoGravity option. Is there something in the CraftEntity class that would allow me to do this? I'd prefer to stay away from schedulers.
  2. Offline


  3. Offline


    This can be achieved through editing MetaData. Try setting the entities Metadata(NoGravity,true); like so.
  4. Offline


    If you mean for *all* entities, I don't think you really can. The "NoGravity" tag is specific to armor stands.

    The best you can do (sort of) is to apply a velocity to an entity on a scheduled task to counteract gravity- but this doesn't work well, is susceptible to lag, makes the client go out of sync, etc.
  5. Offline


    Oh, sorry, I posted in the wrong section.

    As for the rest: I tried setting the metadata, but it didn't work.

    I tried:

    hologram.setMetadata("NoGravity", new FixedMetadataValue(plugin, "1b"));


    hologram.setMetadata("NoGravity", new FixedMetadataValue(plugin, true));

    is the ArmorStand.

    EDIT: I fixed it. I used NMS and OBC with reflection:

    Class<?> CraftArmorStand = Reflection.getOBC("entity.CraftArmorStand"); // Gets the CraftBukkit classClass<?> EntityArmorStand = Reflection.getNMSClass("EntityArmorStand"); // Gets the NMS classObject CASInstance = CraftArmorStand.cast(hologram);
    Method getHandleMethod = CraftArmorStand.getMethod("getHandle");
    Object handle = getHandleMethod.invoke(CASInstance);
    Method setGravityMethod = EntityArmorStand.getMethod("setGravity", boolean.class);
    setGravityMethod.invoke(handle, true);
    Last edited: Jun 5, 2015
Thread Status:
Not open for further replies.

Share This Page