Skip to content

Commit

Permalink
Fix indestructable tools still sometimes despawning (#5170)
Browse files Browse the repository at this point in the history
Technically, it will still potentially despawn if you leave the game running for several years with how this is setup, its the cost to pay for the item spinning. Due to short rounding if the game shuts down then the age of the item will be truncated and thus never reach the lifetime.
  • Loading branch information
KnightMiner committed Dec 13, 2023
1 parent 25f7d27 commit dd888db
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
public class IndestructibleItemEntity extends ItemEntity {
public IndestructibleItemEntity(EntityType<? extends IndestructibleItemEntity> entityType, Level world) {
super(entityType, world);
this.setExtendedLifetime();
// using setUnlimitedLifetime() makes the item no longer spin, dumb design
// since age is a short, this value should never be reachable so the item will never despawn
this.lifespan = Integer.MAX_VALUE;
}

public IndestructibleItemEntity(Level worldIn, double x, double y, double z, ItemStack stack) {
Expand Down

0 comments on commit dd888db

Please sign in to comment.