Tinkers Construct

Tinkers Construct

164M Downloads

Indestructible items despawn

iTrooz opened this issue ยท 10 comments

commented

Minecraft Version

1.18.2

Forge Version

40.2.0

Mantle Version

1.9.45

Tinkers' Construct Version

3.6.4.113

Describe your issue

Problem description

Dropped indestrucible items seem to despawn after some time. I've tried to drop a plate chestplate, as well a Cobalt Mattock (see screenshot). Both had a diamond as well as a netherite modifier
image

After some time, they despawn, despite not burning in lava, and being tconstruct:indestructible_item types.

I could also reproduce this in 1.16.5

Possible fix

I've done very few Forge development so I may be wrong, but maybe you need to call setUnlimitedLifetime() instead of setExtendedLifetime() here ?


https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.18.2/net/minecraft/world/entity/item/ItemEntity.html#setUnlimitedLifetime()

Other

Relevant discord discussion: https://discord.com/channels/381483562576379907/395801350731989003/1173370244916584528

Crash Report

No response

Other mods

None

Tried reproducing with just Tinkers?

Yes

Performance Enchancers

None of the above

Searched for known issues?

Searched open issues, Searched closed issues, Checked the FAQ

commented

Fixed in 3.7.0.152 for 1.18.2

commented

Thanks

commented

Max int is not no despawn, its just a long time. The vanilla method to prevent despawn should be used instead. Its possible we are calling the wrong one; Its also possible force accidently broke it in one of their patches. I will check when I next get a chance

commented

If you are interested, here is the patch I made for 1.16 (seems to work): 5623a97

commented

Once again I don't a lot of experience, but from my research it seems like setNoDespawn() is indeed broken in 1.16. (it seems to set Age to -6000 in the NBT, doubling the lifetime of the item)
I inspired myself from these lines for my patch: https://github.com/Jomcraft-Network/NoItemDespawn/blob/95bc454c364d9c9188c55fb32e10e314c65b0362/src/main/java/de/pt400c/noitemdespawn/EventHooksFML.java#L55-L58 but if you are looking for a way to prevent them from despawning indefinitely, calling event.setCanceled(true); in ItemExpireEvent should be enough

commented

You keep saying 1.16 but your issue is for 1.18. which is it?

commented

Both. I found the bug in 1.16 but then reproduced it in 1.18 because AFAIK 1.16 is EOL here.
setUnlimitedLifetime() would be the patch for 1.18 (I didn't test it), 5623a97 (or the alternative below) would be the patch for 1.16

commented

Turns out the "proper fix" also stops items from spinning, so went with extending the lifespan to a large degree. Event is overkill for an item I control.

commented

Okay ! Well, I'll close this issue since it's fixed. Thank you

commented

Do not close it until it is in a released update. That is why Knight didn't close it.