Floating items

Discussion in 'Spigot Plugin Development' started by OscarDali, Jun 18, 2018.

  1. Hi, basically I want to make an item keep floating and not disappear, try using the property of the setGravity(False); but it gave me an error
     
  2. Sooo what’s the error?
     
  3. ^

    Also, what have you tried? Having some code would help us help you.
     
  4. This is my code

    Code (Java):
                Location location = e.getPlayer().getLocation();
                Item item = location.getWorld().dropItem(location, new ItemStack(Material.GRASS));
                item.setCustomName("EXAMPLE");
                item.setCustomNameVisible(true);
                item.setGravity(false); //This is the problem

    Code (YAML):
    [15:25:43 ERROR]: Could not pass event PlayerCommandPreprocessEvent to SkyWarsApi v5.4
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1154) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_151]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_151]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_151]
    Caused by
    : java.lang.NoSuchMethodError: org.bukkit.entity.Item.setGravity(Z)V
            at me.SrPandaStick.SkyWarsApi.Holograms.Holograms.onCommand(Holograms.java:33) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[1.8.8_spigot.jar:git-Spigot-76236cb-62a2169]
            ... 16 more
     
  5. spawn an armor stand, set it invisible, then add an item to a slot and set the gravity of armorstand instead
     
  6. I've already done that but it's not what I'm looking for, I do not understand why I can not take the gravity of an item, I'm looking to do it alone to the item
     
  7. Simplest way I can imagine is just spawning a barrier block right below it. Not sure if there's any other way without the item looking glitchy.
     
  8. You are compiling the plugin against Spigot 1.10 or newer and you are running the plugin in Spigot 1.8.8 cause setGravity method was added in 1.10
     
    • Winner Winner x 3
    • Agree Agree x 1
  9. Thank you very much, that was my problem, I was compiling it in 1.12 and I used it in 1.8, but I've seen floating items in 1.8 and they are entities, they are not on an armorstand, can not you really do this?
     
  10. Let 1.8 die. Seriously. It's old and officially unsupported. Unsupported means you're on your own if you decide to stick with it.
     
    • Winner Winner x 5
  11. I have people using 1.8 and even 1.7, and if I can give them the taste they want, I will not deny them
     
  12. BOOO.
    [​IMG]
    1.8 + 1.7 still has a huge playerbase as it is the only version with good pvp. In fact, I have been looking at new servers and a lot of them are still using 1.8 because of it's real pvp.
     
    • Agree Agree x 6
  13. Well back to the subject, then you can not do this in 1.8?, as I said I saw a server that did it in 1.8
     
  14. People will not move on if they are not forced. Good example is 90% of plugin devs would not move to Java 8 because server admins still ran Java 7. It wasn't until Mojang forced the use of 8 that people moved on. Don't be part of the problem. Don't be an enabler.
    Guess you didn't see the part where I said "unsupported." You're really on your own with that. Welcome to legacy \o/
     
    • Agree Agree x 2
  15. (offtopic) 1.8 should be continued to be supported because minecraft 1.8 people actually like pvp in other versions its attrocious and although plugins can be made to disable that type of pvp, any good pvp server has 1.8 + 1.7. I would like someone to name a single popular + god server that does not support 1.8 or doesnt have 1.8 pvp
     
    • Optimistic Optimistic x 1
  16. Its officially unsupported. Staff is done with it. You do realize core team devs make all sorts of fun about people that hold that viewpoint. "But mah pee vee pee!" Etc etc.

    Here's what md_5 has to say about it:

    "It is also a good time to point out that when seeking support from us or the community, the only supported server versions are recent CraftBukkit & Spigot 1.11.2 / 1.12 versions. Any other version puts you at risk of already fixed bugs, and exploits."

    Pretty sure 1.11.2 is unsupported now as well, seeing he posted that over a year ago.
     
    • Funny Funny x 1
  17. well, even so 1.8 + 1.7 are the only "real minecraft" versions in my opinion.
     
    • Agree Agree x 1
    • Funny Funny x 1
  18. The thread isn't about which version devs should be working on. I personally haven't ever seen floating items in 1.8, although I haven't seen them in 1.9+ servers either. (Admittedly I don't play 1.9+ almost ever). What exactly do you mean by a "floating item"? Do you mean like a dropped item that's floating in mid-air? Or does it look like it's on an armor stand? You've already stated that it isn't the armor stands, so no idea. Could you provide an example of what you're trying to recreate? I think as I've stated before the easiest way to achieve this is just placing a barrier below the item and make it so players can't picukp it up.
     
  19. Well, regarding the versions is not that this is insisting that they remain in an "old" version, if not what they like, you will not force me to do something I do not want, if they want 1.7 - 1.8 is because they enjoy it, so they knew the game and so they would like to leave it, they have no choice but to look for servers like that, and they do not hurt anyone.

    Yes, it's just an item floating, something like this:

    [​IMG]

    [​IMG]

    I do not know if it's an armor stand, because it has that kind of "animation" like when you drop an item and turn on itself
     
  20. Enter the server where I saw it and take a photo, the item is shown as an entity, if it were an armor booth it would not be like that

    [​IMG]