[SPIGOT-685] Can't pick up items spawned with world.dropItemNaturally Created: 12/Mar/15  Updated: 15/Mar/15  Resolved: 15/Mar/15

Status: Closed
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Gnar Assignee: Thinkofname
Resolution: Invalid Votes: 2
Labels: 1.8, bug, entity, spigot
Environment:

Debian 7, git-Spigot-26dfd01-5cb9b70


Plugin: SpawnItem (Custom)

 Description   

There is no errors in the console.

When I spawn an item with world.spawnItemNaturally(location, itemstack), sometimes the items can not be picked up. It sometimes happens, sometimes it doesn't. It also won't call PlayerPickupItemEvent and the items will not merge with other items.

Typically this happens several hours after server restart.

Utilising https://gist.github.com/aadnk/5563794#file-cancellationdetector-java I am able to determine that no plugin is cancelling PlayerPickupItemEvent and the event is not being called at all on these specific, random items.

Players have suggested that it happens when a chunk is unloaded and reloaded, but I have unloaded chunks and reloaded them and the item will still work sometimes.

My exact plugin code hasn't changed in months and was working prior to updating to the latest Spigot. Previously my old build was at least a month old, and was on a Spigot 1.8 build. Unfortunately I do not have the build version.



 Comments   
Comment by Chris Lutte [ 13/Mar/15 ]

This needs to be closed as the OP has confirmed it was not a spigot issue and nobody else was provided any evidence that it exists apart from stating it effects them but hasn't provided any details even after being asked.

Comment by Gnar [ 13/Mar/15 ]

It turned out to be because I set the despawn rate for items to 30 minutes on the spigot.yml

Not really a Spigot issue after all.

Comment by Gnar [ 12/Mar/15 ]

It's worth noting that in my spigot.yml I had the item despawn time set to 30 minutes for the items. I saw Black Hole mention 28 minutes.

If I lower that would that have any effect? I have lowered it either way to 15 minutes.

Edit: Currently speaking to Chris to see if it's due to the way chunks unload.

Comment by Chris Lutte [ 12/Mar/15 ]

Jesus sorry trying to do a million this at once.

There has been a big internal chunkIO changes. One thing to note this is direct from the source by ThinkingOfdeath

"If chunk had previously been queued to save, must do save to avoid loss of that data" and

"Always remove entities - even if discarding, need to get them out of world table "

Both of them are in regards to unloading chunks. If you have access you can see it here

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/CraftWorld.java?at=d8a9c7be4227b2243968b63ab7cc7a00098c93ad#177

As Gnar mentioned he does a lot of Loading and Unloading of chunks this is likely to be the issue. But can't confirm it just yet. But it certainly points to the memory leaks, it won't just be your plugin any plugin that hasn't updated to use the correct Unload methods will cause the same effect.

Comment by Black Hole [ 12/Mar/15 ]

Commit d8a9c7be422 is the update for 1.8.3. It was commited some days before official release.

Comment by Chris Lutte [ 12/Mar/15 ]

The code for ticking item stacks changed with 1.8.3: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/nms-patches/EntityItem.patch

The problem is that patch was released 13 days before 1.8.3. So in theory a 1.8 build before this patch and the issue should not be present.

having a drop delay of 32767 makes the item infinite and it will never despawn.

Let me test it and spawn some items and wait 40 mins. And see what happens. BUT this should not effect newly dropped Items only past ones. From the sound of it am I correct in saying when it starts new and old drops are unable to be picked up ?

@Sherwoodax can you provide more details please eg your set up plugins environment thanks.

Comment by Black Hole [ 12/Mar/15 ]

The code for ticking item stacks changed with 1.8.3: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/nms-patches/EntityItem.patch

It looks correct, but the error might occur if elapsedTicks is larger than 32767. If the server is running at nearly 20 TPS, this takes about 28 minutes.

Comment by Sherwoodax Sherwood [ 12/Mar/15 ]

Can confirm this affects me as well. After a seemingly random amount of time, players are unable to pick up items.

Comment by Gnar [ 12/Mar/15 ]

I will be providing code upon request. There is sensitive information in the code that I need to remove before I can share it, for those willing to test it in the proper test environment.

Comment by Chris Lutte [ 12/Mar/15 ]

You slowing it down by not providing code. As profiling that will provide the answer to if its your plugin or not.

Comment by Gnar [ 12/Mar/15 ]

I'm merely providing more information in response to your queries. The more information provided the easier it is to resolve the issue.

There are no command blocks.

Edit: I agree, his attitude does stink.

Comment by Chris Lutte [ 12/Mar/15 ]

Comment till your blue in the face unless i can see the plugin code there is not a lot I can do. As I know what changes have been made in the updates the ones in the last few days would have no relevance.

Is there command blocks in this world ??

But until I have seen the plugin i'll have to just leave it . You might think i am being persistent but 99/100 it ends up being a plugin issue. I should know i have the same issue with some of my own and it always turns out to be me not updating correctly.

Edit: Sorry to say but your friends attitude stinks. As this will get marked as invalid as it currently stands. If you don't want to provide you plugin for whatever reason doesn't help you case.

