Solved Floating Item, ChunkLoad Error (Maybe)

Discussion in 'Spigot Plugin Development' started by HotDoctor, Apr 27, 2019.

Thread Status:
Not open for further replies.
  1. Hi, im trying to create "Holograms" with floating items, this is my code:
    Code (Java):

        public void spawnItem(ItemStack item) {
            hloc = location.clone().add(0.5, 1.8, 0.5);
            double mathY = (lines.size() + 1.8) * -0.57;
            ArmorStand as = location.getWorld().spawn(hloc.clone().add(0, mathY, 0), ArmorStand.class);
            as.setGravity(false);
            as.setBasePlate(false);
            as.setVisible(false);
            as.setArms(true);
            Item itemcreator = location.getWorld().dropItem(hloc.clone().add(0, mathY, 0), item);
            as.setPassenger(itemcreator);
            itemcreator.setPickupDelay((((50000*20)*60)*60)*24);
            itemarmorStand.add(as);
     
         }
     
    Technically there's no error in console but this happens:
    Gif: https://gph.is/g/ZO5RLjE

    Any help? i will appreaciate it, tysm
     
    #1 HotDoctor, Apr 27, 2019
    Last edited: Apr 29, 2019
  2. Bump
    Please i havent fixed this ;w;
     
  3. Maybe you can try
    itemcreator.setGravity(false);
     
  4. Using spigot 1.8.8 im so sorry
     
  5. If it is a chunk thing maybe listen to see if the item despawns and then does that. If that is what is happening just try cancelling it. Just a thought, don't know if it will actually work.
     
    • Friendly Friendly x 1
  6. Should I try ChunkUnloadEvent or directly ItemDespawnEvent?
     
  7. I would try testing both. I would try one then the other and then both just to see.
     
  8. I will just close this.
    I havent searched a solution
    If someone know how to fix this, please send PM.
     
  9. Fixed:
    I have just changed the code and the spigot api/server to 1.10
    Code (Text):

        public void spawnItem2(ItemStack item) {
            if(main2.getServer().getBukkitVersion().contains("1.8") || main2.getServer().getBukkitVersion().contains("1.9")) {
                hloc = location.clone().add(0.5, 1.8, 0.5);
                double mathY = (lines.size() + 1.8) * -0.57;
                ArmorStand as = location.getWorld().spawn(hloc.clone().add(0, mathY, 0), ArmorStand.class);
                as.setGravity(false);
                as.setBasePlate(true);
                as.setVisible(false);
                as.setArms(true);
                as.setGravity(false);
                Item item2 = hloc.getWorld().dropItem(hloc.clone().add(0, mathY, 0), item);
                item2.setVelocity(new Vector(0, 0, 0));
                as.setPassenger(item2);
                item2.setPickupDelay(Integer.MAX_VALUE);
            }else if(main2.getServer().getBukkitVersion().contains("1.10")) {
                hloc = location.clone().add(0.5, 1.8, 0.5);
                double mathY = (lines.size() + 1.8) * -0.57;
                ArmorStand as = location.getWorld().spawn(hloc.clone().add(0, mathY, 0), ArmorStand.class);
                as.setGravity(false);
                as.setBasePlate(true);
                as.setVisible(false);
                as.setArms(true);
                as.setGravity(false);
                Item item2 = hloc.getWorld().dropItem(hloc.clone().add(0, mathY, 0), item);
                item2.setVelocity(new Vector(0, 0, 0));
                as.setPassenger(item2);
                item2.setPickupDelay(Integer.MAX_VALUE);
                item2.setGravity(false);
             
            }
         
         
         
         }
     

    The chunk bug is only for +1.10 servers, but no for 1.8 and 1.9

    EDIT: Yes, i know, im idiot.
     
Thread Status:
Not open for further replies.