The Register<EntityType> event method is in my main mod class, which I posted in my first comment. The issue already appears with the reduced class I posted. This is the full class:
public class EntityItemNoDespawn extends ItemEntity {
public EntityItemNoDespawn(EntityType<?> type, World world) {
super((EntityType<? extends ItemEntity>) type, world);
this.rotationYaw = (float)(Math.random() * 360.0D);
this.setMotion(0, -1, 0);
this.setInfinitePickupDelay();
this.setNoDespawn();
}
public EntityItemNoDespawn(World world, double x, double y, double z, ItemStack stack) {
super(world, x, y, z, stack);
this.setPosition(Math.round(x) + 0.5, Math.round(y) + 0.5, Math.round(z) + 0.5);
this.rotationYaw = (float)(Math.random() * 360.0D);
this.setMotion(0, -1, 0);
this.setInfinitePickupDelay();
this.setNoDespawn();
}
@Override
public void tick() {
this.setCustomName(new StringTextComponent(this.getItem().getCount() + " " + this.getItem().getDisplayName()));
this.setCustomNameVisible(true);
super.tick();
}
@Override
public boolean getAlwaysRenderNameTagForRender() {
return true;
}
}