Comment by Gnar [ 12/Mar/15 ]

I already know of the locations, so I know that is the highest block value. The locations aren't random, they're in a list.

The map is prebuilt, and this is for an RPG-style server. I manually select every location. I go to each location and add .1 to each y value to ensure that it does not get stuck inside a block. All items will work at any location, except sometimes items will not be able to be picked up and it won't call PlayerPickupItemEvent either.

This is only for one world. There are no other worlds loaded. There is no reference to the items anywhere.

I have also contacted someone who also uses the method dropItemNaturally and he confirmed that around the 12 hour mark the same thing happen on his server and he updated several days ago. He does not use my plugin, however.

I'll see if I can get him to post on here with his findings too.

The minority of items is random each time. I mention this in the first post too. Just some items won't be able to be picked up. There's no correlation however in the locations nor the item itself that is affected - The only correlation is time. It occurs after 3-12 hours. Another correlation is that it is only items spawned with dropItemNaturally.

It could be an issue with the latest Spigot build. Considering this issue was posted 2 hours ago and your first reply was 42 minutes ago, I doubt you were tested it for an extended period of time, which is what this bug would require to be properly identified.

I don't remove entities on chunk unload.

I understand that all you can really do is try to replicate the issue though. I have tried many times to replicate the issue to find out the cause. Right now I know the effect, but not the cause. The best that I can say is that it happens after a few hours. Sometimes it takes 3 hours, sometimes it takes 12. Regardless, it happens every time after a restart.

I'll see if I can get my other server owner friend to comment on his findings about this.
Edit: He won't be commenting, he doesn't want to register and figures it'll get fixed either way, unfortunately.

Comment by Chris Lutte [ 12/Mar/15 ]

What is the minority of items that it happened on ??

Comment by Chris Lutte [ 12/Mar/15 ]

Pm me a link to the plugin itself, it might well of worked on a build a month ago, that was 1.8, latest is 1.8.3.With a lot of MC changes.

Setting it to 64.1 doesn't mean much. how do you know that is the highest Y block at that location as your not testing for it.

Until I can see you entire plugin not much I can do as I can't replicate it. My account on forums is also Relicum.

Also do you have multiple worlds if so how are they loaded and unloaded. Also are you holding a hard reference to the items in the world ?? Something is holding a reference to the object or chunk. If your manually unloading and load chunks I imagine that could be your issue, are you removing entities from the chunk before unloading it ? I'll wait to see the entire plugin as the issue is with your plugin. Spigot might well of updated but as I can not replicate it at all it is not an issue with the Spigot build.

Comment by Gnar [ 12/Mar/15 ]

Did you test it for an extended period of time like I suggested in my original post? My code is fine, it was working on previous builds, just not on the current one. I have tried to see if it is from chunks loading/unloading, but haven't found a correlation there. The only correlation is that it only ever occurs after the server has been running for 3-12 hours and only on a minority of items.

The chunks are populated, I have checked and confirmed that. This task is not async. The Y value is, for example, 64.1, to prevent it falling inside a block.

I could try adding a delay, but like I said, it worked until I updated spigot. The only modification to the environment is Spigot.

Yup, I would only drop the exact same item on top of it to test that.

Comment by Chris Lutte [ 12/Mar/15 ]

Also any custom items will not merge with other items except clones of the custom item itself.

Comment by Chris Lutte [ 12/Mar/15 ]

Just to let you know I just tested it and have no issues at all. I can confirm it works 100% as its meant to. So it has to be something in your plugin, regardless if it used to work.

Pickup is not needed to be set to zero if you want instant pick ups.

From the looks of it you might be spawning the items in unpopulated chunks (Loading does not populate the chunk on its own, try setting the block at the location to air and then spawn in as you could of spawned it inside a empty block. Also what Y height are you dropping this from. Also is the task Async ?

Try adding a delay of a tick between loading and dropping as doing it in the same tick doesn't sound right to me.

Comment by Gnar [ 12/Mar/15 ]

Sure.

http://pastebin.com/G51cBhDY is the code I use.

This is ran with a scheduler with a location list. I originally thought it was a plugin blocking it until the CancellationDetector didn't return anything, the item didn't merge and the item will never, ever despawn. I tested it with a vanilla server with only my plugin and this occurs too.

http://www.spigotmc.org/threads/cant-pick-up-item.54380/ This thread is what made me consider that it might be a Spigot issue rather than plugin.

Let me know if there's any extra info I can give you.

Comment by Chris Lutte [ 12/Mar/15 ]

the method your looking for is world.dropItemNaturally(Location location,ItemStack item)

As that is the current name of the method. Where are you getting that method from its not on the bukkit World object (Used in Spigot API to) Try using that method.

Can you post the relevant parts of the code as currently its a little hard to advise.

Comment by SpigotMC [ 12/Mar/15 ]

Your build is not the latest and therefore may be the reason you are having this issue. Spigot is 1 version(s) behind. CraftBukkit is 5 version(s) behind. This message was automatically generated and is not guaranteed to be a solution to your issue.

Generated at Sat Apr 05 06:16:34 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.